Recent

Author Topic: Application not using/finding .mo files for i18n (works when .po included)  (Read 4597 times)

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
I'm in th eprocess of packaging up my application in an installer and have just found that when I only include the .mo translation files my application will not translate.

If I include only the .po files, then switching languages works perfectly.

Accoridng to the documentation "You want to distribute only the .mo files in the locale or languages directory", but it doesn't seem to be working.

I'm using a combination of DefaultTranslator and SetDefaultLang(langCode) to switch the language both via command line and via a menu option, but this only seems to work if I include the .po files.

Am I missing something?

-FM

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Does nobody have any suggestions as to why this isn't working?

Is there any extra info I can give that might help someone to help me with this?

The documentation clearly says that only .no files should be distributed with an application, but I have found that translations just don't work unless I include the .po files.

-FM

wp

  • Hero Member
  • *****
  • Posts: 11830
I checked this with a copy of the transations demo in the examples folder of the Lazarus installation, and it worked partly: With .mo files, the strings which were directly assigned to resource strings were correct, but those handled by the LCLTranslator were not translated (when I select my system language they were translated, too, but only once and stayed like that even when another language was selected later). With .po files all texts of the demo are translated.

To do this test, I had recreated all .mo files, and then I moved the .po files out of the "languages" folder to simulate your situation - note that the .pot file must be removed as well because it makes the translation system think that there are .po files. Note also that the .pot file was automatically recreated when I recompiled the project - I could prohibit this in my test by unchecking the "Create/update .po file when saving a .lfm file" in the i18n options (however, this is not a good selection in development).
« Last Edit: June 20, 2021, 11:09:31 am by wp »

AL

  • Sr. Member
  • ****
  • Posts: 256
I had the same issue, and could not get it to work with  .mo files. 
I decided to distribute the  .po files.
Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
I guess I'll have to go with distributing the .po files in that case - shame, I like to try to follow 'best practices' where I can.

-FM

 

TinyPortal © 2005-2018