Forum > Translations
I18N and maintaining PO files
dbannon:
OK, great answers folks !
As stated, tick the checkbox dsiders mentions and, lo ! an old translation file I had in there has been updated with -
1. new stuff I added since it was done
2. unused entries removed.
3. Unchanged entries have kept their translation.
Hmm, when looking at the updated Spanish po file, I note that some entries in POEdit are orange in colour, I'm unsure why. Firstly we have new entries that don't have a translation, then we have some with a translation in black and some in orange, wonder what the difference is ?
I'll play a little and update the wiki as I work it out.
How good is this IDE ? And how good is this forum !
Davo
dbannon:
Hmm, no, not working. The I18N stuff in my app that is. So, made a simple example and thats not working either. I made a tiny app that includes -
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses LCLTranslator; procedure TForm1.Button1Click(Sender: TObject);begin SetDefaultLang('es', 'locale', true); memo1.append('Country Code ' + Copy(GetEnvironmentVariable('LC_CTYPE'), 1, 2));end;
Turned I18N on in project options, pointed it to a directory called locale and built. I then used poedit to make a new Spanish version, called project1.es_ES.po and a matching project1.es_ES.mo containing some fake Spanish translations.
I tried setting a run parameter in the ide of --lang=es and also launched from linux command line also with the same switch. But all I see is english captions.
So I used strace to see what files were being opened or attempted. No sign of the app making any attempt to open a file called project1.es_ES.mo or look in a directory called locale other than /usr/share/locale
Note I also looked at the LC_CTYPE var and thats always blank. And I tried setting language to es in the code. User both DefaultTranslator and LCLTranslator (only later allow use of SetDefaultLang() ). Appears to me the switch, "--lang=es" is being ignored.
Just what have I missed ?
* I use lcltranslator (or defaulttranslator),
* I tick the Project->ProjectOptions->i18N , enable i18N
* I use a runtime commandline switch --lang=es and --lang es (as suggested by wiki page).
* I tried putting the necessary files in a directory called locale and languages
Davo
wp:
--- Quote from: dbannon on April 22, 2019, 01:34:51 pm ---new Spanish version, called project1.es_ES.po [...] I tried setting a run parameter in the ide of --lang=es
--- End quote ---
These settings don't match: either call the translation file "project1.es.po" or ask for language "--lang=es_ES".
dbannon:
Thanks WP, I did try both combinations, no difference.
I have been browsing through LCLTranslator and its pretty weird !
Firstly, we have -
for i := 1 to Paramcount - 1 do begin
So, if the --lang=es is only parameter, we don't do the subsequent test.
Next, if instead use we use a space rather than an '=', --lang es we do pick it up.
It then calls the helper, GetLocaleFileName(Lang, LCExt, Dir); that tries almost every possible combination of short and long locale codes and directory structure.
About the only combination it does not try is the one documented in the wiki, that is ./locale/project1.es.mo
Now, I am happy to update the wiki but am not really sure if that is the correct thing to do. I don't for the life of me understand why we have to use the space between long switch and its parameter, but thats clearly what the code wants.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} -----lang es // works but is inconsistent with normal lazarus model--lang=es // does not work, but, I believe should. -les // does not work-l es // does work
So, rather than fixing the docs, should I fix the code ? Are there people depending on existing model ?
There are two separate issues going on here, the formt of the switch AND the location of the mo file.
Davo
(sorry for edit, accidental early post ...)
(Another edit : it does in fact find ./locale/project1.es.mo but only if it has not found project1.po first. If it finds that, and thats likely to be your primary language one, in my case, English, it uses it. So, it appears to not have changed. So, important, don't keep po files in ./locale I think searching for ./locale/project1.po is a mistake, I cannot imagine why someone would want that ? )
Thaddy:
I would not change anything.
The options style is simply GNU gettext format. (even generic Linux/Unix options format)
It would be very strange if the options would differ from GNU gettext...
https://www.gnu.org/software/gettext/
Options are always a point for discussion, but in this case: keep the GNU syntax.
I for one use it not only for Lazarus but for many other purposes.
It would be very unnatural if the syntax starts to differ between applications.
Navigation
[0] Message Index
[#] Next page
[*] Previous page