[Pas2js] i18n
Michael Van Canneyt
michael at freepascal.org
Thu Oct 25 16:10:23 CEST 2018
On Tue, 23 Oct 2018, Ulrich, Christian wrote:
> Hi,
>
> Is there actually already an way to translate resourcestrings ?
> How should an translation be done at the moment ?
A resourcestring is a javascript object literal with 2 members.
"org" and "current". I think the names are self-describing :)
When getting a resourcestring value, The rtl will first check the "current"
value, and if it is empty, use the "org" value. The "org" value is created by the
compiler when it creates the compiled unit.
So, to translate, create a javascript file which does the following:
pas["yourunit"].$resourcestrings.YourResourcestring.current = "The Translated Value";
Where
"yourunit" is the name of a unit and YourResourcestring is the name of the resource string.
It should not be too difficult to create a program which extracts all
resourcestrings from a program and creates such a file, which you can then
translate. I will add it to my todo list.
Michael.
More information about the Pas2js
mailing list