{"id":17936220,"url":"https://github.com/i18n-pro/svelte","last_synced_at":"2025-09-16T03:48:14.426Z","repository":{"id":236932036,"uuid":"600417803","full_name":"i18n-pro/svelte","owner":"i18n-pro","description":" Lightweight, simple, flexible, automatic translation internationalization tool for Svelte（适用于 Svelte 的轻量、简单、灵活、自动翻译的国际化工具）","archived":false,"fork":false,"pushed_at":"2025-09-06T08:32:27.000Z","size":885,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-06T10:05:05.625Z","etag":null,"topics":["auto-translation","automatic-translation","i18n","i18n-pro","machine-translation","svelte","svelte-i18n","translator"],"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/i18n-pro.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-11T12:37:32.000Z","updated_at":"2025-08-25T17:10:47.000Z","dependencies_parsed_at":"2024-04-29T10:02:11.994Z","dependency_job_id":"3c50cc6c-9d96-4074-a7d2-b39f3b92ecb7","html_url":"https://github.com/i18n-pro/svelte","commit_stats":null,"previous_names":["i18n-pro/svelte"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/i18n-pro/svelte","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i18n-pro%2Fsvelte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i18n-pro%2Fsvelte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i18n-pro%2Fsvelte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i18n-pro%2Fsvelte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/i18n-pro","download_url":"https://codeload.github.com/i18n-pro/svelte/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i18n-pro%2Fsvelte/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275358840,"owners_count":25450443,"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","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["auto-translation","automatic-translation","i18n","i18n-pro","machine-translation","svelte","svelte-i18n","translator"],"created_at":"2024-10-28T22:01:22.446Z","updated_at":"2025-09-16T03:48:14.415Z","avatar_url":"https://github.com/i18n-pro.png","language":"TypeScript","funding_links":[],"categories":["Utilities","Recently Updated"],"sub_categories":["Internationalization","[Oct 27, 2024](/content/2024/10/27/README.md)"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cp style=\"font-size: 18px;\"\u003eAn out-of-the-box, lightweight i18n auto-translation solution for Svelte\u003c/p\u003e\n\nEnglish | [简体中文](https://github.com/i18n-pro/svelte/blob/v2.0.0/README_zh-CN.md)\n\n\n\n[![npm-version](https://img.shields.io/npm/v/@i18n-pro/svelte.svg?style=flat-square \"npm-version\")](https://www.npmjs.com/package/@i18n-pro/svelte \"npm\")\n[![npm-download](https://img.shields.io/npm/dm/@i18n-pro/svelte \"npm-download\")](https://www.npmjs.com/package/@i18n-pro/svelte \"npm\")\n\n[![github-stars](https://img.shields.io/github/stars/i18n-pro/svelte?style=social \"github-stars\")](https://github.com/i18n-pro/svelte/stargazers \"github-stars\")\n[![last-commit](https://img.shields.io/github/last-commit/i18n-pro/svelte/main \"last-commit\")](https://github.com/i18n-pro/svelte/commits/main \"last-commit\")\n[![github-issues](https://img.shields.io/github/issues-raw/i18n-pro/svelte \"github-issues\")](https://github.com/i18n-pro/svelte/issues \"github-issues\")\n[![codecov](https://codecov.io/gh/i18n-pro/svelte/branch/main/graph/badge.svg?token=0F80N8BAZ0 \"codecov\")](https://codecov.io/gh/i18n-pro/svelte \"codecov\")\n\n![demo](https://s3.bmp.ovh/imgs/2025/07/11/f4158e232580e524.gif)\n\n\u003c/div\u003e\n\u003cdetails \u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n\n  [Vision](#vision)\u003cbr/\u003e\n  [Requirement](#requirement)\u003cbr/\u003e\n  [Features](#features)\u003cbr/\u003e\n  [Live Demo](#live-demo)\u003cbr/\u003e\n  [Principle](#principle)\u003cbr/\u003e\n  \u0026emsp;\u0026emsp;[Implementation based on  `Store` ](#implementation-based-on--store)\u003cbr/\u003e\n  \u0026emsp;\u0026emsp;[Implementation based on  `Context` ](#implementation-based-on--context)\u003cbr/\u003e\n  [License](#license)\u003cbr/\u003e\n\n\u003c/details\u003e\n\n\n# Vision\nMake internationalization easy and enjoyable 😄💪🏻\n\n# Requirement\n\n* svelte \u003e= **3.0.0**\n* i18n-pro \u003e= **3.0.0** \u003c **4.0.0**\n\n\n# Features\n\n* **lightweight**：[![bundlesize](https://img.shields.io/bundlephobia/minzip/i18n-pro?color=brightgreen\u0026style=plastic \"i18n-pro-bundlesize\")](https://bundlephobia.com/package/i18n-pro \"i18n-pro-bundlesize\") + [![bundlesize](https://img.shields.io/bundlephobia/minzip/@i18n-pro/svelte?color=brightgreen\u0026style=plastic \"bundlesize\")](https://bundlephobia.com/package/@i18n-pro/svelte \"bundlesize\")\n* The following features are inherited from  [i18n-pro](https://github.com/i18n-pro/core \"i18n-pro\") \n   * **simple**\n   * **flexible**\n   * **automatic-translation**\n   * **keyless**\n\n\n# Live Demo\n\n* Implementation based on  `Store` \n   * [Open in CodeSandbox](https://codesandbox.io/p/github/i18n-pro/svelte-demo/main?file=README.md)\n   * [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg \"Open in StackBlitz\")](https://stackblitz.com/github/i18n-pro/svelte-demo?file=README.md)\n* Implementation based on  `Context` \n   * [Open in CodeSandbox](https://codesandbox.io/p/github/i18n-pro/svelte-demo/context?file=README.md)\n   * [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg \"Open in StackBlitz\")](https://stackblitz.com/github/i18n-pro/svelte-demo/tree/context?file=README.md)\n\n\n# Principle\nThis library has corresponding implementations for the  `Store`  and  `Context`  features based on  [i18n-pro](https://github.com/i18n-pro/core \"i18n-pro\")  and  `Svelte` \n## Implementation based on  `Store` \nMainly composed of  `4`  part\n* createI18n\n* t\n* setI18n\n* i18nState\n\n\n\n**createI18n**：Initialize internationalization\u003cbr /\u003e**t**：Get internationalization text\u003cbr /\u003e**setI18n**：Set language or language package\u003cbr /\u003e**i18nState**：The current state of internationalization\n\n\n\nA simple example is as follows\n```typescript\n// i18n.ts\nimport { createI18n } from '@i18n-pro/svelte'\n\ncreateI18n( {\n  namespace: 'testNamespace',\n  locale: \"en\",\n  langs: {\n    zh: {\n      'hello world': '你好世界',\n      'custom-key': '你好世界',\n    },\n    ja:{\n      \"hello world\": \"こんにちは世界\",\n      'custom-key': 'こんにちは世界',\n    },\n  }\n})\n\n// App.svelte\n\u003cscript\u003e\n  import { t } from '@i18n-pro/svelte'\n\u003c/script\u003e\n\n\u003cdiv\u003e\n  {/** text-as-key */}\n  \u003cdiv\u003e{$t('hello world')}\u003c/div\u003e\n  {/** custom-key */}\n  \u003cdiv\u003e{$t.t('custom-key', 'hello world')}\u003c/div\u003e\n\u003c/div\u003e\n\n// index.ts\nimport './i18n'\nimport App from './App.svelte'\n\nnew App({\n  target: document.getElementById('app'),\n})\n```\n\n## Implementation based on  `Context` \nMainly composed of  `2`  part\n* I18nProvider\n* useI18n\n\n\n\n**I18nProvider**：Configure container components for internationalization initialization properties\u003cbr /\u003e**useI18n**：Hook method for obtaining internationalization API and state\n\n\n\nA simple example is as follows\n```typescript svelte\n// App.svelte\n\u003cscript\u003e\n  import { useI18n } from '@i18n-pro/svelte/context'\n  const { t } = useI18n()\n\u003c/script\u003e\n\n\u003cdiv\u003e\n  {/** text-as-key */}\n  \u003cdiv\u003e{$t('hello world')}\u003c/div\u003e\n  {/** custom-key */}\n  \u003cdiv\u003e{$t.t('custom-key', 'hello world')}\u003c/div\u003e\n\u003c/div\u003e\n\n// Root.svelte\n\u003cscript\u003e\n  import { I18nProvider } from '@i18n-pro/svelte/context'\n  import App from './App.svelte'\n\u003c/script\u003e\n\n\u003cI18nProvider\n  namespace=\"i18n-example\"\n  locale=\"en\"\n  langs={{\n    zh: {\n      'hello world': '你好世界',\n      'custom-key': '你好世界',\n    },\n    ja:{\n      \"hello world\": \"こんにちは世界\",\n      'custom-key': 'こんにちは世界',\n    },\n  }}\n\u003e\n  \u003cApp/\u003e\n\u003c/I18nProvider\u003e\n\n// index.ts\nimport App from './Root.svelte'\n\nnew App({\n  target: document.getElementById('app'),\n})\n```\n\n# Help Document\n\n\u003e To avoid unnecessary duplicate document content, some of the documents in this library are linked to the content in  `i18n-pro` \u003cbr/\u003e\n\u003e The  `i18n-pro`  related link in the current document is based on the  `3.0.0`  version. If you are using a different version, you need to check the document corresponding to the version you are using to avoid inconsistent usage\u003cbr/\u003e\n* Current Library\n   * Quick Start\n      * [Implementation based on  `Store` ](https://github.com/i18n-pro/svelte/blob/v2.0.0/docs/dist/USAGE_STORE.md)\n      * [Implementation based on  `Context` ](https://github.com/i18n-pro/svelte/blob/v2.0.0/docs/dist/USAGE_CONTEXT.md)\n   * API\n      * [Implementation based on  `Store` ](https://github.com/i18n-pro/svelte/blob/v2.0.0/docs/dist/API_STORE.md)\n      * [Implementation based on  `Context` ](https://github.com/i18n-pro/svelte/blob/v2.0.0/docs/dist/API_CONTEXT.md)\n   * [Changelog](https://github.com/i18n-pro/svelte/blob/v2.0.0/docs/dist/CHANGELOG.md)\n* i18n-pro\n   * [Command Line](https://github.com/i18n-pro/core/blob/v3.0.0/docs/dist/COMMAND_LINE.md)\n   * [Matching Rules](https://github.com/i18n-pro/core/blob/v3.0.0/docs/dist/MATCH_RULE.md)\n   * [Q\u0026A](https://github.com/i18n-pro/core/blob/v3.0.0/docs/dist/Q\u0026A.md)\n   * [Translation Log](https://github.com/i18n-pro/core/blob/v3.0.0/docs/dist/OUTPUT_LOG.md)\n\n\n# License\n[MIT](./LICENSE)\n\nCopyright (c) 2023-present Eyelly Wu","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi18n-pro%2Fsvelte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi18n-pro%2Fsvelte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi18n-pro%2Fsvelte/lists"}