Skip to content
tinganho edited this page Oct 9, 2014 · 2 revisions

Install l10ns npm install l10ns -g

Create a new project folder test and initialize a new translation project. The initialization guide will guide you through creating a project.

$ mkdir test
$ cd test
$ l10ns init

Now, create a source file test.js with (at least) the following code:

var firstnameLabel = l('FIRSTNAME')
  , lastnameLabel = l('LASTNAME')
  // Pass in variables
  , age = 7
  , yourAgeIsLabel = l('YOUR_AGE_IS', { age : age });
  // Pass in multiple variables
  , cats = 2
  , dogs = 3
  , catsAndDogsLabel = l('YOU_HAVE_NUMBER_OF_CATS_AND_DOGS', { cats : cats, dogs : dogs});

Now, lets update translation keys from source:

$ l10ns update

Lets check which translation keys have been added:

$ l10ns log
@1 FIRSTNAME | NO TRANSLATION
@2 LASTNAME | NO TRANSLATION
@3 YOUR_AGE | NO TRANSLATION
@4 YOU_HAVE_NUMBER_OF_CATS_AND_DOGS | NO TRANSLATION

Edit the last translation using log reference:

$ l10ns set @1 "Firstname" # using default langague
$ l10ns set @1 --locale=zh "名" # using chinese

Translation are now saved to a localization file. To compile to your source programming language:

$ l10ns compile

Lets set up a web interface for translator to use:

$ l10ns interface
Clone this wiki locally