Translations by users

Topics: Localization, Writing modules
Jul 18, 2011 at 3:57 PM

I've just been reading about PO files and using them to translate the Orchard CMS (http://orchardproject.net/docs/Creating-global-ready-applications.ashx)

This is very useful (i've just signed up to start translating ;) ) but I would also like my users to be able to customize some front-end semi-static strings. For instance, the "read more" link or the "next page" link. Would it be possible to install the PO editing module that Orchard itself uses? That way I'd use it as a dictionary-like module to let my users translate specific words.

Of course, these PO files will be specific for my application so I won't upload them.

Coordinator
Jul 18, 2011 at 7:22 PM

The po editing application that we have on the site is not an Orchard module, it's a plain MVC application. Furthermore, it doesn't manipulate the po files directly, but rather uses a unique database for all translations. The po files are only generated from the database when someone first downloads them. I have no problem providing the source code for the application under the same BSD license as Orchard, but I'm not sure it would cover your requirements.

Jul 19, 2011 at 2:15 PM

Hmm, that's not the most user-friendly solution in my case ;)

It would be really nice to integrate it into Orchard and edit the PO files directly. Should be possible, right?
When I get to the localization part of my project, I'll definitely give it a shot. 

Jul 19, 2011 at 2:31 PM

To me it sounds unnecessary to edit the PO files if you have access to the DB holding all the translations - I guess the translation wep app will give you an easier editing experience than that of editing files...

I would be interested in access to that web app and the DB structure you use - we've built an online translation tool for www.camping.info using WebForms but it was never pretty enough to release to the public ;-) So now for providing translation ability to our customers we will need a replacement that will easily work with orchard.

Bertrand, would you make that app available somewhere?

Thanks, Oliver

Coordinator
Jul 20, 2011 at 12:33 AM

Editing the po files from that application would not have worked, no.

Yes, I can make the application available. I'm kind of flooded recently so expect a substential delay.

Jul 20, 2011 at 7:47 AM
No problem, i think this will be a nice feature. Thanks for providing the code!



On 20 jul. 2011, at 01:33, "bertrandleroy" <notifications@codeplex.com> wrote:

From: bertrandleroy

Editing the po files from that application would not have worked, no.

Yes, I can make the application available. I'm kind of flooded recently so expect a substential delay.

Aug 22, 2011 at 7:57 AM

The substantial delay is probably not over yet, but I'm still interested when you get around to it, bertrand :)

thnx in advance!

Oct 10, 2011 at 1:14 PM
Edited Oct 10, 2011 at 1:14 PM

I'm also very interested in an application like this. So the content managers can update the translations them self

Coordinator
Oct 10, 2011 at 8:59 PM

Quick update on this: I haven't published it yet because I'm in the process of moving that to an Orchard module...

Oct 11, 2011 at 2:16 PM

Oke that's very good news! cool!

Oct 31, 2011 at 5:01 PM

Bertrand, the deadline for my translatable site is nearing. Is there an eta on the orchard translation module?

Coordinator
Oct 31, 2011 at 10:14 PM

It's already available, but I forgot to update this thread.

https://bitbucket.org/bleroy/orchardpo/overview

Nov 2, 2011 at 8:44 AM

Thanks! very nice! Is that module also available in the gallery?

Coordinator
Nov 2, 2011 at 8:45 AM

Not yet.

Nov 2, 2011 at 9:18 AM
Edited Nov 2, 2011 at 9:47 AM

Ok i've managed to get it working. But i'm getting the following error while donwload generated po package:

System.InvalidOperationException: No open entry.

update:

i'm getting the following error: A required anti-forgery token was not supplied or was invalid.  in UnzipPostedFileToDatabase

 


Nov 3, 2011 at 5:33 PM

I also had some trouble using the OrchardPo module. It's not exactly what I needed, so I forked and made some modifications to it. Actually, I re-wrote the whole thing :)

But it now works like I want it to:

  • Editors can edit each translation individually
  • You don't need to change any code! Keep using the @T("") or @T.Plural("","",int) :)
  • Changes are immediately visible for all users
  • All translations are cached for optimal performance (just like the default translation manager)
  • Ability to set the admin culture different from the global culture. It can even be set to a culture that isn't installed as website culture (e.g. english editors can edit the spanish website)
  • Userfriendly editing experience via a new "Translations" module in the Admin menu
  • When Multitenancy is enabled, each Tenant can have its own translations

Maybe these are also the features that you're looking for, Znowman. For now you can check it out at:
https://github.com/Q42/Orchard-DbTranslations/wiki/Orchard-Database-Translations

There's a couple of tweaks left that need to be done, next week I'll submit to the gallery.
If you're looking for other specific functionality, let me know I'll see if I can include in this package!

Coordinator
Nov 3, 2011 at 7:32 PM

Thanks guys, this is great to see. What I did was really for one single purpose (the Orchard site), so it's great to see you were able to reuse it for a wider scenario. One thing I'm still a little worried about is the dilution of efforts that means: if people can edit their translations locally, will that negatively impact our centralized effort?

Nov 3, 2011 at 9:28 PM

@lukasvan3l A super! great work!

@bertrandleroy you've got a point there. But i think that users will still create centralized localizations po files for modules which are on the gallery. because it has to be done only once and can be used directly in other created website also.

the good thing is that if the contentmanager wants to change a text field he can now. I think this module is very important to make Orchard successful as a general cms (which can be by users who are not programmer). without this module my customers can't edit text fields them self so i can't build and sell a website with Orchard to them.

Nov 9, 2011 at 2:29 PM

Glad you like it! It has a lot of reused code from OrchardPo and the Vandelay Translationmanager in it :)

About your worries, maybe this effort only makes it easier. For instance, I'm deploying for a site that has a lot of different editors. When they all pitch in to translate in their respective languages, it wil help a lot!

I could facilitate the road back to you by placing a "contribute" link that lets the users download the po.zip files and mail them to you, maybe even directly upload them in your translation module. In my case it would also help if editors can select specific translated modules to export, because some are specific and maybe even confidential. I'll take a look at that.

Summary: i think we can work things out so we're both happy! :)

Coordinator
Nov 9, 2011 at 9:47 PM

Sounds good. Please note that the translation manager's commands have options to limit the output to specific modules.

Developer
Nov 10, 2011 at 11:13 AM

Hi!

I started using Bertrand's translation module and so far I've encountered two errors:
First, the previously mentioned unsupplied anty-forgery token. However, for testing purposes you can disable this feature in the Module.txt file of the module, by setting the AntiForgery property to "disabled".
After I did this the post method worked, but I instantly recieved an exception with the following details:

  • Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: source
  • Source File: src\Orchard\Mvc\Routes\ShellRoute.cs
  • Line: 148

After tracking the error I've found that the exception origins in the LocalizationService's SaveStringToDatabase method. The exception is thrown because at first use, the table is empty. The funny part is that after adding a null-check into the code the exception was still thrown.

Nov 10, 2011 at 2:44 PM
Edited Nov 10, 2011 at 7:52 PM

@lukasvan3l ok i tested today your translations module and i'm impressed! you did a very good job! Many thanks!

Nov 10, 2011 at 4:10 PM

Thanks! I tried to get the UI as friendly as possible. Maybe Bertrand will enjoy working with it so much he'll consider using it instead of the OrchardPo module :)

Anyway, the module can be downloaded from http://www.orchardproject.net/gallery/List/Modules/Orchard.Module.Q42.DbTranslations

Internal testing found a couple of small issues that we're working on so the 1.1 release will be soon to follow. let me know how it goes at your end!

Nov 15, 2011 at 5:06 PM
Edited Nov 15, 2011 at 5:07 PM

I installed the module successfully and like it. 

I then tried to disable the Q42.DbTranslations feature it in the Dashboard. Since then I always get the following exception, when trying to get into the dashboard: 

Server Error in '/' Application.
No persister for: Q42.DbTranslations.Models.AdminCultureSettingsPartRecord
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.MappingException: No persister for: Q42.DbTranslations.Models.AdminCultureSettingsPartRecord

Source Error:

Line 85: 
Line 86:         public virtual T Get(int id) {
Line 87:             return Session.Get(id);
Line 88:         }
Line 89: 


Source File: C:\Projects\discoverize\src\Orchard\Data\Repository.cs    Line: 87

How should I repair the error?
Nov 15, 2011 at 5:21 PM

You could delete Q42.DbTranslations' source code, I think it will help.

@lukasvan3l, the Handler should also be decorated with the Feature attribute, so that the ActivatingFilter doesn't get executed.

Nov 16, 2011 at 9:26 AM

Thanks for letting me know, @latentlone, and thanks for giving me the fix, @q42jaap :)

It was a little more decoration, not just the handler but every class involved needed to be decorated. So almost every class in the module now has a feature decoration of
AdminCultureSelector or DbTranslations. Works like a charm :) 1.1 will be released end of this week!

Nov 16, 2011 at 10:27 AM
Edited Nov 16, 2011 at 10:29 AM

I enabled the fearture from the command line - now the dashboard works again. 

(I did not want to delete the feature - I just wanted to test something. That is why I would not like to delete the code.)

Another question: If the feature is enabled: Are existing po-files being ignored, and are only translations from the database used?

(Seems like the answer is yes - just tested it.)

Nov 16, 2011 at 10:43 AM

Existing po files are indeed being ignored. In the 1.1 release I've built in that you can import the existing PO files into the database.
That way when you install the module you can import the existing PO's and then you'll see exactly the same as when you were using the PO files.

Maybe in the future it'll use the PO files as backup, but hopefully this'll be sufficient.

Let me know if you miss anything! 

Coordinator
Nov 24, 2011 at 2:09 AM

This is all pretty cool. I'm glad you guys found OrchardPo was a good base for it.