i18(i18n)

To add i18 support for your app you need to define what text you would like to translate. The best way to define your text is to store it in external json file.

For example:

Each language you should have own json file!

Next you need to add html indicators in all place you want to use i18.

<div id="i18_links">

<span data-i18n="nav.dashboard"> </span>

<span data-i18n="nav.graphs"> </span>

<span data-i18n="nav.mailbox"> </span>

</div>

Next you need to initialise the i18next plugin:


$.i18n.init(

resGetPath: 'locales/__lng__.json',

load: 'unspecific',

fallbackLng: false,

lng: 'en'

}, function (t)

$('.i18_links').i18n();

});

i18

i18 After that if you want to change the language you just need to add buttons and fire the i18n.setLng() function.

More info about specific function and configuration options you can find on official i18next documentation.

转载请说明出处 内容投诉内容投诉
九幽软件 » i18(i18n)