{"id":23507353,"url":"https://github.com/simplyhexagonal/i18n","last_synced_at":"2025-07-23T22:39:02.577Z","repository":{"id":71910286,"uuid":"409463796","full_name":"simplyhexagonal/i18n","owner":"simplyhexagonal","description":"i18next wrapper for use as an esbuild / ViteJS plugin or as a stand-alone dependency","archived":false,"fork":false,"pushed_at":"2021-10-26T17:34:15.000Z","size":146,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-12T08:27:15.147Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplyhexagonal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-09-23T05:46:16.000Z","updated_at":"2022-02-26T14:55:47.000Z","dependencies_parsed_at":"2023-09-24T03:32:17.240Z","dependency_job_id":"24d6cf9e-6b23-4ebc-88ec-90ce7f2a4d35","html_url":"https://github.com/simplyhexagonal/i18n","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"72a53553dc979db0d01440a61ea86cb6ef512f4f"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/simplyhexagonal/i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyhexagonal%2Fi18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyhexagonal%2Fi18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyhexagonal%2Fi18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyhexagonal%2Fi18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplyhexagonal","download_url":"https://codeload.github.com/simplyhexagonal/i18n/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyhexagonal%2Fi18n/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266250154,"owners_count":23899401,"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":[],"created_at":"2024-12-25T10:18:13.967Z","updated_at":"2025-07-23T22:39:02.548Z","avatar_url":"https://github.com/simplyhexagonal.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/jeanlescure","https://opencollective.com/simplyhexagonal"],"categories":[],"sub_categories":[],"readme":"# Simply Hexagonal i18n\n![Tests](https://github.com/simplyhexagonal/i18n/workflows/tests/badge.svg)\n\n[i18next](https://www.npmjs.com/package/i18next) wrapper for use as an esbuild / ViteJS plugin\nor as a stand-alone dependency.\n\n## Open source notice\n\nThis project is open to updates by its users, [I](https://github.com/jeanlescure) ensure that PRs are relevant to the community.\nIn other words, if you find a bug or want a new feature, please help us by becoming one of the\n[contributors](#contributors-) ✌️ ! See the [contributing section](#contributing)\n\n## Like this module? ❤\n\nPlease consider:\n\n- [Buying me a coffee](https://www.buymeacoffee.com/jeanlescure) ☕\n- Supporting Simply Hexagonal on [Open Collective](https://opencollective.com/simplyhexagonal) 🏆\n- Starring this repo on [Github](https://github.com/simplyhexagonal/i18n) 🌟\n\n## Install\n\n```sh\npnpm i -D\n\n# or\nyarn add -D\n\n# or\nnpm install -D \n```\n\n## Config\n\n```ts\nimport I18N from '@simplyhexagonal/i18n';\n\nimport en from './i18n/en.json';\nimport es from './i18n/es.json';\n// etc..\n\nconst i18n = new I18N({\n  resources: {\n    ...en,\n    ...es,\n    // etc...\n  }\n});\n```\n\n## Usage\n\nWith [esbuild](https://esbuild.github.io/):\n\n```ts\nawait i18n.changeLanguage('en');\n\nconst esbuildConfig: BuildOptions = {\n  entryPoints: [/* ... */],\n  outfile: '...',\n  bundle: true,\n  minify: isProduction,\n  plugins: [\n    i18n.plugins.esbuild,\n  ],\n};\n\nbuild(esbuildConfig);\n```\n\nWith [Vite](https://vitejs.dev/):\n\n```ts\nawait i18n.changeLanguage('en');\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [\n    i18n.plugins.vite,\n  ],\n});\n```\n\nStand-alone:\n\n```ts\nawait i18n.initPromise;\n\nawait i18n.changeLanguage('en');\n\nconst template = fs.readFileSync('./template.html').toString();\n\nconst result = i18n.apply(template);\n\n// do something with result\n```\n\n## Template usage and configuration\n\nIn your templates use the `__('key')` notation:\n\n```tsx\n\u003ch1\u003e__('hello')\u003c/h1\u003e\n```\n\nIf you would like to change the notation, you can set your own custom regular exression to find the\ni18n keys within your templates:\n\n```ts\nconst i18n = new I18N(\n  {\n    resources: {\n      ...en,\n      ...es,\n    },\n  },\n  [\n    /\\{\\{([^\\{\\}]+?)\\}\\}/g,\n  ],\n);\n```\n\nThe key is expected to always be the first matching group (i.e. whatever is matched within the\nfirst set of parenthesis in your regex).\n\n**NOTE:** _you can define multiple regexes._\n\nThen in your template:\n\n```tsx\n\u003ch1\u003e{{hello}}\u003c/h1\u003e\n```\n## Contributing\n\nYes, thank you! This plugin is community-driven, most of its features are from different authors.\nPlease update the docs and tests and add your name to the `package.json` file.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://jeanlescure.cr\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/3330339?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJean Lescure\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#maintenance-jeanlescure\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e \u003ca href=\"https://github.com/simplyhexagonal/i18n/commits?author=jeanlescure\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#userTesting-jeanlescure\" title=\"User Testing\"\u003e📓\u003c/a\u003e \u003ca href=\"https://github.com/simplyhexagonal/i18n/commits?author=jeanlescure\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"#example-jeanlescure\" title=\"Examples\"\u003e💡\u003c/a\u003e \u003ca href=\"https://github.com/simplyhexagonal/i18n/commits?author=jeanlescure\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n## License\n\nCopyright (c) 2021-Present [Simply Hexagonal i18n Contributors](https://github.com/simplyhexagonal/i18n/#contributors-).\u003cbr/\u003e\nLicensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplyhexagonal%2Fi18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplyhexagonal%2Fi18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplyhexagonal%2Fi18n/lists"}