Internationalisation of BXE User Interface
Christian Stocker <[email protected]> Thu, 16 Dec 2004 11:27:25 +0100
| Newsgroups | gmane.editors.bitflux.devel,gmane.editors.bitflux.general |
|---|---|
| Message-ID | <[email protected]> |
Hi (I'm CC'ing [email protected], as they might be interested in that as wel= l) I had a request (or more in the last months) for making BXE=20 multi-langual. There's nothing, which stands against doing it, except my=20 precious time ;) But here are my thoughts: We use XML documents for defining the "strings". As we use the cocoon=20 i18n format already in our CMS, it makes a lot of sense to us, to use=20 that XML format. Here's an example (and more info about cocoon's i18n=20 implementation): http://cocoon.apache.org/2.1/userdocs/transformers/i18n-transformer.html#= Catalogues+%28Dictionaries%29 What we have to do now, is to provide a class to BXE, which does the=20 translation. The best thing would be to do that BXE independent, so one=20 can use that JS class for other things than only in BXE. Here's a prototype (it's full of coding mistakes, but you should get the=20 idea): *** function i18n (catalogLocation, locale) { =09 this.catalog =3D document.load(catalogLocation + "_" + locale + ".xml"); } i18n.prototype.getText =3D function (key) { result =3D this.catalog.query('/catalogue/message[@key =3D "'.key.'"]'= ); if(result && result->length > 0) { return result->item(0)->nodeValue; } return key; } *** And in the actual code, we will simply do then: var i18nObj =3D new i18n("/xml/catalog","en"); text =3D i18nObj.getText("some text here"); (of course, we need some kind of singleton, so we don't load the xml=20 document again and again, but you get the idea) One problem with the whole i18n stuff is the order of words, eg. in=20 English it's "Add Element" in German "Element hinzuf=FCgen" and Element i= s=20 usually variable, therefore we need some variable substitution... In cocoon, it's solved the following way: the key would be "Add {0}" and you can provide further arguments. In=20 this case, getText would take a second parameter (an array) for variable=20 substitution.. text =3D i18nObj.getText("Add {0}", array("Elementname")); and this would return "Add Elementname" in english, but "Elementname=20 hinzuf=FCgen" in German. Does this make sense? Additionally, we could also add a transformer, which translates whole=20 XML documents with the i18n syntax of cocoon. Not sure, if we really=20 need that in BXE right now, but that should be doable as well. Any other ideas? Or should I go ahead with that approach? chregu --=20 christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | [email protected] | gnupg-keyid 0x5CE1DECB --=20 bx-editor-dev mailing list [email protected] http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-dev