{"id":15102942,"url":"https://github.com/veliovgroup/Meteor-Internationalization","last_synced_at":"2025-09-27T01:30:34.811Z","repository":{"id":26520470,"uuid":"29973373","full_name":"veliovgroup/Meteor-Internationalization","owner":"veliovgroup","description":"🙊 Super-Lightweight and fast i18n isomorphic driver for Meteor with support of placeholders.","archived":false,"fork":false,"pushed_at":"2023-04-05T12:49:45.000Z","size":113,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-15T17:58:42.301Z","etag":null,"topics":["driver","i18n","internationalization","javascript","js","localization","meteor","meteor-package","meteorjs"],"latest_commit_sha":null,"homepage":"https://packosphere.com/ostrio/i18n","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/veliovgroup.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"dr-dimitru","custom":"https://paypal.me/veliovgroup"}},"created_at":"2015-01-28T15:14:56.000Z","updated_at":"2023-11-07T12:39:02.000Z","dependencies_parsed_at":"2024-06-19T02:58:47.341Z","dependency_job_id":null,"html_url":"https://github.com/veliovgroup/Meteor-Internationalization","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veliovgroup%2FMeteor-Internationalization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veliovgroup%2FMeteor-Internationalization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veliovgroup%2FMeteor-Internationalization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veliovgroup%2FMeteor-Internationalization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veliovgroup","download_url":"https://codeload.github.com/veliovgroup/Meteor-Internationalization/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234369843,"owners_count":18821339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["driver","i18n","internationalization","javascript","js","localization","meteor","meteor-package","meteorjs"],"created_at":"2024-09-25T19:09:56.598Z","updated_at":"2025-09-27T01:30:29.544Z","avatar_url":"https://github.com/veliovgroup.png","language":"JavaScript","funding_links":["https://github.com/sponsors/dr-dimitru","https://paypal.me/veliovgroup"],"categories":["Internationalization","Packages"],"sub_categories":[],"readme":"[![support](https://img.shields.io/badge/support-GitHub-white)](https://github.com/sponsors/dr-dimitru)\n[![support](https://img.shields.io/badge/support-PayPal-white)](https://paypal.me/veliovgroup)\n\u003ca href=\"https://ostr.io/info/built-by-developers-for-developers\"\u003e\n  \u003cimg src=\"https://ostr.io/apple-touch-icon-60x60.png\" height=\"20\"\u003e\n\u003c/a\u003e\n\n# Reactive i18n and l10n isomorphic driver\n\nObject based, fast, lightweight (*334 lines with comments*) and reactive internationalization isomorphic driver for Meteor with support of placeholders, and user's locale auto-detection.\n\nNot tied to Blaze, can be used with Vue.js, React.js or any other JS solution.\n\n## Install:\n\n```shell\nmeteor add ostrio:i18n\n```\n\n## Import:\n\n```js\nimport I18N from 'meteor/ostrio:i18n';\n```\n\n### Object-based structure\n\n```js\n/* Isomorphic (Both Server and Client) */\nconst i18nConfig = {\n  settings: { //--\u003e Config object\n    defaultLocale: \"en\",\n    ru: {\n      code: \"ru\",\n      isoCode: \"ru-RU\",\n      name: \"Русский\"\n    },\n    en: {\n      code: \"en\",\n      isoCode: \"en-US\",\n      name: \"English\"\n    }\n  },\n  ru:{ //--\u003e Localization with key of country two-letter code\n    property: \"value\",\n    property2: {\n      nestedProp: \"value\"\n    },\n    dynamicProperty(){\n      return `\u003ca href=\"/${this.currentLocale.get()}/info\"\u003einfo\u003c/a\u003e`;\n    }\n  },\n  en:{ //--\u003e Localization with key of country two-letter code\n    property: \"value\",\n    property2: {\n      nestedProp: \"value\"\n    },\n    dynamicProperty(){\n      return `\u003ca href=\"/${this.currentLocale.get()}/info\"\u003einfo\u003c/a\u003e`;\n    }\n  }\n  ...\n};\n\nimport I18N from 'meteor/ostrio:i18n';\nconst i18n = new I18N({i18n: i18nConfig});\n```\n\n## Initialization\n\n```js\nimport I18N from 'meteor/ostrio:i18n';\nconst i18n = new I18N(config);\n```\n\n- `config.i18n` {*Object*}  - [Internalization object](https://github.com/VeliovGroup/Meteor-Internationalization#object-based-structure)\n- `config.returnKey` {*Boolean*} - Return key if l10n value not found, default: `true`\n- `config.helperName` {*String*}  - Template helper name, default: `i18n`\n- `config.helperSettingsName` {*String*}  - Settings helper name, default: `i18nSettings`\n\n## API\n\n### `get([locale,] key, [replacements...])`\n\n- `locale` {*String*} - [Optional] Two-letter locale string, used to force locale, if not set __current locale__ is used\n- `key` {*String*} - l10n key like: `object.path.to.key`\n- `replacements..` {*String*|[*String*]|*Object*} - [Optional] Replacements for placeholders in l10n string\n\n```js\ni18n.get('object.path.to.key'); // Current locale, no replacements\n\ni18n.get(locale, param); // Force locale, no replacements\ni18n.get('en', 'object.path.to.key');\n\ni18n.get(param, replacements); // Current locale, with replacements\ni18n.get('object.path.to.key', 'Michael'); // Hello {{username}} -\u003e Hello Michael\n\ni18n.get(locale, param, replacements); // Force locale, with replacements\ni18n.get('en', 'object.path.to.key', 'John Doe'); // Hello {{username}} -\u003e Hello John Doe\n```\n\n### `has([locale,] key)`\n\n*Determine whenever key is exists in configuration file(s).*\n\n- `locale` {*String*} - [Optional] Two-letter locale string, used to force locale, if not set __current locale__ is used\n- `key` {*String*} - l10n key like: `object.path.to.key`\n\n```js\ni18n.has('object.path.to.key'); // Current locale\ni18n.has(locale, param); // Force locale\ni18n.has('ca', 'object.path.to.key'); //false\ni18n.has('en', 'object.path.to.key'); //true\n```\n\n### `setLocale(locale)`\n\n- `locale` {*String*} - Two-letter locale code\n\n```js\ni18n.setLocale(locale);\n```\n\n### `addl10n(l10n)`\n\n- `l10n` {*Object*} - Object with language set\n\n```js\ni18n.addl10n({\n  en: { // \u003c- Object's root is the language two-letter code\n    newKey: \"New Value\"\n  }\n});\n```\n\n### Get current localization at any environment\n\n```js\ni18n.currentLocale.get(); // Reactive on Client\n```\n\n### Get current default locale\n\n```js\ni18n.defaultLocale;\n```\n\n### Get configuration object\n\n```js\ni18n.langugeSet();\n/* Returns:\n{\n  current: 'en', // Current locale\n  locales: ['ru', en], // List of locales\n  // All locales\n  all: [{\n    code: \"ru\",\n    isoCode: \"ru-RU\",\n    name: \"Русский\",\n    path: \"i18n/ru/\"\n  },{\n    code: \"en\",\n    isoCode: \"en-US\",\n    name: \"English\",\n    path: \"i18n/en/\"\n  }],\n  // All locales except current\n  other: [{\n    code: \"ru\",\n    isoCode: \"ru-RU\",\n    name: \"Русский\",\n    path: \"i18n/ru/\"\n  }],\n}\n*/\n```\n\n### Get specific key from configuration object\n\n- `key` {*String*} - One of the keys: `current`, `all`, `other`, `locales`, `currentISO`, `currentName`, `currentPath`\n\n```js\ni18n.getSetting('current'); // en\n```\n\n### Blaze specific usage\n\nUsage in Blaze templating\n\n#### Client's browser locale\n\n```js\ni18n.userLocale; // en-US\n```\n\n#### Template helpers\n\n__Template helpers requires__ `templating` __package to be installed__. `i18n` helper - accepts `locale`, `key` and `replacements`\n\n```handlebars\n\u003cp\u003e{{i18n 'sample.hello'}}\u003c/p\u003e\n\u003cp\u003e{{{i18n 'sample.html'}}}\u003c/p\u003e\n\u003cp\u003e{{i18n 'sample.fullName'}}\u003c/p\u003e\n\u003cp\u003e{{i18n 'sample.fullName' 'Michael' 'A.' 'Macht'}}\u003c/p\u003e\n\u003cp\u003e{{i18n 'en' 'sample.fullName' 'Michael' 'A.' 'Macht'}}\u003c/p\u003e\n\u003cp\u003e{{i18n 'de' 'sample.fullName' first='Michael' middle='A.' last='Macht'}}\u003c/p\u003e\n\u003cp\u003e{{i18n 'sample.fullName' first='Michael' middle='A.' last='Macht'}}\u003c/p\u003e\n\u003cp\u003e{{i18n 'sample.fullName' first='Michael' middle='A.' third='Macht'}}\u003c/p\u003e\n```\n\n*Change name of the helper via config object: `config.helperName`*\n\n`i18nSettings` - accepts configuration object key, one of `current`, `all`, `other`, `locales`\n\n```handlebars\n{{#each i18nSettings 'all'}}\n  ...\n{{/each}}\n```\n\n*Change name of the helper via config object: `config.helperSettingsName`*\n\n#### Template language switcher example\n\n```handlebars\n\u003ctemplate name=\"langSwitch\"\u003e\n  {{#each i18nSettings 'all'}}\n    {{#if compare code '==' currentLocale}}\n      \u003cspan title=\"Current language\"\u003e{{name}}\u003c/span\u003e\u0026nbsp;\n    {{else}}\n      \u003ca href=\"#\" data-switch-language=\"{{code}}\"\u003e{{name}}\u003c/a\u003e\u0026nbsp;\n    {{/if}}\n  {{/each}}\n\u003c/template\u003e\n```\n\n```js\nTemplate.langSwitch.helpers({\n  currentLocale(){\n    return i18n.currentLocale.get()\n  }\n});\n\nTemplate.langSwitch.events({\n  'click [data-switch-language]'(e) {\n    e.preventDefault();\n    i18n.setLocale(e.currentTarget.dataset.switchLanguage);\n    return false;\n  }\n});\n```\n\nTemplate helpers `compare`, `==`, `Session` and many more comes from: [`ostrio:templatehelpers`](https://atmospherejs.com/ostrio/templatehelpers) package.\n\n## Support this project:\n\n- [Sponsor via GitHub](https://github.com/sponsors/dr-dimitru)\n- [Support via PayPal](https://paypal.me/veliovgroup)\n- Use [ostr.io](https://ostr.io) — [Monitoring](https://snmp-monitoring.com), [Analytics](https://ostr.io/info/web-analytics), [WebSec](https://domain-protection.info), [Web-CRON](https://web-cron.info) and [Pre-rendering](https://prerendering.com) for a website\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveliovgroup%2FMeteor-Internationalization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveliovgroup%2FMeteor-Internationalization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveliovgroup%2FMeteor-Internationalization/lists"}