Lazarus

Using the Lazarus IDE => Options => Topic started by: lainz on March 28, 2018, 07:10:41 pm

Title: Copy i18n to build folder
Post by: lainz on March 28, 2018, 07:10:41 pm
Hi, I've made a configuration in project options so the i18n is in the project folder like this:

Quote
project\i18n

Po are generated fine.

The thing I want to do is copy contents of i18n folder to

Quote
project\bin\debug\$(TargetCPU)-$(TargetOS)\locale\

So when I'm debugging I can test translations as well.

I want to do this from the IDE that's the tool I use to compile.
Title: Re: Copy i18n to build folder
Post by: Phil on March 28, 2018, 07:37:14 pm
I want to do this from the IDE that's the tool I use to compile.

You've tried "Execute after" in project options, right?

For example, for a project created by LazXProj, it always runs this to make sure the version info and install scripts are updated:

"$PKGDIR(AppXProj)/../utils/fix_xproj$ExeExt()" "$Project(InfoFile)"
Title: Re: Copy i18n to build folder
Post by: lainz on March 28, 2018, 07:56:15 pm
Thanks, I think this is not cross platform, right? I need to make an executable for each platform I'm using with Lazarus.

I was thinking something like PascalScript or similar.
Title: Re: Copy i18n to build folder
Post by: Phil on March 28, 2018, 07:59:55 pm
Thanks, I think this is not cross platform, right? I need to make an executable for each platform I'm using with Lazarus.

Not sure if I follow. I would say it is cross-platform. Maybe not very well documented, but I haven't found situations where I needed a separate .lpi, for example. Use the macros ($).


Title: Re: Copy i18n to build folder
Post by: lainz on March 28, 2018, 08:04:30 pm
Not sure if I follow. I would say it is cross-platform. Maybe not very well documented, but I haven't found situations where I needed a separate .lpi, for example. Use the macros ($).

I mean I need a different batch file for each OS I run that Execute after. Not something like run a PascalScript that does the copy of the files with no need of batch.
Title: Re: Copy i18n to build folder
Post by: Phil on March 28, 2018, 08:09:22 pm
I mean I need a different batch file for each OS I run that Execute after. Not something like run a PascalScript that does the copy of the files with no need of batch.

Run a compiled Pascal console app to do it. Only need one for that.

I've never found a use for Pascal Script.
Title: Re: Copy i18n to build folder
Post by: lainz on March 28, 2018, 08:15:48 pm
That's ok. I will try that.
Title: Re: Copy i18n to build folder
Post by: Phil on March 28, 2018, 08:18:45 pm
That's ok. I will try that.

If you put it in a package, as in my example above, you can add the command to your project options without worrying about where it actually is, by specifying its path with $PKGDIR().

In my example, the console app is relative to a known package, so it's slightly more complicated.

See Lazarus Cross-Platform Project for source:

https://macpgmr.github.io/
Title: Re: Copy i18n to build folder
Post by: wp on March 28, 2018, 08:25:14 pm
Your application probably saves its settings in an ini or cfg file. Add a setting for the Languages folder. After first run of the application edit the ini file and change the entry for the Languages folder to point to the "project\i18n" -- this way is is not necessary at all to copy files around.
Title: Re: Copy i18n to build folder
Post by: Phil on March 28, 2018, 08:29:26 pm
this way is is not necessary at all to copy files around.

I assumed that he was copying files into the structure he uses with the installed app on Windows and Linux (but not macOS, since path doesn't make sense there).
Title: Re: Copy i18n to build folder
Post by: lainz on March 28, 2018, 09:30:58 pm
Yes, I have a json cfg file stored in the user app data folder.

I'm using DefaulTranslator so I don't know if I can change that folder path. Maybe there is a parameter I can send to the app when it starts. But I don't know if is available.

About Mac, I don't have one. I'm running it on a slow VM. I'm not sure where DefaulTranslator looks for translation on a Mac. Will be nice to know more about it.
Title: Re: Copy i18n to build folder
Post by: Phil on March 28, 2018, 10:20:41 pm
About Mac, I don't have one. I'm running it on a slow VM. I'm not sure where DefaulTranslator looks for translation on a Mac. Will be nice to know more about it.

I'm not aware of any apps on Mac that use .po files for localization. Most use a combination of .strings and .nib files under the locale's folder (eg, MyApp.app/Contents/Resources/en.lproj for English). GIMP uses .mo files - maybe something similar to .po?

Note that Mac apps generally don't use .cfg, etc. files. Preferences are stored under ~/Library/Preferences, etc. See the list here:

https://macpgmr.github.io/MacXPlatform/PascalAndMapbox_3.html#MiscNotes

Title: Re: Copy i18n to build folder
Post by: lainz on March 29, 2018, 03:06:39 am
I'm using the cross platform way Lazarus provides for config and translations. But I don't know the exact details. How these work.
Title: Re: Copy i18n to build folder
Post by: Phil on March 29, 2018, 03:25:20 am
I'm using the cross platform way Lazarus provides for config and translations.

I feel your pain.

Just in case anyone is interested in how Mac and iOS developers do it:

https://developer.apple.com/internationalization/
TinyPortal © 2005-2018