Version 1 (modified by niko, 14 years ago) (diff)


Internationalisation (i18n)

If you look for information on localisation (l10n, how you translate Xinha) take a look at wiki:Documentation/Localisation?.

This page is for xinha-developers and on how the _lc-function works.


Xinha has different contexts for i18n:

  • "HTMLArea": the core of Xinha uses this context.
  • eg. "InsertAnchor?": every plugin has its own context (the name of the plugin)

the _lc-function

HTMLArea._lc('english string');

This is the simplest usage, HTMLArea (core) will be used as context. The function will return the localised string.

HTMLArea._lc('english string', 'PluginName');

Usage within an plugin. Most plugins do have its own _lc function defined, you don't need to pass the context everytime then.

CharCounter.prototype._lc = function(string) {
    return HTMLArea._lc(string, "CharCounter");

var complexity = 'very';
HTMLArea._lc({string: 'this is a $complexity complex sentence', replace:{'complexity': complexity}});

This provides a way to have complex sentences where some parts are variable - and this variable part might be at another position in other languages.

HTMLArea._lc({key: 'button_bold', string: ["ed_buttons_main.gif",3,2]});

It is also possible to translate objects, this is used to internationalize the bold, italic... toolbar-buttons.

The key is used to lookup the string (which is actually an object) in the l10n-file.