Internationalization is currently lacking from Zest.
We could really do with adding it, and ideally in a way that is backwards compatible.
My proposal is that we add a new property to Zest scripts, something like i18n=true/false (in json of course;)
If i18n is true then all strings output by the script (eg via ZestActionPrint or ZestActionFail should be i18n tags rather than readable text, as should things like the script name and description.
To get the translated text you'll need to pass one or more property files with the translations into the Zest runner.
If you try to run an i18n script without providing the translations you should at the very least get a warning, possibly a hard failure.
An option to print out all of the i18n tags would be very useful ;)
So a very simple script could look like:
{
"about": "This is a Zest script. For more details about Zest visit https://developer.mozilla.org/en-US/docs/Zest",
"zestVersion": "0.3",
"title": "script.title",
"description": "script.desc",
"prefix": "",
"type": "Standalone",
"i18n": true,
"parameters": {
"tokenStart": "{{",
"tokenEnd": "}}",
"tokens": {},
"elementType": "ZestVariables"
},
"statements": [
{
"message": "script.msg",
"priority": "HIGH",
"index": 1,
"enabled": true,
"elementType": "ZestActionFail"
}
],
"authentication": [],
"index": 0,
"enabled": true,
"elementType": "ZestScript"
}
With the English (American;) language file:
script.title = Always fails - High
script.desc = Always fails with a HIGH alert
script.msg = This is an example failure message
So running this with a file containing the above translations will result in the failure "
This is an example failure message" being printed.
All Zest runners would need to support basic property files containing the translated messages.
They can optionally support suitable translation bundles, so the Java runner would support Java ResourceBundles
You could then invoke a script using something like:
zest.sh -script myscript.zst -i18n messages.jar -lang en_GB
An alternative approach would be to include the translations in the Zest JSON, but I think that would be much harder to translate and maintain.
What do people think?
Simon