Adding a new translation to sahana

Asked by Giacomo Mirabassi

I have some problems to install the italian translation I created to a tryout sahana installation. I followed the instructions contained in http://wiki.sahana.lk/doku.php/doc:localization_guide:english#add_a_new_language but i run into some problems:

After adding the new locale and clic on "get new list" nothing happens.
If I clic on the "save" button the system ask me to make writable the path /sahana/res/it/LC_MESSAGES/sahana.po, which not exists. I make the folder and give permissions and the system create a new sahana.po file.
Then i follow the procedure described on the page above but when I clic on "compile messages" nothing happens except the textarea disappears, no .mo file created and no error/success messages appears.
If i make the .mo file by hand still no changes appear on website...

what can I do?

Thanks in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
Sahana-Eden Edit question
Assignee:
No assignee Edit question
Solved by:
Giacomo Mirabassi
Solved:
Last query:
Last reply:
Revision history for this message
Tim McNamara (tim-clicks) said :
#1

Giacomo-

I have notified our localisation/translation expert. Hopefully he will be able to answer your questions shortly.

Revision history for this message
nursix (nursix.org) said :
#2

Hi Giacomo,

I don't recommend that way of translating Sahana you try to do - but however, if you need to do it that way, here a few comments:

1) The built-in translation function is problematic due to common file system issues (permissions etc) and since the result is not checked. Principally, you've followed the correct working path, but any minor error can prevent the whole from working (e.g. a missing "\n" at the end of a string).

2) You need to check some things in your configuration:
a) does the server accept that locale? The usual (and conform) locale code for Italian is "it_IT" not "it" - so you probably need to rename the path into res/locale/it_IT/LC_MESSAGES and edit the corresponding entry in the res/locale/locale file. Note: probably your server is configured to accept "it_IT.UTF-8" instead of "it_IT" - so you should try this likewise.

b) Does the .mo file you created contain any data? Sometimes, msgfmt just encounters a minor problem (e.g. plurals mismatch, minor syntax errors) and issues just a warning, but nevertheless creates a .mo file, which then contains no data. This is actually an issue in msgfmt itself, but however, the messages are not propagated to the Sahana UI and hence you cannot see them.

c) Does the sahana.po file which Sahana has saved contain any translations? Maybe, due to the file system issues you described before, the translations got lost and Sahana has saved an empty file? Just open sahana.po with a text editor and check it out. Btw - if you have admin access to the server, I'd recommend to use a simple text editor instead of the Sahana UI - or better, use a PO editor to work on PO translations, e.g. POEdit or Virtaal. This prevents any syntax or encoding issues.

d) IMPORTANT: You always need to restart the webserver (and the application) when you have updated the locale file. The built-in translation function does not enforce a reload of the localization files - so it is actually completely useless unless you have admin access to the server (which you have, I guess).

e) As laughable as it sounds: check for any caching problems in your browser :) Press F5 (or Ctrl-F5 respectively) to reload.

3) I could probably help you better if you'd give me a chance to check your .PO file. Feel free to send the PO file to me (<email address hidden>) for a basic check and compilation.

4) A much better Wiki page about Sahana translation is:
http://wiki.sahana.lk/doku.php?id=translate:home

Feel free to contact me for any further questions -
Best regards,
Dominic

Revision history for this message
nursix (nursix.org) said :
#3

Btw,

you should also check whether your server is configured for Italian locale or not.

I say this, because e.g. Debian systems are by default just configured for en_US, and nothing else. Every other locale needs to be configured first.

In contrast, SuSE as well as Ubuntu-based systems configure a number of the most common locales even in a basic setup, and you don't need to do anything here.

Windows-based systems configure almost all locales, but instead often have encoding problems (i.e. the default encoding is not UTF-8, which causes problems when the encoding of the translations is not explicitly specified).

Dominic

Revision history for this message
Giacomo Mirabassi (giacmir) said :
#4

Thanks for the responses.
Actually I'm not enforced to use this way of translating the software, I translated the interface using the official pootle online interface at http://translate.sahana.lk/it/sahana0622/ so the information i'm interested in is how to use those translations in order to check them in the real software environment.

It could be important to say that I noticed I couldn't switch even to any of the preinstalled languages. So I wonder if my problem/error stays at another level.

The steps I followed to generate the .mo file were to download the seven sahana-*.po files from the site and to join them together, then to remove all the duplicate headers and to correct all the errors reported by msgfmt.

referring to your suggestions:
I've checked that both my generated .mo and the sahana.po file generated by sahana actually contain data (even if actually I never used the .po file generated by the sahana instance), restarted the server, cleared browser cache and I've renamed the folder into it_IT. Nothing changes.

Thanks again for help

Revision history for this message
nursix (nursix.org) said :
#5

:) I see.

Thanks for translating at the Pootle site. The sahana.po file is split into seven sections to support distributed workflow, but yes - to install the translation you need to merge them into one sahana.po and compile the result using msgfmt.

Seems that you're doing that quite correctly, though.

Tipp: joining the PO files manually is hard work, you /could/ try the Translate Toolkit (http://translate.sourgeforge.net) and use pomerge to merge them using sahana.pot as template. That makes things much easier - no duplicate headers, no duplicate entries - just one command.

Using the preinstalled languages doesn't work here either. Never worked, honestly spoken. AFAIK these are dummies carrying no translations. And the si_LK locale, anyway, is unlikely to be installed at your server, nor are the necessary fonts at most of the clients.

You may find official language packs for Sahana on my website http://pub.nursix.org/sahana/locale. Just unpack them in res/locale and edit the file res/locale/locale accordingly (either manually or using the Sahana admin/locale interface - manually is much faster, of course).

From what you wrote above I suppose that your server doesn't accept the it_IT locale.
What kind of operating system are you using at the server?

Dominic

Revision history for this message
nursix (nursix.org) said :
#6

Oh - wow:

You did an almost complete translation!

Gimme a few minutes to produce the official Sahana language pack and add your name to the Sahana Wiki contributors hall of fame :)

Great work!
Dominic

Revision history for this message
Giacomo Mirabassi (giacmir) said :
#7

Thanks,
I'll wait for the language pack.

I worked on this translations together with some friends of the scout group i'm in, and I would like (if possible) to have them represented as contributors, at least as group. I would be glad if you could insert us as "Clan Il Timone - agesci Pg3"

Thanks again.

Giacomo

Revision history for this message
nursix (nursix.org) said :
#8

Done.

Language pack is packed and uploaded to http://pub.nursix.org/sahana/locale.
Also, I installed it at https://backus.nursix.org/dmsdemo - works perfectly.

Using Debian, I had to do the following:

1) Adding "it_IT UTF-8" to /etc/locale.gen
2) Running locale-gen from command line
3) unpack the language pack in res/locale (in Sahana)
4) adding "it_IT Italian" to the file res/locale/locale (in Sahana)
5) Restart the webserver

This may be different on other systems, though. What kind of system do you use?

However - thanks again, special credits to the whole group!
Great work!

Dominic

Revision history for this message
Giacomo Mirabassi (giacmir) said :
#9

After several tries I managed it to work by changing a line in sahana/inc/lib_locale/handler_locale.inc

on line 90 i changed setlocale(LC_ALL,$locale) with setlocale(LC_ALL,$locale.".utf8")

It is obviously not a good solution, since it works only for utf8 encoded languages, but for my needs it's enough.

I'm using a local apache installation on an ubuntu laptop, but I think this can be an issue on several other distribution, yesterday we experienced the same problem on a debian server, I hope I can check this solution on that server in the afternoon.

according to php documentation the setlocale function uses the system locale definitions. My machine responded to the "locale -a" command showing that italian was it_IT.utf8, so I tried and works.

Thanks again for help.

Revision history for this message
Giacomo Mirabassi (giacmir) said :
#10

Also it works by simply adjusting the sahana/res/locale anche the language folder name accordingly to the right encoding.

Thanks again

Giacomo

Revision history for this message
nursix (nursix.org) said :
#11

Yes,

that's what I mentioned before.

The locale identification depends on your system's config, and Ubuntu uses the UTF-8 extension in the default configuration (however, you /could/ still change that into it_IT).

Note: there is nothing wrong with Ubuntu here: The "it_IT.UTF-8" notation is absolutely conform with the standard, whereas "it_IT" is incomplete and leaves the encoding to the system's default (which is not necessarily UTF-8).

There's no need to change that code line.

I'd rather recommend that you:
- rename your locale path in Sahana from res/locale/it_IT into res/locale/it_IT.UTF-8
- change the entry in res/locale/locale from "it_IT Italian" into "it_IT.UTF-8 Italian"

That works likewise and is the more logical approach, I mentioned it before.

Dominic

Revision history for this message
nursix (nursix.org) said :
#12

*lol*

Thanks, same thought here.

Dominic