Skip to content

Instantly share code, notes, and snippets.

@kostia
Forked from ryaz/API.md
Last active August 29, 2015 13:57
Show Gist options
  • Save kostia/9530579 to your computer and use it in GitHub Desktop.
Save kostia/9530579 to your computer and use it in GitHub Desktop.

API

$.li18n.currentLocale = 'xxx';
Set the current locale.

Default is "en".


$.li18n.translations = {en: {spam: 'eggs'}};
Set the translations.

Default is {}.


$.li18n.translate(key, interpolationOptions);
Translate the given key using interpolation options.

Params:

  • key - translation lookup key (String).
  • interpolationOptions - options for translations with interpolation (Object).

Returns:

  • translation if found (String) (by default).
  • error message (String) if translation not found and $.li18n.onTranslationMissing is set to 'message'.
  • value from $.li18n.onTranslationMissing if translation not found and $.li18n.onTranslationMissing is set to a function.
  • throws an error if translation is not found and $.li18n.onTranslationMissing is not set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment