{"_id":"@callumdenby/i18next-locize-backend","_rev":"1-4d5dc106b87e2ebe58ad0943deb5c280","name":"@callumdenby/i18next-locize-backend","dist-tags":{"latest":"1.9.0"},"versions":{"1.9.0":{"name":"@callumdenby/i18next-locize-backend","version":"1.9.0","description":"backend layer for i18next using locize service ","main":"dist/commonjs/index.js","jsnext:main":"dist/es/index.js","module":"dist/es/index.js","types":"index.d.ts","keywords":["i18next","i18next-backend","locize"],"homepage":"https://github.com/locize/i18next-locize-backend","bugs":{"url":"https://github.com/locize/i18next-locize-backend/issues"},"repository":{"type":"git","url":"git://github.com/locize/i18next-locize-backend.git"},"dependencies":{},"devDependencies":{"babel-cli":"6.18.0","babel-core":"6.18.2","babel-eslint":"7.1.1","babel-preset-es2015":"6.18.0","babel-preset-stage-0":"6.16.0","babelify":"7.3.0","browserify":"13.1.1","browserify-istanbul":"2.0.0","chai":"3.5.0","coveralls":"2.11.15","eslint":"3.10.2","eslint-config-airbnb":"13.0.0","i18next":"4.1.0","isparta":"4.0.0","istanbul":"github:gotwarlost/istanbul#source-map","karma":"1.3.0","karma-browserify":"5.1.0","karma-chai":"0.1.0","karma-chrome-launcher":"2.0.0","karma-cli":"1.0.1","karma-coverage":"github:douglasduteil/karma-coverage#next","karma-coveralls":"1.1.2","karma-expect":"1.1.3","karma-mocha":"1.3.0","karma-phantomjs-launcher":"1.0.2","karma-rollup-preprocessor":"2.0.2","karma-sinon":"1.0.5","karma-spec-reporter":"0.0.26","mkdirp":"0.5.1","mocha":"3.1.2","phantomjs-prebuilt":"2.1.13","rimraf":"2.5.4","rollup":"0.36.3","rollup-plugin-babel":"2.6.1","rollup-plugin-node-resolve":"2.0.0","rollup-plugin-uglify":"1.0.1","sinon":"1.17.6","yargs":"6.4.0"},"scripts":{"test":"karma start karma.conf.js --singleRun","tdd":"karma start karma.conf.js","clean":"rimraf dist && mkdirp dist","copy":"cp ./dist/umd/i18nextLocizeBackend.min.js ./i18nextLocizeBackend.min.js && cp ./dist/umd/i18nextLocizeBackend.js ./i18nextLocizeBackend.js","build:es":"BABEL_ENV=jsnext babel src --out-dir dist/es","build:cjs":"babel src --out-dir dist/commonjs","build:umd":"rollup -c rollup.config.js --format umd && rollup -c rollup.config.js --format umd --uglify","build:amd":"rollup -c rollup.config.js --format amd && rollup -c rollup.config.js --format umd --uglify","build:iife":"rollup -c rollup.config.js --format iife && rollup -c rollup.config.js --format iife --uglify","build":"npm run clean && npm run build:cjs && npm run build:es && npm run build:umd && npm run copy","preversion":"npm run test && npm run build && git push","postversion":"git push && git push --tags"},"author":{"name":"Jan Mühlemann","email":"jan.muehlemann@gmail.com","url":"https://github.com/jamuhl"},"license":"MIT","gitHead":"f3872ab4f63d9737df500b4f521a494d991537c7","_id":"@callumdenby/i18next-locize-backend@1.9.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"callumdenby","email":"me@callumdenby.com"},"dist":{"integrity":"sha512-EbRtChVcAvHyY0epMGTgEq0PQTJd7G4X/UFEjdGQ96qdpJbd2BSs4JsD+SuokIYXRhlYDwAnRlmaYE0JTBqNMA==","shasum":"90940e067688b6650db5a1c8fce7d0c4249364c5","tarball":"https://registry.npmjs.org/@callumdenby/i18next-locize-backend/-/i18next-locize-backend-1.9.0.tgz","fileCount":16,"unpackedSize":84631,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJctGctCRA9TVsSAnZWagAAeCoQAJTiCvheB3IHEfCvaizk\nJvoKLlirFylg/d5uh316vEsjTBrGJtzxprQKcFsKEocXkTJ3l2Km2JfVOD2f\ndOHlVXu1B/aiTu8dfHrcMcMDJGo6rV/NUodrTtxanTkuG5zK+3Hlk4SDU7sJ\nQ+hLoLH0gxR8R+CVMwdj9qUMSlvL04h/vznaQ5krheVmHiJW7naPZWWclgG9\nr1B38TgXgPrxtwvJd6BsevQpz5kl9lW8UEdOwufeIWQhNgrQHv5wUW5A3WKp\n7NkAXW3028l1EAhibxZhiDP+egj8NwcDTvev5dhGrUxmNLxpbV5az/OUwDAM\n2dRCPZcRjyFdkHbvuUCdMabwaoFAD2Uwv3DW0uhpxUFx5h2ZSHoOoFPD31NZ\n25i+N18PfqJCSE3t9n16uHK8TgacARBCUIvK9q/Wo62s2CaXsmfrWLpth1B9\nFNag/zwz+paEu9We5tWhe+p26ZkH8pqroJGR//4DC2f9p+d/TQtQNkPj7nFP\nqOMT+oBViBowLSj0ZRAVjG+ZD1ANCM/+GSGlLzWqyC0ajme4Dhc9ae+NhEPX\n19l/YJ8zbIAxh6sHqRHBL+vmPLPOB5An4S6xVOil/YnfB8lYMvElQTTZOgAU\ns2kaaf2juVfGjtxTtqtCozUOeCEw0oKyqu9VXKTV4RQUKBTDd1Xy8We6HolU\nRBIf\r\n=Fe/N\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCWqrU/djWWle520lshvnqUKyNBnN2SAu0ohYpE3EPWpwIhANxNQfkLYOJQHfULV/27/jQGdJ7SYr91uznDIy7AbBHf"}]},"maintainers":[{"name":"callumdenby","email":"me@callumdenby.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/i18next-locize-backend_1.9.0_1555326764897_0.16447347456999162"},"_hasShrinkwrap":false}},"time":{"created":"2019-04-15T11:12:44.709Z","1.9.0":"2019-04-15T11:12:45.043Z","modified":"2022-04-04T21:33:17.599Z"},"maintainers":[{"name":"callumdenby","email":"me@callumdenby.com"}],"description":"backend layer for i18next using locize service ","homepage":"https://github.com/locize/i18next-locize-backend","keywords":["i18next","i18next-backend","locize"],"repository":{"type":"git","url":"git://github.com/locize/i18next-locize-backend.git"},"author":{"name":"Jan Mühlemann","email":"jan.muehlemann@gmail.com","url":"https://github.com/jamuhl"},"bugs":{"url":"https://github.com/locize/i18next-locize-backend/issues"},"license":"MIT","readme":"[![Travis](https://img.shields.io/travis/locize/i18next-locize-backend/master.svg?style=flat-square)](https://travis-ci.org/locize/i18next-locize-backend)\n[![npm version](https://img.shields.io/npm/v/i18next-locize-backend.svg?style=flat-square)](https://www.npmjs.com/package/i18next-locize-backend)\n[![Bower](https://img.shields.io/bower/v/i18next-locize-backend.svg)]()\n[![David](https://img.shields.io/david/locize/i18next-locize-backend.svg?style=flat-square)](https://david-dm.org/locize/i18next-locize-backend)\n\nThis is an i18next backend to be used for [locize](http://locize.com) service. It will load resources from locize server using xhr.\n\nIt will allow you to save missing keys containing both **default value** and **context information** by calling:\n\n```js\ni18next.t(key, defaultValue, tDescription);\ni18next.t(key, { defaultValue, tDescription });\n```\n\n# Getting started\n\nSource can be loaded via [npm](https://www.npmjs.com/package/i18next-locize-backend), bower or [downloaded](https://cdn.rawgit.com/locize/i18next-locize-backend/master/i18next-locize-backend.min.js) from this repo.\n\n```\n# npm package\n$ npm install i18next-locize-backend\n\n# bower\n$ bower install i18next-locize-backend\n```\n\nWiring up:\n\n```js\nimport i18next from \"i18next\";\nimport Locize from \"i18next-locize-backend\";\n\ni18next.use(Locize).init(i18nextOptions);\n```\n\n- As with all modules you can either pass the constructor function (class) to the i18next.use or a concrete instance.\n- If you don't use a module loader it will be added to `window.i18nextLocizeBackend`\n\n## Backend Options\n\n**IMPORTANT** make sure you do not add your apiKey in the production build to avoid misuse by strangers\n\n```js\n{\n  // the id of your locize project\n  projectId: '[PROJECTID]',\n\n  // add an api key if you want to send missing keys\n  apiKey: '[APIKEY]',\n\n  // the reference language of your project\n  referenceLng: '[LNG]',\n\n  // version - defaults to latest\n  version: '[VERSION]',\n\n  // private - set to true if you version on locize is set to use private publish\n  private: false,\n\n  // hostnames that are allowed to create, update keys\n  // please keep those to your local system, staging, test servers (not production)\n  allowedAddOrUpdateHosts: ['localhost']\n}\n```\n\nTo load translations only `projectId` needs to be filled. To use the **saveMissing** feature of i18next additional to the projectId both `apiKey` and `referenceLng` have to be set.\n\nOptions can be passed in:\n\n**preferred** - by setting options.backend in i18next.init:\n\n```js\nimport i18next from \"i18next\";\nimport Locize from \"i18next-locize-backend\";\n\ni18next.use(Locize).init({\n  backend: options\n});\n```\n\non construction:\n\n```js\nimport Locize from \"i18next-locize-backend\";\nconst locize = new Locize(options);\n```\n\nvia calling init:\n\n```js\nimport Locize from \"i18next-locize-backend\";\nconst locize = new Locize();\nlocize.init(options);\n```\n\n## Additional API endpoints\n\n### backend.getLanguages\n\nWill return a list of all languages in your project including percentage of translations done per version.\n\n```js\nimport Locize from \"i18next-locize-backend\";\nconst locize = new Locize(options);\n\nlocize.getLanguages((err, data) => {\n  /*\n  data is:\n\n  {\n    \"en\": {\n      \"name\": \"English\",\n      \"nativeName\": \"English\",\n      \"isReferenceLanguage\": true,\n      \"translated\": {\n        \"latest\": 1\n      }\n    },\n    \"de\": {\n      \"name\": \"German\",\n      \"nativeName\": \"Deutsch\",\n      \"isReferenceLanguage\": false,\n      \"translated\": {\n        \"latest\": 0.9\n      }\n    }\n  }\n  */\n});\n\n// or\ni18next.services.backendConnector.backend.getLanguages(callback);\n```\n\n### backend.getOptions\n\nWill return an object containing useful informations for the i18next init options.\n\n```js\nimport Locize from \"i18next-locize-backend\";\nconst locize = new Locize(options);\n\nlocize.getOptions((err, data) => {\n  /*\n  data is:\n\n  {\n    fallbackLng: 'en',\n    referenceLng: 'en',\n    whitelist: ['en', 'de'],\n    load: 'languageOnly|all' // depending on your whitelist has locals having region like en-US\n  }\n  */\n});\n\n// or\ni18next.services.backendConnector.backend.getOptions(callback);\n```\n\nYou can set a threshold for languages to be added to whitelist by setting whitelistThreshold in backend options (eg: 1 = 100% translated, 0.9 = 90% translated).\n\n## SPECIAL - let the backend determine some options to improve loading\n\nYou can load some information from the backend to eg. set whitelist for i18next just supporting languages you got in your locize project.\n\nYou will get i18next options for (same as above backend.getOptions):\n\n- fallbackLng\n- whitelist\n- load\n\n```js\nimport i18next from \"i18next\";\nimport Locize from \"i18next-locize-backend\";\n\nconst locize = new Locize(\n  {\n    projectId: \"[PROJECTID]\",\n    apiKey: \"[APIKEY]\",\n    version: \"[VERSION]\"\n    // referenceLng -> not needed as will be loaded from API\n  },\n  (err, opts) => {\n    i18next.use(locize).init({ ...opts, ...yourOptions }); // yourOptions should not include backendOptions!\n  }\n);\n```\n","readmeFilename":"README.md"}