{"_id":"@cheshirecat/i18nt","_rev":"8-a977116d7894a97233298c966209bab3","name":"@cheshirecat/i18nt","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.2":{"name":"@cheshirecat/i18nt","version":"1.0.2","keywords":["i18n","internationalization","plugin","js","javascript","typescript","vue","react","svelte"],"author":{"name":"cheshirecat","email":"ca.leduc@me.com"},"license":"ISC","_id":"@cheshirecat/i18nt@1.0.2","maintainers":[{"name":"cheshirecat","email":"ca.leduc@me.com"}],"homepage":"https://github.com/zecheshirecat/i18nt#readme","bugs":{"url":"https://github.com/zecheshirecat/i18nt/issues"},"dist":{"shasum":"b122afdf07eea9c5f7f85f900f81e39248455fa6","tarball":"https://registry.npmjs.org/@cheshirecat/i18nt/-/i18nt-1.0.2.tgz","fileCount":7,"integrity":"sha512-8j9A0Ax3Rbsd4JSBdE1wFeuS6uvuSzrzkD3QkDVAwsm01tPO4jx+4Mf9G4fqh5Q8F8rcLVNizfBs9j7EQLlGig==","signatures":[{"sig":"MEUCIAFJG1Bd5X4sC1qOkwRkJKo1a7f5TJvV7/hpSB2uaKZ2AiEA7SfEib84YkIcckx5iukkIbakHS+uCWTTKsVYpFf09Xw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10921,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiBhQvCRA9TVsSAnZWagAAdrkP/3+WxNSC8lHrCOBRVjJC\n7f8uGmhtT9k0Xn8l3BgrxOYeASOuSI8gSwSIJrfsSL7YTEH262cq9L+zaY3j\nPPG++07UN2RW8UZIou0KfeJS3EH3EdQKx/IXNJMu8nEI8xaN82DZCTVSKUgR\n3VMVvxwFUu9GF8H+2dHc4RpROH9lTF4uRrJKOmwI6Qjr9drXSizdomTY19WH\njERk4zbIlJ8C2t7gjfKAhKNTblW/n33vknVIQk4WPPrctKQWkh+UbMLx/1MX\nX+mxfsrqo0+ivlpNuwHnXLXpLVFERZyfZDfpAvGw2osoZkWVBCXXS/cZAv27\n764IhM5aejItMTNy/6Int110MKjtPiGmni2de17malI7QrnVipOXq0geFIcQ\n3IQlBpCAH4M7iU/sJEGX9e4u/p7o99CBzF6JDaCNBO8zHhay6hqNBOPgkHcQ\nRs1wDLWCdz0OMlTym+6WDsBJ0dTV6kV0lgSiPurr7f11ACSRsFJftxYj022O\n15R5e/IwvoPdGvyFU6JI2ipVnF05UVyoA70Tjk+5KBsK0eIDKipxBcZAcN1/\nQuXgdI+Ok85y6t9X62oMfE+ZHFUS7p5uDp4zodDe+FtztWLA2eaWDeIMjrij\nQvmJ8DxWhO70gK/+v39QnG9KEb+r7rObeVLy8VR0F010PRsYEHFSDjJ2aRrV\na7vp\r\n=+t1E\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"3395b07db8894efece0d6d3447319332e5b3ea64","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"_npmUser":{"name":"cheshirecat","email":"ca.leduc@me.com"},"repository":{"url":"git+https://github.com/zecheshirecat/i18nt.git","type":"git"},"_npmVersion":"8.1.2","description":"A lightweight internationalization module with TypeScript support","directories":{},"_nodeVersion":"16.13.2","_hasShrinkwrap":false,"devDependencies":{"typescript":"^4.5.5"},"_npmOperationalInternal":{"tmp":"tmp/i18nt_1.0.2_1644565551071_0.9097425958647645","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.0.3":{"name":"@cheshirecat/i18nt","version":"1.0.3","keywords":["i18n","internationalization","plugin","js","javascript","typescript","vue","react","svelte"],"author":{"name":"cheshirecat","email":"ca.leduc@me.com"},"license":"ISC","_id":"@cheshirecat/i18nt@1.0.3","maintainers":[{"name":"cheshirecat","email":"ca.leduc@me.com"}],"homepage":"https://github.com/zecheshirecat/i18nt#readme","bugs":{"url":"https://github.com/zecheshirecat/i18nt/issues"},"dist":{"shasum":"58223ccfe30a94193e86f826a94f859320b9d173","tarball":"https://registry.npmjs.org/@cheshirecat/i18nt/-/i18nt-1.0.3.tgz","fileCount":7,"integrity":"sha512-q1foTBIYHM1xgQPIAMY0vxrn5Jboc+5sLCynn33rTN2pifV61IsLmP1tRw7yLhdCsp/FWN494Ay9Ma4mtIseLA==","signatures":[{"sig":"MEUCIQDR74ceLMdb62rkubqPLMl0hXKUKVqqZXAE0NI8jGin1gIgV1wLz8WzZvUMChIxD/b7j6BO2Rxf9vUF3zp33Rwb/yA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11255},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"ff6490f29f4b430842ff4ff66e7b90c1f3b10e2f","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"_npmUser":{"name":"cheshirecat","email":"ca.leduc@me.com"},"repository":{"url":"git+https://github.com/zecheshirecat/i18nt.git","type":"git"},"_npmVersion":"9.5.1","description":"A lightweight internationalization module with TypeScript support","directories":{},"_nodeVersion":"18.16.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.2.2"},"_npmOperationalInternal":{"tmp":"tmp/i18nt_1.0.3_1698061388057_0.42219583153203644","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"2.0.0":{"name":"@cheshirecat/i18nt","version":"2.0.0","keywords":["i18n","internationalization","plugin","js","javascript","typescript","vue","react","svelte"],"author":{"name":"lecheshirecat","email":"contact@pixeliste.fr"},"license":"ISC","_id":"@cheshirecat/i18nt@2.0.0","maintainers":[{"name":"cheshirecat","email":"ca.leduc@me.com"}],"homepage":"https://github.com/lecheshirecat/i18nt#readme","bugs":{"url":"https://github.com/lecheshirecat/i18nt/issues"},"dist":{"shasum":"05b64c81e4cc2c8e11e36dd3105bde02a74e9c51","tarball":"https://registry.npmjs.org/@cheshirecat/i18nt/-/i18nt-2.0.0.tgz","fileCount":9,"integrity":"sha512-DQuUxvibtb6r6HWCuDKoHBQOJjqUkd9tY79Gvj/dN4xCwFuziRi2u/n4jLuZlKwvccntl1TXZQzN1CH9IO0KDw==","signatures":[{"sig":"MEYCIQCh23+8zZ2UM0nCbonk7a7t0jDSwd/k2plVW0ODfRlJKgIhAI+AcL/D+RzlPBf+GvZRojpoghLOSkz9cJx4DOTXjt4a","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":27341},"main":"dist/main.js","types":"dist/types.d.ts","module":"dist/module.js","source":"src/index.ts","gitHead":"6fc1ed83fe04d1e305334ba40854c383bdcf73fb","scripts":{"build":"parcel build src/index.ts","watch":"parcel watch","prebuild":"rm -rf dist","tsc:check":"tsc --noEmit"},"targets":{"main":{"optimize":true},"module":{"optimize":true}},"_npmUser":{"name":"cheshirecat","email":"ca.leduc@me.com"},"repository":{"url":"git+https://github.com/lecheshirecat/i18nt.git","type":"git"},"_npmVersion":"10.2.4","description":"A lightweight internationalization module with TypeScript support","directories":{},"_nodeVersion":"20.11.1","_hasShrinkwrap":false,"devDependencies":{"parcel":"latest","typescript":"latest","@parcel/packager-ts":"latest","@parcel/transformer-typescript-types":"latest"},"_npmOperationalInternal":{"tmp":"tmp/i18nt_2.0.0_1711977172709_0.17344656150603477","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2022-02-08T18:11:34.298Z","modified":"2025-02-20T14:50:53.155Z","1.0.0":"2022-02-08T18:11:34.644Z","1.0.1":"2022-02-08T21:41:46.890Z","1.0.2":"2022-02-11T07:45:51.196Z","1.0.3":"2023-10-23T11:43:08.279Z","2.0.0":"2024-04-01T13:12:52.919Z"},"bugs":{"url":"https://github.com/lecheshirecat/i18nt/issues"},"author":{"name":"lecheshirecat","email":"contact@pixeliste.fr"},"license":"ISC","homepage":"https://github.com/lecheshirecat/i18nt#readme","keywords":["i18n","internationalization","plugin","js","javascript","typescript","vue","react","svelte"],"repository":{"url":"git+https://github.com/lecheshirecat/i18nt.git","type":"git"},"description":"A lightweight internationalization module with TypeScript support","maintainers":[{"name":"cheshirecat","email":"ca.leduc@me.com"}],"readme":"# i18nt\n\nA lightweight internationalization module with TypeScript support\n\n## Installation\n\n```javascript\nnpm install @cheshirecat/i18nt --save\n```\n\n## How to use\n\nDefault use in your main.js project\n\n```typescript\nimport { addTranslation } from '@cheshirecat/i18nt'\n\nimport en from './assets/locales/en.json'\nimport fr from './assets/locales/fr.json'\n...\naddTranslation('en', en)\naddTranslation('fr', fr)\n...\n```\n\nYou can set / get the current language globally as follows:\n\n```javascript\nimport { setLocale } from \"@cheshirecat/i18nt\";\n/* 'default' would set locale to your browser default language */\nsetLocale(\"default\");\n```\n\nThe JSON files consist of key-value pairs where the key is the first argument passed to the main translation function, like:\n\n```javascript\n/* json */\n{\n  \"msg1\": \"Message traduit en français\",\n  \"msg2\": \"Ceci est un autre message\",\n  \"greetings\": \"Bonjour!\"\n}\n```\n\n## Basic usage\n\nYou can import the \\_t translation function from i18nt module to localize texts in the HTML template (Vue, React, Svelte, etc.)\n\n```javascript\nimport { _t } from \"@cheshirecat/i18nt\";\n```\n\n```html\n<div>\n  <p>{_t('msg1')}</p>\n</div>\n```\n\nThe result would be translated in the browser:\n\n```html\n<div>\n  <p>Message traduit en français</p>\n</div>\n```\n\n## Advanced usage\n\nYou can pass an optional object with the following properties:\n\n- `locale`: to force translation with a locale parameter\n- `tokens`: an array to replace the %s token with the indexed string\n- `count`: a Number to output a specific translated count\n\n### Interpolation\n\nThe i18nt module supports string interpolation, with `%s` as placeholder in your translation files\n\n```html\n<div>\n  <p>{_t('greetings', { locale: 'en', tokens: ['Svelte'] })}</p>\n</div>\n```\n\n```javascript\n/* json */\n{\n  \"greetings\": \"Hello %s !\"\n}\n```\n\nIt would be rendered in the browser:\n\n```html\n<div>\n  <p>Hello Svelte !</p>\n</div>\n```\n\n### Pluralization\n\nThe i18nt module also supports pluralization, with `|` as a separator for none / one / many elements\n\n```html\n<select>\n  <option value=\"0\">{_t('crows', { count: 0 })}</option>\n  <option value=\"1\">{_t('crows', { count: 1 })}</option>\n  <option value=\"10\">{_t('crows', { count: 10 })}</option>\n</select>\n```\n\n```javascript\n{\n  \"crows\": \"None | A crow | Murder of Crows\"\n}\n```\n\nAs a result:\n\n```html\n<select>\n  <option value=\"0\">None</option>\n  <option value=\"1\">A crow</option>\n  <option value=\"10\">Murder of Crows</option>\n</select>\n```\n\n## Global parameters\n\n`getLocale`: to access the global language variable\n`setLocale`: to set the global language variable\n\n```typescript\nimport { getLocale, setLocale } from \"@cheshirecat/i18nt\";\n\nfunction setLanguage(lang: string): void {\n  setLocale(lang);\n}\n\nfunction getLanguage(): string {\n  return getLocale();\n}\n```\n\n## License\n\n[ISC](https://opensource.org/licenses/ISC)\n","readmeFilename":"README.md"}