{"id":26874000,"url":"https://github.com/createwheel/mini-i18n","last_synced_at":"2025-03-31T09:32:35.094Z","repository":{"id":61351522,"uuid":"550873210","full_name":"CreateWheel/mini-i18n","owner":"CreateWheel","description":"Lightweight the internationalization module","archived":false,"fork":false,"pushed_at":"2024-01-29T14:51:15.000Z","size":51,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T11:50:25.433Z","etag":null,"topics":["i18n","internationalization","language"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/CreateWheel.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}},"created_at":"2022-10-13T13:17:48.000Z","updated_at":"2022-12-27T02:26:46.000Z","dependencies_parsed_at":"2022-10-15T17:18:30.957Z","dependency_job_id":null,"html_url":"https://github.com/CreateWheel/mini-i18n","commit_stats":null,"previous_names":["lete114/mini-i18n"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CreateWheel%2Fmini-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CreateWheel%2Fmini-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CreateWheel%2Fmini-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CreateWheel%2Fmini-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CreateWheel","download_url":"https://codeload.github.com/CreateWheel/mini-i18n/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246447059,"owners_count":20778908,"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","internationalization","language"],"created_at":"2025-03-31T09:32:34.430Z","updated_at":"2025-03-31T09:32:35.083Z","avatar_url":"https://github.com/CreateWheel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mini-i18n\n\nLightweight the internationalization module, Can be run in browser or nodejs environment, only 1kb\n\n## Installation\n\n```bash\nnpm install mini-i18n\n```\n\n## Usage\n\n```js\nimport I18n from 'mini-i18n'\n\nconst options = {\n  lang: 'zh', // default language\n  languages: {\n    // list of languages\n    zh: { hello: '你好', languages: [{ js: ['ts', 'nodejs'] }, 'java', 'c#'] }\n  }\n}\n\n// Initialize and return a translation method\nconst t = I18n.init(options)\n\nconsole.log('hello:', t('hello')) // hello: 你好\n\n// Adding new languages to the language list\nI18n.setLanguage('en', { hello: 'hello', languages: [{ js: ['ts', 'nodejs'] }, 'java', 'c#'] })\n\n// View the list of languages\nconsole.log('list of languages:', I18n.getLanguage())\n// {\n//   zh: {\n//     hello: \"你好\",\n//     languages: [{ \"js\": [\"ts\", \"nodejs\"] }, \"java\", \"c#\"]\n//   },\n//   en: {\n//     hello: \"hello\",\n//     languages: [{ \"js\": [\"ts\", \"nodejs\"] }, \"java\", \"c#\"]\n//   }\n// }\n\n// Switching languages\nI18n.use('en')\n\nconsole.log('hello:', t('hello')) // hello: hello\n\n// Switching zh\nI18n.use('zh')\n\nconsole.log('hello:', t('hello')) // hello: 你好\n\n// can be obtained by subscripting the array\nconsole.log('array index:', t('languages[0].js[1]')) // array index: nodejs\n\n// See which language is currently in use\nconsole.log('current use language:', I18n.use()) // current use language: zh\n\n// How do you change dynamically?\n\n// For example, the hello above has it output hello, world\n// Custom Add Placeholder\nI18n.setLanguage('en-test', { hello: 'hello$[placeholder]', languages: [{ js: ['ts', 'nodejs'] }, 'java', 'c#'] })\n\nI18n.use('en-test')\n\n// By using the replace method of the string\nconst hello = t('hello').replace('$[placeholder]', ', world')\nconsole.log('en-test:', hello) // en-test: hello, world\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreatewheel%2Fmini-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreatewheel%2Fmini-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreatewheel%2Fmini-i18n/lists"}