Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PO files folder #123

Open
rchastain opened this issue Jan 2, 2023 · 5 comments
Open

PO files folder #123

rchastain opened this issue Jan 2, 2023 · 5 comments

Comments

@rchastain
Copy link

I have just added PO files to an application of mine. It was very easy, and it works fine.

Is it possible to put the PO files in a dedicated directory, or is it mandatory to let them in the directory of the application?

@rchastain
Copy link
Author

rchastain commented Feb 12, 2023

The procedure which loads PO files seems to be this one:

// src/corelib/fpg_translations.pas
procedure TranslateResourceStrings(const BaseAppName, BaseDirectory, CustomLang: string);

It is called here:

// corelib/fpg_main.pas
TranslateResourceStrings(ApplicationName, ExtractFilePath(ParamStr(0)), '');

So I imagine that we could do something like this:

TranslateResourceStrings(ApplicationName, ExtractFilePath(ParamStr(0)){$IFDEF USE_LANGUAGES_FOLDER} + 'languages'{$ENDIF}, '');

@graemeg
Copy link
Owner

graemeg commented Feb 20, 2023

That's a good point. It probably wasn't a wise choice to place them in the same directory as the application executable. Your suggestion of a languages sub-directory will definitely work.

Let me just research a few options and I'll come back to you. For example

  • Store them system wide. For example, what FreeBSD does /usr/local/share/locale/<language>/LC_MESSAGES/<appname>.po. Linux probably does something similar.
    • The down side being that you need root access now, to install you app :-(
  • Keep things "self contained" in one directory. Much like we currently have (and what Windows + MacOS does).
    • This means you can install it anywhere the user has write access.
    • Make better use of sub-directories
  • Maybe also introduce a command line parameter, to override at runtime, the location
    • Maybe this will just over-complicate matters, and probably something that will never be used

@rchastain
Copy link
Author

Hello Graeme.

Other (not very important) question related to PO files. With LCL applications, you can force the language with --lang=en (for example). Is there a way to do that with fpGUI applications?

@graemeg
Copy link
Owner

graemeg commented Jun 3, 2023

Crap, I never got back to this thread - my bad. I'll make sure I commit options 2 & 3 from my last message.

As for your latest question... From memory, we don't have a '--lang' command line parameter in fpGUI, but you could do the same on Linux/FreeBSD as follows:

env LANG=af_ZA.UTF8 ./fontselect

This will apply the language override, just for that one command (in this example the command is to run the ./fontselect application).

By default, fpGUI looks at the LANG environment variable (I can't remember if that is true for Windows as well), and in Windows, it also looks at the Windows Registry for the current user.

@rchastain
Copy link
Author

Thank you Graeme. Indeed, it works.

For the other question, the option 2 would be perfect for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants