Introduction
test-ipv6.com is proving to be a valuable asset to people debugging their connectivity. However, not everyone in the world speaks English; as such, it is desirable to have support for other languages. Early mirrors did do translations, but edited the raw code in a way that's hard to carry forward. Since then, we've externalized nearly all text out of the javascript, to make it easier both for translation, and for mirror operators to stay current.
We are looking for people to help with translations. Operating your own mirror is not a requirement; but it does make testing easier.
Details
There are two categories of text in falling-sky. The core project itself is almost entirely JavaScript; and pages are rendered dynamically. The test-ipv6.com site is nearly all static (FAQs and such) and have a high amount of material inside. Each will take a different approach.
text/text.en-us
The files in the text/ directory are used both by JavaScript as well as some static HTML file generation. Anything relating to testing the user, is in this file. FAQ's are managed seperately (see the HTML section below).
- Check out the falling-sky source tree.
- cd falling-sky
- cd source
- New languages
- Edit build-text.pl. Search for en-us, add new language.
- Copy text/text.en-us to text/text.XX where XX is the new language code.
- Edit/Test Text
- Edit: text/text.XX where XX is the language code
- Test: ./build-text.pl XX where XX is the language code
- Make sure no errors are reported.
- You may see warnings of specific strings not yet translated. These will fall back to using the en-us version.
- Rules for source/text/text.en-us:
- source/text/text.en-us has defaults
- source/text/text.LOCALE has overrides (ie, source/text/text.es)
- New labels will be used any time the meaning changes.
- Labels may be reused when only fixing spelling and grammar.
- svn diff if making improvements; or mail jfesler a zip file with the text.
- If you will be making regular improvements, get svn commit access from jfesler, and use svn commit instead.
Using test/text.en-us
JavaScript:
The $gt(x,y) function call will dynamically look up a message from the text file. If the text is missing for the current language, then the en-us text will be used instead. Example: s = $gt("builtin", "v4is") + " " + this.ipv4.ip;.
HTML (and other templated files):
- [% USE GT %] will load the text strings into the template engine; this should be done once per file, at or near the top.
- [% GT.gt("html","disclaimer") %] will be replaced by the disclaimer in the html section of the text file.
HTML
- source/html/main/ now has all navigation / structure for the main text
- This should have all strings externalized, using [% GT.gt("a","b") %]
- Remaining html files are mostly content. These can simply be duplicated and translated.
- ie, copy faq_6to4.html to faq_6to4.html.es for a Spanish translation
Template Variables
- Template variables when expanding:
- $VARS->{locale}="en-us"; on the first pass, etc.
- Template can also expand static text:
- [% USE GT %] to load the strings into memory, and make them accessible. Use this in any file you use templates, before using the GT functions.
- [% GT.gt("a","b") %] will look up section "a", line "b", and replace the [% .. %] with the text
- Includes will prefer locale specific files.
- [% PROCESS foo.inc %] will prefer foo.inc.LANG, then foo.inc.en-us, then simply foo.inc
- Final output files will be filename.ext.[locale] (example: index.js.en-us + index.jsgz.en-us)