{"id":28092746,"url":"https://github.com/strikingly/react-i18n","last_synced_at":"2025-05-13T13:40:18.018Z","repository":{"id":51552567,"uuid":"62353744","full_name":"strikingly/react-i18n","owner":"strikingly","description":"Gettext style i18n in React that supports component interpolation.","archived":false,"fork":false,"pushed_at":"2023-03-04T09:14:50.000Z","size":332,"stargazers_count":3,"open_issues_count":8,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-18T14:54:20.642Z","etag":null,"topics":["gettext","i18n","internationalization","react","react-i18n"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strikingly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-Sentry","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-01T01:42:50.000Z","updated_at":"2023-01-06T06:21:53.000Z","dependencies_parsed_at":"2023-02-09T10:00:58.729Z","dependency_job_id":null,"html_url":"https://github.com/strikingly/react-i18n","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strikingly%2Freact-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strikingly%2Freact-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strikingly%2Freact-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strikingly%2Freact-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strikingly","download_url":"https://codeload.github.com/strikingly/react-i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253951655,"owners_count":21989540,"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":["gettext","i18n","internationalization","react","react-i18n"],"created_at":"2025-05-13T13:40:17.519Z","updated_at":"2025-05-13T13:40:17.998Z","avatar_url":"https://github.com/strikingly.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# react-i18n\n\nReact i18n\n\n`npm i r-i18n --save`\n\n## Usage\n\n```jsx\nimport React from 'react'\n\nimport {\n  createI18n\n  debug, \n} from 'r-i18n'\n```\n\n## Samples\n\n#### init\nUse [Jed](http://slexaxton.github.io/Jed) to initialize i18n in your project.\n\n```jsx\nconst i18n = createI18n({ /* jed options */ })) \n```\n\n#### t\n\nComponent as placeholder\n\n```jsx\nconst {t} = i18n\n\nt('Welcome to Strikingly')  \n// -\u003e '欢迎使用 Strikingly'\n\nt('Welcome to Strikingly, %{username}', { username: 'Shu' }) \n// -\u003e '欢迎使用 Strikingly，Shu'\n\n// React component as placeholder\n\nt('%{author} assigned this event to %{assignee}', {\n  author: \u003cAuthor value={author} /\u003e,\n  assignee: \u003cem\u003eexample@example.com\u003c/em\u003e\n})\n// -\u003e [\u003cAuthor value={author} /\u003e, ' assigned this event to ', \u003cem\u003eexample@example.com\u003c/em\u003e]\n```\n\n#### tct\n\nHTML inside translated string with a root wrapper\n\n```jsx\nconst {tct} = i18n\n\n//...\n\ntct('Welcome. Click [link:here]', {\n  root: \u003cp/\u003e,\n  link: \u003ca href=\"#\" /\u003e\n})\n// -\u003e \u003cp\u003e欢迎。点击 \u003ca href=\"#\"\u003e此处\u003c/a\u003e 继续。\u003c/p\u003e\n```\n\n### Debug \u0026 mark\n\nWrap `t` and `tct` with a wrapper `\u003cspan class=\"translation-wrapper\"/\u003e`\n\n(for React Native, it just appends a flag emoji to the message)\n\n```jsx\nimport {createI18n, debug} from 'r-i18n'\n\n//...\nconst i18n = createI18n({ /* jed options */ })) \ndebug()\n\ni18n.tct('Welcome. Click [link:here]', {\n  root: \u003cp/\u003e,\n  link: \u003ca href=\"#\" /\u003e\n})\n// -\u003e \u003cspan class=\"translation-wrapper\"\u003e\n//      \u003cp\u003e欢迎。点击 \u003ca href=\"#\"\u003e此处\u003c/a\u003e 继续。\u003c/p\u003e\n//    \u003c/span\u003e\n```\n\n## React Native\n\nReact-i18n works both with React and React Native.  \nFor React Native, use `npm i rn-i18n --save`.\n\nReact Native branch: [react-native](https://github.com/strikingly/react-i18n/tree/react-native)\n\n## Syntax\n\nr-i18n uses `%{}` to pass args.  \n__And use `%%` to escape `%`__.\n\ni.e. `t('%{percentage}%% correct', { percentage: 100 }) -\u003e '100% correct'`\n\n## Acknowledgement\n\n#### [Sentry](https://github.com/getsentry/sentry)\n\nPost about i18n and React on Sentry blog: [link](https://blog.getsentry.com/2016/01/07/react-i18n.html).\n\n[Sentry source code on GitHub](https://github.com/getsentry/sentry/blob/f489a20c6d5318aba2f30fec0d745835436a94f7/src/sentry/static/sentry/app/locale.jsx).\n\n[License of Sentry](./LICENSE-Sentry).\n\n#### [sprintf.js](https://github.com/alexei/sprintf.js)\n\n[License of sprintf.js](./LICENSE-sprintfjs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrikingly%2Freact-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrikingly%2Freact-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrikingly%2Freact-i18n/lists"}