[Pas2js] Translating using resource strings
Michael Van Canneyt
michael at freepascal.org
Mon Jul 15 15:05:19 CEST 2019
Hello,
I've added a unit that presents you with an API to translate the resource
strings in your program.
The unit is called rstranslate. You can
1. Load a translation for a single resource string.
2. Load an object with a list of units/strings that must be translated in a simple format.
3. Specify an URL of a file which contains the translations.
The file will be loaded, the object parsed and used to translate using mechanism 2.
Since this is an async operation, there is a callback to notify you when the translation is done.
4. Reset the resource strings to their original values for one string or all strings of a unit.
For each of the cases there is a demo in the folder demo/translate.
You can click the translate button twice : every even click will reset the
translation, allowing you to switch between 2 languages.
The implementation is just a sample which should cover most use cases.
You can perfectly create your own alternative mechanism, of course.
Still planned is to let the compiler generate a file (in the same format as
used by this API) with the default values of the strings as found in the
program source file(s).
Michael.
More information about the Pas2js
mailing list