A comprehensive internationalization solution for Meteor

Internationalization for Meteor

tap-i18n is a Meteor package that provides a comprehensive i18n solution for Meteor apps and packages, with the goal of standardizing the way package developers internationalize their packages.

Watch a talk about tap:i18n & tap:i18n-db

Get involved in tap:i18n:

Developed by Professional Meteor Services

for Leading Conference Technology.

Related Packages:

Check tap:i18n-db for Meteor collections internationalization.

Check tap:i18n-ui for bootstrap based UI components for tap:i18n.

Check tap:i18n-bundler for Cordova & static file deployments.

Users of tap-i18n v0.9 and below, read tap:i18n v1.0 New Features & Backward Compatibility and update your app to v1.0 .

Contents

Key Features

All Encompassing

tap-i18n is designed in a way that distinguishes the role of the package developer, that is, making the package available in multiple languages, from the role of the app developer which is to translate the app, but more importantly, to manage the app's internationalization aspects, such as: setting the supported languages for the project, setting the client language, configuring CDNs for language files, and so on.

Readable Syntax

< div class = " btn " > {{ _ " sign_up " }} </ div >

Advanced i18n

tap-i18n uses i18next v1.11 as its internationalization engine and exposes all its capabilities to the Meteor's templates - variables, dialects, count/context aware keys, and more.

client/messages.html

< template name = " messages_today " > < p > {{ _ " inbox_status " " Daniel " count = 18 }} </ p > </ template >

i18n/en.i18n.json

{ " inbox_status " : " Hey, %s! You have received one new message today. " , " inbox_status_plural " : " Hey, %s! You have received %s new messages today. " }

See more examples below.

Transparent Namespacing

You don't need to worry about domain prefixing or package conflicts when you translate your project or package. Behind the scenes we automatically generate scoped namespaces for you.

Ready to Scale

Translations are unified into a single JSON file per language that includes both package and project-level translations

On-demand: translations are loaded only when they are needed

3rd Party CDN Support

Quickstart

Step 1: Install tap-i18n using meteor:

$ meteor add tap:i18n

Step 2: Add translation helpers to your markup:

*.html

< div > {{ _ " hello " }} </ div >

Step 3: Define translations in JSON or YAML format:

i18n/en.i18n.json

{ " hello " : " Hey there " }

i18n/fr.i18n.json

{ " hello " : " Bonjour " }

i18n/es.i18n.yml

hello : Hola

Translations files should end with lang_tag.i18n.json/yml.

You can split translations of a certain language to multiple files, we ignore the prefixed text, e.g., we add the translations of menu.en.i18n.json in the same way we add those of en.i18n.json .

You can put languages files anywhere in your project tree, as long as they are common to both your server and client - do not put languages files under /client, /server or /public.

Note: Languages files have to be saved in utf-8 encoding.

Step 4: Initiate the client language on startup (optional)

If you want the client to be served by a specific language on startup

Assuming that you have a function getUserLanguage() that returns the language for tag for the current user.

getUserLanguage = function () { // Put here the logic for determining the user language return " fr " ; }; if ( Meteor . isClient ) { Meteor . startup ( function () { Session . set ( " showLoadingIndicator " , true ); TAPi18n . setLanguage ( getUserLanguage ()) . done ( function () { Session . set ( " showLoadingIndicator " , false ); }) . fail ( function ( error_message ) { // Handle the situation console