{"id":16368003,"url":"https://github.com/fzn0x/yoi18n","last_synced_at":"2025-03-23T02:33:19.076Z","repository":{"id":249481133,"uuid":"831646141","full_name":"fzn0x/yoi18n","owner":"fzn0x","description":"⚡ Straightforward \u0026 less effort React i18n library. (Under 1kb gminzipped)","archived":false,"fork":false,"pushed_at":"2024-07-23T04:32:51.000Z","size":321,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-12T02:51:20.358Z","etag":null,"topics":["i18n","internationalization","lightweight","localization","multi-language","react","react-i18n","react-library","translations","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/fzn0x.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":"2024-07-21T07:40:18.000Z","updated_at":"2024-07-23T04:32:54.000Z","dependencies_parsed_at":"2024-07-21T09:33:34.352Z","dependency_job_id":"78bf1d34-7fb5-4bdf-af2f-b492390df7f0","html_url":"https://github.com/fzn0x/yoi18n","commit_stats":null,"previous_names":["fzn0x/yoi18n","fzn0x/reacti18n","fzn0x/fasti18n"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzn0x%2Fyoi18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzn0x%2Fyoi18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzn0x%2Fyoi18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzn0x%2Fyoi18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fzn0x","download_url":"https://codeload.github.com/fzn0x/yoi18n/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221842782,"owners_count":16890202,"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","lightweight","localization","multi-language","react","react-i18n","react-library","translations","typescript"],"created_at":"2024-10-11T02:51:24.006Z","updated_at":"2024-10-28T14:46:38.552Z","avatar_url":"https://github.com/fzn0x.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yoi18n\n\n\u003e [!WARNING]\n\u003e This package is still a work in progress.\n\n\u003chr /\u003e\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/fzn0x/yoi18n/ci.yml?branch=main)](https://github.com/fzn0x/yoi18n/actions)\n[![GitHub](https://img.shields.io/github/license/fzn0x/yoi18n)](https://github.com/fzn0x/yoi18n/blob/main/LICENSE)\n[![npm](https://img.shields.io/npm/v/yoi18n)](https://www.npmjs.com/package/yoi18n)\n[![npm](https://img.shields.io/npm/dm/yoi18n)](https://www.npmjs.com/package/yoi18n)\n[![JSR](https://jsr.io/badges/@fzn0x/yoi18n)](https://jsr.io/@fzn0x/yoi18n)\n[![Bundle Size](https://img.shields.io/bundlephobia/min/yoi18n)](https://bundlephobia.com/result?p=yoi18n)\n[![Bundle Size](https://img.shields.io/bundlephobia/minzip/yoi18n)](https://bundlephobia.com/result?p=yoi18n)\n[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/fzn0x/yoi18n)](https://github.com/fzn0x/yoi18n/pulse)\n[![GitHub last commit](https://img.shields.io/github/last-commit/fzn0x/yoi18n)](https://github.com/fzn0x/yoi18n/commits/main)\n\n\u003chr /\u003e\n\n⚡Straightforward \u0026 less effort React i18n library.\n\n## Get to Know\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [JavaScript](#javascript)\n  - [TypeScript](#typescript)\n  - [React](#react)\n- [License](#license)\n\n## Installation\n\n```bash\nbun install yoi18n\nnpm install yoi18n\nyarn add yoi18n\npnpm install yoi18n\n```\n\n## Usage\n\nCreates `lang.json` and `lang-admin.json` files:\n\n**`lang.json` :**\n\n```json\n{\n  \"en\": {\n    \"hello\": \"hello world\"\n  },\n  \"de\": {\n    \"hello\": \"Guten Morgen\"\n  },\n  \"id\": {\n    \"hello\": \"Hallo bang\"\n  }\n}\n```\n\n**`lang-admin.json` :**\n\n```json\n{\n  \"en\": {\n    \"hello\": \"hello world from admin\"\n  },\n  \"de\": {\n    \"hello\": \"Guten Morgen from admin\"\n  },\n  \"id\": {\n    \"hello\": \"Hallo bang from admin\"\n  }\n}\n```\n\n### JavaScript\n\n```js\n// lang.js\nconst i18n = require('yoi18n')\n\nconst t = i18n.init({\n  namespace: {\n    default: {\n      // user pages\n      load: `/lang.json`,\n      defaultLang: 'en',\n    },\n    admin: {\n      // admin pages\n      load: `/lang-admin.json`,\n      defaultLang: 'en',\n    },\n  },\n  detection: {\n    order: ['cookie', 'path', 'query'], // use defaultLang if not found\n    defaultLang: 'en',\n  },\n})\n\nconsole.log(t('hello')) // \"hello\" from default namespace\nconsole.log(t('admin.hello')) // \"hello\" from admin namespace,\n\n// You can export for reusability\n// module.exports = t;\n```\n\n### TypeScript\n\n```js\n// lang.ts\nimport i18n from 'yoi18n'\n\nconst t = i18n.init({\n  namespace: {\n    default: {\n      // user pages\n      load: `/lang.json`,\n      defaultLang: 'en',\n    },\n    admin: {\n      // admin pages\n      load: `/lang-admin.json`,\n      defaultLang: 'en',\n    },\n  },\n  detection: {\n    order: ['cookie', 'path', 'query'], // use defaultLang if not found\n    defaultLang: 'en',\n  },\n})\n\nconsole.log(t('hello')) // \"hello\" from default namespace\nconsole.log(t('admin.hello')) // \"hello\" from admin namespace,\n\n// You can export for reusability\n// export default t;\n```\n\n### React\n\n```jsx\nimport i18n from 'yoi18n'\n\nconst t = i18n.init({\n  namespace: {\n    default: {\n      // user pages\n      load: `/lang.json`,\n      defaultLang: 'en',\n    },\n    admin: {\n      // admin pages\n      load: `/lang-admin.json`,\n      defaultLang: 'en',\n    },\n  },\n  detection: {\n    order: ['cookie', 'path', 'query'], // use defaultLang if not found\n    defaultLang: 'en',\n  },\n})\n\n// Creates a function LanguageSwitch to change defaultLang\nexport default function LanguageSwitch({ lang, ns }) {\n  // t.switch is to change the defaultLang\n  return \u003cdiv onClick={() =\u003e t.switch(lang, ns)}\u003eSwitch Language for {ns}\u003c/div\u003e\n}\n\n;\u003cLanguageSwitch lang='de' ns='default' /\u003e\n;\u003cLanguageSwitch lang='de' ns='admin' /\u003e\n```\n\n## License\n\nyoi18n is [MIT Licensed](./LICENSE) and Open Source Software by [@fzn0x](https://github.com/fzn0x)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzn0x%2Fyoi18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffzn0x%2Fyoi18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzn0x%2Fyoi18n/lists"}