{"id":28502354,"url":"https://github.com/hexojs/hexo-i18n","last_synced_at":"2025-07-05T02:31:30.325Z","repository":{"id":24580710,"uuid":"27988627","full_name":"hexojs/hexo-i18n","owner":"hexojs","description":"i18n module for Hexo.","archived":false,"fork":false,"pushed_at":"2024-07-15T13:13:02.000Z","size":65,"stargazers_count":14,"open_issues_count":4,"forks_count":9,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-03T19:10:55.691Z","etag":null,"topics":["hexo","typescript"],"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/hexojs.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}},"created_at":"2014-12-14T08:43:50.000Z","updated_at":"2024-08-09T05:09:43.000Z","dependencies_parsed_at":"2024-04-06T03:24:17.466Z","dependency_job_id":"1b5ba633-7f11-4325-9428-c3391988e3af","html_url":"https://github.com/hexojs/hexo-i18n","commit_stats":{"total_commits":59,"total_committers":13,"mean_commits":4.538461538461538,"dds":0.8135593220338984,"last_synced_commit":"97c1971f4f74eb1f36ce653f0057c8b2f47a708e"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/hexojs/hexo-i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexojs","download_url":"https://codeload.github.com/hexojs/hexo-i18n/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexojs%2Fhexo-i18n/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259780155,"owners_count":22910152,"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":["hexo","typescript"],"created_at":"2025-06-08T16:09:51.492Z","updated_at":"2025-07-05T02:31:30.319Z","avatar_url":"https://github.com/hexojs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hexo-i18n\n\n[![CI](https://github.com/hexojs/hexo-i18n/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/hexojs/hexo-i18n/actions/workflows/ci.yml)\n[![NPM version](https://badge.fury.io/js/hexo-i18n.svg)](https://www.npmjs.com/package/hexo-i18n)\n[![Coverage Status](https://coveralls.io/repos/github/hexojs/hexo-i18n/badge.svg)](https://coveralls.io/github/hexojs/hexo-i18n)\n\ni18n module for [Hexo].\n\n## Installation\n\n``` bash\n$ npm install hexo-i18n --save\n```\n\n## Usage\n\n### Example\n\n``` js\nvar i18n = new require('hexo-i18n')({\n  languages: ['zh-TW', 'en']\n});\n\ni18n.set('en', {\n  ok: 'OK',\n  name: 'My name is %1$s %2$s.',\n  index: {\n    title: 'Home'\n  },\n  video: {\n    zero: 'No videos',\n    one: 'A video',\n    other: '%d videos'\n  }\n});\n\ni18n.set('zh-TW', {\n  name: '我的名字是 %2$s %1$s。',\n  index: {\n    title: '首頁'\n  },\n  video: {\n    zero: '沒有影片',\n    one: '一部影片',\n    other: '%d 部影片'\n  }\n});\n\nvar __ = i18n.__();\nvar _p = i18n._p();\n\n__('ok') // OK\n__('index.title') // 首頁\n__('name', '大呆', '王') // 我的名字是王大呆\n_p('video', 0) // 沒有影片\n_p('video', 1) // 一部影片\n_p('video', 10) // 10 部影片\n```\n\n### new i18n([options])\n\nCreates a new i18n instance.\n\nOption | Description | Default\n--- | --- | ---\n`languages` | Default languages. It can be an array or a string | `default`\n\n### i18n.get([lang]) → Object\n\nReturns a set of localization data. `lang` can be an array or a string, or the default language defined in constructor if not set. This method will build the data in order of languages.\n\n### i18n.set(lang, data)\n\nLoads localization data.\n\n### i18n.remove(lang)\n\nUnloads localization data.\n\n### i18n.list()\n\nLists loaded languages.\n\n### i18n.__() → Function(key, arg...)\n\nReturns a function for localization.\n\n### i18n._p() → Function(key, count, ...)\n\nThis method is similar to `i18n.__`, but it returns pluralized string based on the second parameter. For example:\n\n``` js\n_p('video', 0) = __('video.zero', 0)\n_p('video', 1) = __('video.one', 1)\n_p('video', 10) = __('video.other', 10)\n```\n\n## License\n\nMIT\n\n[Hexo]: https://hexo.io/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexojs%2Fhexo-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexojs%2Fhexo-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexojs%2Fhexo-i18n/lists"}