Skip to content

a feature rich internationalization (i18n) package for meteor with usage of the Unicode Common Locale Data Repository

License

Notifications You must be signed in to change notification settings

Nemo64/meteor-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

translator - powerful internationalization

An i18n utility belt specifically designed for meteor to seperate your app from the language.

read the full documentation in the wiki or see the quickstart!

Features

  • readable yaml files or normal json files to store the language ~docs
  • namespacing though multiple files ~docs (this will me be removed in future version to enable other features (like overwriting) and make the package easier to use)
  • variables in the translations hello {username} ~docs
  • icu messageformat using Unicode cldr ~docs
  • date formating using moment and cldr released on {var, date} ~docs
  • localized number formating again using cldr {var, number} ~docs
  • language fallbacks ["en_GB","en_US"]
  • lazy loading of languages as soon as they are needed
  • automatic language detection using the accept-language header (experimental)
  • reactive changing of the translations
  • a small footprint of 10 kb uglified and even less with gzip

Quickstart

Translation file

#languages/user.en_US.lang.yml
user_area:
  header: "user area"
  message:
    greeting: "Hello {name}!"

JavaScript

Translator.setDefaultLanguage(['en_US']); // autodetect fallback
FrontLang = new Translator(); // translator for frontend
FrontLang.use('languages/user'); // without the "en_US.lang.yml"

FrontLang.get('user_area.header'); // => user area
FrontLang.get('user_area.message.greeting', { name: "world" }); // => Hello world!

Template

// this JavaScript is required to ensure capsulation
Template.template_name.trans = FrontLang.createHelper();
<template name="template_name">
    <h1>{{trans "user_area"}}</h1>
    <p>{{trans "user_area.message.greeting" name="world"}}</p>
</template>

TODO

  • Territory fallback like "i want British English but there is only American English"! This is useful for the auto detection of languages! I need help with this because I don't know if that'll work with most languages!
  • Providing more features from CLDR

About

a feature rich internationalization (i18n) package for meteor with usage of the Unicode Common Locale Data Repository

Resources

License

Stars

Watchers

Forks

Packages

No packages published