# Introduction Source can be loaded via [npm](https://www.npmjs.com/package/jquery-i18next), bower or [downloaded](https://github.com/i18next/jquery-i18next/blob/master/jquery-i18next.min.js) from this repo. -------------- **NEWS: localization as a service - locize.com** Needing a translation management? Want to edit your translations with an InContext Editor? Use the orginal provided to you by the maintainers of i18next!  With using [locize](http://locize.com/) you directly support the future of i18next and react-i18next. -------------- If you don't use a module loader it will be added to window.jqueryI18next ``` # npm package $ npm install jquery-i18next # bower $ bower install jquery-i18next ``` Simplifies i18next usage in projects built based on jquery, like: page source: ```html
``` loaded resource file (locales/en/translation.json): ```json { "nav": { "home": "Home", "page1": "Page One", "page2": "Page Two" } } ``` javascript code: ```js $(".nav").localize(); // results in // ``` ## Initialize the plugin ```js jqueryI18next.init(i18nextInstance, $, { tName: 't', // --> appends $.t = i18next.t i18nName: 'i18n', // --> appends $.i18n = i18next handleName: 'localize', // --> appends $(selector).localize(opts); selectorAttr: 'data-i18n', // selector for translating elements targetAttr: 'i18n-target', // data-() attribute to grab target element to translate (if diffrent then itself) optionsAttr: 'i18n-options', // data-() attribute that contains options, will load/set if useOptionsAttr = true useOptionsAttr: false, // see optionsAttr parseDefaultValueFromContent: true // parses default values from content ele.val or ele.text }); ``` ## using options in translation function ```js $("#btn1").localize(options); ``` or ```js $("#btn1").localize(); ``` `data-i18n-options` attribute must be a valid JSON object. ## usage of selector function ### translate an element ```js $("#btn1").localize(options); ``` myKey: same key as used in i18next (optionally with namespaces) options: same options as supported in i18next.t ### translate children of an element ```js $(".nav").localize(); ``` ### translate some inner element ```js