About WebTranslateIt.com

WebTranslateIt.com is a web-based translation tool to translate documents and software.

Learn more at WebTranslateIt.com.

Recent posts in the same category

i18next

Posted by Edouard on 22 décembre 2011

i18next is a third-party i18n Javascript library you might find useful for localizing Javascript in your application.

Add the i18next.js after the jquery JavaScript.

<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="i18next-[version].js"></script>

Add your resourcefile under /locales/en-US/translation.json. Translations are stored in a JSON hash compatible with WebTranslateIt’s JSON.

{
    "app": {
        "name": "i18n"
    },
    "creator": {
        "firstname": "Jan",
        "lastname": "Mühlemann"
    }
}

Init and use the module:

$.i18n.init({}, function(t) { // will init i18n with default settings and set language from navigator
    var appName = t('app.name'); // -> i18n
    var creator = t('creator.firstname') + ' ' + t('creator.lastname'); // -> Jan Mühlemann
});