Unable to locate files needed for translations lazarus / 10-Designer ---------------------------------------------------------------------- Gizmo · 2012-03-05 12:49 Hi I have been asked if I can create an Italian version of my GUI program. I have read http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_l ocalizations_for_programs and note that it states creating multi- language applications is within the capabilities of Lazarus. However, I do not seem to have either a *.po file or a *.rst file in my project directory? What might I be doing wrong? How do I generate these files in order that I can send them to my translator? Ted ---------------------------------------------------------------------- Gizmo · 2012-03-05 21:05 I have worked this out, having read the link I pasted above in more detail. For the benefit of others, it seems that you have to go to Project --> Project Options and select 'i18n'. Enable it by ticking the box and specify a directory to hold the po files. Click OK etc and compile and build your program. Lazarus then creates a lrs file and an lrt file and from them both it creates a po file in the directory you specify which you can send to a translator. From what I can gather, once it is returned to you translated, you have to assign a translator to LRSTranslator (defined in LResources) in the initialization section to one of your units Code: [Select]... uses   ...   LResources; ... ... initialization   LRSTranslator := TPoTranslator.Create('/path/to/the/po/file'); I assume from that it generates a language specific GUI. Time will tell, unless anyone can confirm in the meantime? Thanks Ted ---------------------------------------------------------------------- Gizmo · 2012-03-11 22:26 Actually, I haven't worked it out. I have received back from my translator the file project1.it.po with all the necessary translations. I copy it into my langaages subdir of my project. When I rebuild the project though, the same English version appears. Having re-read http://wiki.lazarus.freepascal.org/Translations_/_i18n_ /_localizations_for_programs#Translating_the_IDE I am now somewhat confused because apparantly use of LRSTranslator is not necessary anymore and instead I "Simply include DefaultTranslator in Uses clause". Having tried that, I still get the same English version when I press F9. I then searched for the .mo file as mentioned further down. When I navigate to /usr/share/locale/it/LC_MESSAGES (for Italian) on my computer there are lots of mo files but they are all ofr other applications. None are for Lazarus or my own project. So I am now rather confused? Can anyone help me work out how I simply get Lazarus to look at my .it.po file so that it rebuilds the form using the Italian translations? Many thanks ---------------------------------------------------------------------- ludob · 2012-03-12 08:09 The following works for me (assuming the program is called 'myprogram' and translations are french): - add defaulttranslator to the uses clause - put the file 'myprogram.po' in the directory 'languages/fr_FR' directory below the program directory. So you have to following dir layout: ./myprogram ./languages/fr_FR/myprogram.po For testing purposes you can force the language by adding the -l fr_FR or --LANG fr_FR or --lang fr_FR to the command line. ---------------------------------------------------------------------- Gizmo · 2012-03-12 10:40 Thanks for helping and the instructions. I've followed them but I don't know what I am doing wrong. It just won't work. I have a project dir structure as follows : /home/ted/LazarusProjects/Project beneath project I have Project/languages/it_IT and in that dir is my translated file project1.it.po I have added DeafultTranslator to uses. Code: [Select]uses   Classes, SysUtils, Strutils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls, Menus, ComCtrls, Grids, ExtCtrls, sysconst, DefaultTranslator; I chnage my form a little bit and then press Run --> Build, and I have tried just 'Run' and every time a new 'project1.po' file is created in the root of the languages directory (not the it_IT) sub directory of languages containing the English variants. And the program contains just English. So lastly I tried: Code: [Select]./lazbuild --language=it -B ~/Documents/LazarusProjects/Project/project1.lpi It compiled OK etc but again, no Italian version. What on Earth am I doing wrong? Laz 0.9.31, FPC 2.5.1, SVN Revision: 32326M, 32bit version in Ubuntu 10.04. ---------------------------------------------------------------------- ludob · 2012-03-12 11:34 Quote/home/ted/LazarusProjects/Project beneath project I have Project/languages/it_IT Beneath project? You should have /home/ted/LazarusProjects/Project containing project1 and /home/ted/LazarusProjects/Project/languages/it_IT containing project1.po Quoteand in that dir is my translated file project1.it.ponot project1.it.po but project1.po So your files are /home/ted/LazarusProjects/Project/project1 /home/ted/LazarusProjects/Project/languages/it_IT/project1.po ---------------------------------------------------------------------- Gizmo · 2012-03-12 20:00 This is driving me insane! OK, thanks for the further guidance. Your first observation was that I still had my Italian translated file named as "project.it.po". I thought it had to remain named like that for Lazarus to "pick it" as an Italian language set, but clearly that is just a recommendation for the humans and it has to be renamed back again for the compilation. So, I corrected that. Tried it all again, and still the same problem. I am obviously doing something wrong but I just can't fatham it, even with your guidance. So, for the avoidance of doubt, I have attached all the screenshots : Shot 1 shows my project directory Shot 2  shows the content of my "languages/it_IT" subdirectory, with the same Italian po file, renamed to just 'project1.po' as instructed and opened in gedit ---------------------------------------------------------------------- Gizmo · 2012-03-12 22:52 I've since read this: http://stackoverflow.com/questions/9326305/how- to-inform-free-pascal-compiler-to-set-locale-id-for-the-compiled- application and I tried the proposed answer, which was to edit the lpi project file where the language code for the project is specified, e.g. for my English project is read : So I changed it to "0410" for Italian, as per http://www.science.co.il/language/locale-codes.asp Opened the project, wiggled the form, rebuilt the project. Still, the English version appears!!! So I then went to the Project Options and chose "Italian" instead of "UK English" in the "Project Options --> Version Info" page (see screenshot). Tried again. Still in English. No Italian. I am about to jump out the window! How many ways can I tell lazarus "use Italian, not English" before it actually does it? What am I missing? Somebody? Please!! ---------------------------------------------------------------------- ludob · 2012-03-13 07:35 QuoteShot 2  shows the content of my "languages/it_IT" subdirectory, with the same Italian po file, renamed to just 'project1.po' as instructed and opened in gedit Don't know who created the .po file but you better ask your money back  A .po file has the format Code: [Select]msgid "" msgstr "Content-Type: text/plain; charset=UTF-8" #: tform1.button1.caption msgid "Button1" msgstr "Bouton1" #: tform1.caption msgid "Form1" msgstr "Formulaire1" Msgid is the original string and msgstr is the translated string. The string preceeded with # is just a comment to help the translator. Use poedit or any other po editor to translate .po files to avoid such mistakes. ---------------------------------------------------------------------- Gizmo · 2012-03-15 21:27 ludob Ah! That would be it then! Yes, once I regenerated a new po file and then copied my Italian translations into the msgstr section, wiggled my form and rebuilt, it worked! Now, though obvious with hindsight and obvious to anyone who has done it, it does not say in the translation wiki (http://wiki.lazarus.freep ascal.org/Translations_/_i18n_/_localizations_for_programs#Translating _the_IDE) about how the PO file works in this sense and as well as an addition to that wiki entry, perhaps a suggested future feature might be to add at the start of a generate PO file a couple of lines just to quickly explain and demo how it should be done. For example : Code: [Select]// Ensure you edit this PO file using this system: #: TFORM1.PERCENTAGECOMPLETE.CAPTION  // Comments about the GUI object. Do not edit. msgid "% Complete:"  // The original language. Do not edit. msgstr "% completato:" // The translated language. Edit If I had seen that, it would have saved me a considerable amount of time and might help save others the issues I have had? Regardless, I thankyou very much for helping me out with this Ludob. ---------------------------------------------------------------------- ludob · 2012-03-16 07:22 The po file format is a third party, standard format described in detail by its autors: http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files As with any third party file format, the format is not decribed in the wiki page for a tool/component that uses that format. Nobody would expect the EPS or SVG file format details in the fpvectorial wiki page. Or the dbf file format for TDBF. But all these components or tools will also fail if a wrongly formatted file is presented. The difficulty here is that your original PO file is syntaxically correct. An application can be developed completely in italian (msgid italian text) and the empty msgstr simply means that there is no translation (yet?) for the string. Feel free to update the wiki page and add a trouble shooting paragraph.