LCL translation machanism is not good for a large project and I got a good solut lazarus / 31-LCL ---------------------------------------------------------------------- sainimu78 · 2016-09-02 05:42 If a project is large, so many .lfm it has, so many property stored in some .po files, bad thing comes. Many words to be translated in those .po's must have the same ones or say it needs to translate so many bundles of the same words to be bundles of the same words translated. To be short, it has so many repeatitive translation works to do and hard to maintenan all .po's if some word translation has to be changed. My solution is(in short): 1. Handles many LCL components: procedure LCLTranslateComponent(obj:TObject; poFile:TPoFile); begin   if(obj is TCustemForm)then   begin     for idx:=0 to obj.Components.Count-1 do       str := obj.Components[idx].Caption;       obj.Components[idx].Caption := poFile.Translate(str);   end   else if(obj is TCustemComboBox)then   begin     for idx:=0 to obj.Items.Count-1 do       str := obj.Items[idx];       obj.Items[idx] := poFile.Translate(str);   end   else if(obj is TCustemStringGrid)then     ... alike above   else if(obj is ... other standard base LCL component classes)then     ...   ... end; 2. Calls the procedure LCLTranslateComponent(): procedure LCLTranslate(obj:TComponent; poFileName:string); begin   if((obj is TComponent)=False)then     Exit   poFile := TPoFile.Create(poFileName);   for idx:=0 to obj.Components.Count-1 do     obj.Components[idx].Caption := poFile.Translate(obj.Components[idx]);     LCLTranslateComponent(obj.Components[idx]. poFile);   poFile.Free; end; 3. Calls the procedure LCLTranslate().   ...   LCLTranslate(frmDemo, 'my_defualt_resource_string'+'.'+curLang+'.po');   ... 4. All forms needed translation call LCLTranslate 5. Edit one .po file that it only contents resourcestring's definitions from one .pas unit. 6. If one gets some same words need to translate differently in some case, another .po file can be created in that same way as before but only contents the special resourcestring's to be translated. For example, the form or unit needs the special translation uses 'my_special_resource_string.po' after 'my_defualt_resource_string.po' in code:   LCLTranslate(frmDemo, 'my_defualt_resource_string'+'.'+curLang+'.po');   LCLTranslate(frmDemo, 'my_special_resource_string'+'.'+curLang+'.po'); Or in some sense of easier to maintain way, change the original word wants to be special to be actually special like this:   if there are many captions of 'view' of many buttons in many forms to translate.   In many casees the original word 'View' is translated to '视图', for the special button, the word 'View' should be translated to '查看'.   Now change the special 'View' to 'SpecialButtonInForm.View'.   for the English .po file 'my_defualt_resource_string.en.po'     edit the translation of 'SpecialButtonIn.View' to be 'View'   for the Chinese .po file 'my_defualt_resource_string.ch_CH.po'     edit the translation of 'SpecialButtonIn.View' to be  '查看'   then the 'my_special_resource_string.ch_CH.po' is no need and left no more boring works to be done. This has one drawback that it can only be used once, because the identifiers for searching are those captions of control that already are translated in other language and cannot be used as identifier any more. Maybe this can overcome by extanding some .po file? this type of file can store the original words, or by extanding TPoFile class to store the original words? Whatever, How do you think my solution? ---------------------------------------------------------------------- Bart · 2016-09-02 21:35 What is wrong with having all your trasnlatable strings in 1 unit (as resourcestrings) and simply use translations unit? Look at how the IDE handles it. Bart ---------------------------------------------------------------------- lainz · 2016-09-02 21:42 I think if you need 'View' and a special meaning of 'View' in another control, you can use: resourcestring   rs_view = 'View'   rs_view_special = 'view' for example, with no need of special code. Then OnShow or OnCreate what you prefer, set the caption: Button1.Caption := rs_view; or rs_view_special, the one you need. Always there is work to do, in code or in translation, to save time in one you spend time in the other. Automatic form translation is one of these, a lot of OK buttons that you need to translate one by one. In the other hand using resourcestrings rs_ok then you need to assign it to all buttons by code. There are projects that mix both. ---------------------------------------------------------------------- marcov · 2016-09-03 14:05 Quote from: Bart on September 02, 2016, 11:35:00 pmWhat is wrong with having all your trasnlatable strings in 1 unit (as resourcestrings) and simply use translations unit? Look at how the IDE handles it. Working with resourcestrings for GUI, you need code to assign them for every text in the gui, even standard, common ones. This is ok for something that is as intensively developed as the IDE, but IMHO less for e.g. screens made for one customer. Gettext has support for contexts to solve the base problem of duplicate meanings that sainimu describes (which even happens with languages related to English like Dutch and German, not just with Chinese). Apparently such context can be stored in the default string itself (and should then be stripped by the translation system), but afaik FPC/Lazarus implementation doesn't support that fully ( http://bugs.freepascal.org/view.php?id=28684 ). Note the context-in-string bit was new for me, I just happened to have seen that bugreport just before I saw this message. I haven't researched the functionality fully yet, but some form of easy disambiguation in the GUI without devolving to a solution that needs special treatment for each string would be nice.