Skip to content

fgrandel/meteor-i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meteor Internationalization (i18n) Library

Installation

The package can be installed with Meteorite.

Type inside your application directory:

$ mrt add i18n

Usage

To add messages do:

Meteor.i18nMessages.someNamespace = {
  optionalSubNamespace: {  // You can have as many (sub-)sub-namespaces as you like.
    yourMessage: {
      en: {
        US: 'Your {{message}} in American English', // Use {{}} to mark placeholders.
        GB: 'Your {{message}} in British English'
      },
      de: 'Your {{message}} in German'  // Territory is optional
    },
    anUntranslatedMessage: 'Your untranslated message' // If you don't set a language the same message will be returned for all languages.
  }
};

To set the current locale do:

Meteor.setLocale('en_US');

and to get the current locale do:

Meteor.getLocale(); // en_US

The locale is reactive and also stored in the localStorage (_TranslatorService.locale) on the client in order to resist a page reload.

To translate a message from within your code simply call:

// A message with placeholder
var translatedMessage = __('someNamespace.optionalSubNamespace.yourMessage', {message: 'some placeholder content'});

// A message without placeholder
var anotherMessage = __('someNamespace.optionalSubNamespace.anUntranslatedMessage');

Questions and Feature Requests

If you have feature requests or other feedback please write to jerico.dev@gmail.com.

Contributions

Contributions are welcome! Just make a pull request and I'll definitely check it out.

Thanks to @joernroeder, @mcevskb and @beshur for their contributions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •