* * *

Author Topic: Copy i18n to build folder  (Read 2572 times)

lainz

  • Hero Member
  • *****
  • Posts: 2827
    • Home
Copy i18n to build folder
« 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.
« Last Edit: March 28, 2018, 07:15:38 pm by lainz »

Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Copy i18n to build folder
« Reply #1 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)"

lainz

  • Hero Member
  • *****
  • Posts: 2827
    • Home
Re: Copy i18n to build folder
« Reply #2 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.

Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Copy i18n to build folder
« Reply #3 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 ($).



lainz

  • Hero Member
  • *****
  • Posts: 2827
    • Home
Re: Copy i18n to build folder
« Reply #4 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.

Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Copy i18n to build folder
« Reply #5 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.

lainz

  • Hero Member
  • *****
  • Posts: 2827
    • Home
Re: Copy i18n to build folder
« Reply #6 on: March 28, 2018, 08:15:48 pm »
That's ok. I will try that.

Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Copy i18n to build folder
« Reply #7 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/

wp

  • Hero Member
  • *****
  • Posts: 4903
Re: Copy i18n to build folder
« Reply #8 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.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Copy i18n to build folder
« Reply #9 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).

lainz

  • Hero Member
  • *****
  • Posts: 2827
    • Home
Re: Copy i18n to build folder
« Reply #10 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.

Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Copy i18n to build folder
« Reply #11 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


lainz

  • Hero Member
  • *****
  • Posts: 2827
    • Home
Re: Copy i18n to build folder
« Reply #12 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.

Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Copy i18n to build folder
« Reply #13 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/

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus