{"id":13798902,"url":"https://github.com/xcarpentier/ex-react-native-i18n","last_synced_at":"2025-05-13T06:31:45.362Z","repository":{"id":45916881,"uuid":"73093932","full_name":"xcarpentier/ex-react-native-i18n","owner":"xcarpentier","description":"💱 ex-react-native-i18n for Expo","archived":false,"fork":true,"pushed_at":"2024-06-09T15:43:59.000Z","size":58,"stargazers_count":83,"open_issues_count":8,"forks_count":25,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-19T18:16:30.679Z","etag":null,"topics":["exponent","react-native"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"AlexanderZaytsev/react-native-i18n","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xcarpentier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"xcarpentier","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2016-11-07T15:42:13.000Z","updated_at":"2024-05-08T10:32:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/xcarpentier/ex-react-native-i18n","commit_stats":null,"previous_names":["xcarpentier/react-native-i18n"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcarpentier%2Fex-react-native-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcarpentier%2Fex-react-native-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcarpentier%2Fex-react-native-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcarpentier%2Fex-react-native-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xcarpentier","download_url":"https://codeload.github.com/xcarpentier/ex-react-native-i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253888965,"owners_count":21979536,"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":["exponent","react-native"],"created_at":"2024-08-04T00:00:56.259Z","updated_at":"2025-05-13T06:31:44.940Z","avatar_url":"https://github.com/xcarpentier.png","language":"JavaScript","funding_links":["https://github.com/sponsors/xcarpentier"],"categories":["Libraries built by the community","JavaScript"],"sub_categories":["Demos"],"readme":"[![NPM version](https://badge.fury.io/js/ex-react-native-i18n.svg)](http://badge.fury.io/js/ex-react-native-i18n)\n[![Downloads](https://img.shields.io/npm/dm/ex-react-native-i18n.svg)](https://www.npmjs.com/package/ex-react-native-i18n)\n[![reactnative.gallery](https://img.shields.io/badge/reactnative.gallery-%E2%99%A5-red.svg)](https://reactnative.gallery)\n\n# ex-react-native-i18n for Expo\nIntegrates [I18n.js](https://github.com/fnando/i18n-js) with React Native and ***Expo***. Uses the device's locale as default.\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n## Automatic setup\n`$ npm install ex-react-native-i18n --save`\n\nor\n\n`$ yarn add ex-react-native-i18n`\n\n## Usage\n\nBefore copy usage see this issue: https://github.com/xcarpentier/ex-react-native-i18n/issues/7\n\n```javascript\nimport I18n from 'react-native-i18n'\n\n\nclass Demo extends React.Component {\n  // Async call to init the locale\n  componentWillMount() {\n    I18n.initAsync();\n  }\n  render () {\n    return (\n      \u003cText\u003e{I18n.t('greeting')}\u003c/Text\u003e\n    )\n  }\n}\n\n// Enable fallbacks if you want `en-US` and `en-GB` to fallback to `en`\nI18n.fallbacks = true\n\nI18n.translations = {\n  en: {\n    greeting: 'Hi!'\n  },\n  fr: {\n    greeting: 'Bonjour!'\n  }\n}\n```\n\nThis will render `Hi!` for devices with the English locale, and `Bonjour!` for devices with the French locale.\n\n### Fallbacks\nWhen fallbacks are enabled (which is generally recommended), `i18n.js` will try to look up translations in the following order (for a device with `en_US` locale):\n- en-US\n- en\n\n**Note**: iOS locales use underscored (`en_US`) but `i18n.js` locales are dasherized (`en-US`). This conversion is done automatically for you.\n```js\nI18n.fallbacks = true\n\nI18n.translations = {\n  'en': {\n    greeting: 'Hi!'\n  },\n  'en-GB': {\n    greeting: 'Hi from the UK!'\n  }\n}\n```\nFor a device with a `en_GB` locale this will return `Hi from the UK!'`, for a device with a `en_US` locale it will return `Hi!`.\n\n### Device's locale\nYou can get the device's locale with the `RNI18n` native module:\n```js\nimport I18n from 'ex-react-native-i18n'\nconst deviceLocale = I18n.locale\n```\n\nReturns `en-US`.\n\n\n### I18n.js documentation\nFor more info about I18n.js methods (`localize`, `pluralize`, etc) and settings see [its documentation](https://github.com/fnando/i18n-js#setting-up).\n\n\n## Hire an expert!\nLooking for a ReactNative freelance expert with more than 12 years experience? Contact me from my [website](https://xaviercarpentier.com)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcarpentier%2Fex-react-native-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxcarpentier%2Fex-react-native-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcarpentier%2Fex-react-native-i18n/lists"}