{"id":17677519,"url":"https://github.com/dvcol/vite-plugin-i18n","last_synced_at":"2026-05-01T15:33:08.844Z","repository":{"id":151660263,"uuid":"624562298","full_name":"dvcol/vite-plugin-i18n","owner":"dvcol","description":"Vite plugin to generate merged i18n locales","archived":false,"fork":false,"pushed_at":"2023-04-23T11:41:36.000Z","size":174,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-24T22:17:39.450Z","etag":null,"topics":["i18n","library","plugin","vite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dvcol.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2023-04-06T18:45:46.000Z","updated_at":"2024-10-07T12:18:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"67bf1f6c-28ef-4f73-9d65-4a8e904be253","html_url":"https://github.com/dvcol/vite-plugin-i18n","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":"dvcol/typescript-lib-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvcol%2Fvite-plugin-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvcol%2Fvite-plugin-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvcol%2Fvite-plugin-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvcol%2Fvite-plugin-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvcol","download_url":"https://codeload.github.com/dvcol/vite-plugin-i18n/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246357605,"owners_count":20764359,"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":["i18n","library","plugin","vite"],"created_at":"2024-10-24T07:28:56.073Z","updated_at":"2026-05-01T15:33:03.815Z","avatar_url":"https://github.com/dvcol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-i18n\n\n**vite-plugin-i18n** is a vite plugin to generate static json locale files, either in a virtual object or in a dist folder.\n\nIt parses all json i18n files in a given folder and merge them by language scope.\n\nFiles need to conform to the following structure to be properly parsed:\n\n```\nsrc\n├── ...\n├── root\n│   ├── locale.en.json\n│   ├── locale.es.json\n│   ├── locale.fr.json\n│   └── ...\n│   └── models\n│       ├── models.en.json\n│       ├── models.es.json\n│       ├── models.fr.json\n│       └── ...\n└── ...\n```\n\nWhere src/root is the given root folder containing files to be parsed.\n\n## Usage\n\n#### Install dev dependency :\n\n```shell\nyarn add vite-plugin-i18n -D\nnpm install vite-plugin-i18n --save-dev\npnpm install vite-plugin-i18n --save-dev\n```\n\n#### Add the plugin to your `vite.config.ts`:\n\n```typescript\n// vite.config.ts\nimport { viteI18nPlugin } from \"./vite-plugin-i18n\";\n\nexport default {\n  plugins: [\n    viteI18nPlugin({\n      path: \"src/i18n\",\n      out: \"dist/locale\",\n    }),\n  ],\n};\n```\n\n#### Use virtual module :\n\n```typescript\nimport { locales, watchLocales } from 'virtual:vite-plugin-i18n';\n\nconsole.info('My locales at runtime', locales);\n\nwatchLocales((data: Locale) =\u003e console.info('My locales on hot reload', data));\n```\n\n#### Use hot module reload :\n\n```typescript\nif (import.meta.hot) {\n  import.meta.hot.on('virtual:vite-plugin-i18n', ({ data }) =\u003e {\n    console.info(data) // new locale\n  })\n}\n```\n\n## API\n\n### options\n\n- Type: Object\n\n#### options.path\n\n- Type: `string`\n- Default: `undefined`\n\nThe path where the plugin will attempt to parse json formatted files into unified locales.\n\n#### options.out\n\n- Type: `boolean | string | { dir: string; name?: string } | (locale: string, messages: RecursiveRecord\u003cstring\u003e) =\u003e string`\n- Default: `undefined`\n\nAn string, option object or resolver function to compute the filepath and filename of generated locales.\n\nBy default, the plugin will not write files and only generate a virtual module (see [vite virtual modules](https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention))\n\nIf output is enabled the files will be generated with the following structure:\n\n```\ndist\n├── ...\n├── locales\n│   ├── en.json\n│   ├── es.json\n│   ├── fr.json\n│   └── ...\n└── ...\n```\n\nYou can provide a custom folder path, file name, or file name resolver like this:\n\n```typescript\nviteI18nPlugin({\n  path: \"src/i18n\",\n  out: \"dist/locales\",\n});\n```\n\n```typescript\n viteI18nPlugin({\n  path: \"src/i18n\",\n  out: {\n    dir: 'dist/_locales'\n    name: 'my-custom-name'\n  },\n})\n```\n\n```typescript\nviteI18nPlugin({\n  path: \"src/i18n\",\n  out: (locale, messages) =\u003e `prefix-${locale}-${messages[\"suffixe\"]}.json`,\n});\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvcol%2Fvite-plugin-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvcol%2Fvite-plugin-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvcol%2Fvite-plugin-i18n/lists"}