{"id":4512,"url":"https://github.com/zoontek/react-native-localize","last_synced_at":"2025-05-11T05:45:08.385Z","repository":{"id":38825107,"uuid":"99022582","full_name":"zoontek/react-native-localize","owner":"zoontek","description":"🌍 A toolbox for your React Native app localization","archived":false,"fork":false,"pushed_at":"2025-04-24T22:05:42.000Z","size":6132,"stargazers_count":2343,"open_issues_count":4,"forks_count":213,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-08T01:13:07.925Z","etag":null,"topics":["android","globalization","i18n","internationalization","ios","language-detection","react-native"],"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/zoontek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["zoontek"]}},"created_at":"2017-08-01T16:38:22.000Z","updated_at":"2025-05-07T09:13:50.000Z","dependencies_parsed_at":"2024-03-17T11:26:31.539Z","dependency_job_id":"77add4b7-f93f-4a2f-a356-8f742662e611","html_url":"https://github.com/zoontek/react-native-localize","commit_stats":{"total_commits":376,"total_committers":35,"mean_commits":"10.742857142857142","dds":"0.35904255319148937","last_synced_commit":"ee5bf25e0bb8f3b8e4f3fd055f67ad46269c81ea"},"previous_names":["react-community/react-native-languages","react-native-community/react-native-localize"],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoontek%2Freact-native-localize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoontek%2Freact-native-localize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoontek%2Freact-native-localize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoontek%2Freact-native-localize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoontek","download_url":"https://codeload.github.com/zoontek/react-native-localize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978783,"owners_count":21834917,"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":["android","globalization","i18n","internationalization","ios","language-detection","react-native"],"created_at":"2024-01-05T20:17:14.823Z","updated_at":"2025-05-08T01:13:20.501Z","avatar_url":"https://github.com/zoontek.png","language":"TypeScript","readme":"# 🌍  react-native-localize\n\nA toolbox for your React Native app localization.\n\n[![mit licence](https://img.shields.io/dub/l/vibe-d.svg?style=for-the-badge)](https://github.com/zoontek/react-native-localize/blob/main/LICENSE)\n[![npm version](https://img.shields.io/npm/v/react-native-localize?style=for-the-badge)](https://www.npmjs.org/package/react-native-localize)\n[![npm downloads](https://img.shields.io/npm/dt/react-native-localize.svg?label=downloads\u0026style=for-the-badge)](https://www.npmjs.org/package/react-native-localize)\n\u003cbr /\u003e\n[![platform - android](https://img.shields.io/badge/platform-Android-3ddc84.svg?logo=android\u0026style=for-the-badge)](https://www.android.com)\n[![platform - ios](https://img.shields.io/badge/platform-iOS-000.svg?logo=apple\u0026style=for-the-badge)](https://developer.apple.com/ios)\n[![platform - macos](https://img.shields.io/badge/platform-macOS-000.svg?logo=apple\u0026style=for-the-badge)](https://developer.apple.com/macos)\n[![platform - web](https://img.shields.io/badge/platform-Web-1977f2.svg?logo=html5\u0026logoColor=fff\u0026style=for-the-badge)](https://developer.mozilla.org)\n\n\u003cimg width=\"400\" height=\"auto\" center src=\"https://github.com/zoontek/react-native-localize/blob/master/docs/screenshot.png?raw=true\" /\u003e\n\n## Support\n\nThis library follows the React Native [releases support policy](https://github.com/reactwg/react-native-releases/blob/main/docs/support.md).\u003cbr\u003e\nIt is supporting the **latest version**, and the **two previous minor series**.\n\n## Setup\n\n```bash\n$ npm install --save react-native-localize\n# --- or ---\n$ yarn add react-native-localize\n```\n\n_Don't forget to run `pod install` after that !_\n\n### Web support\n\nThis package supports `react-native-web`. Follow their [official guide](https://necolas.github.io/react-native-web/docs/multi-platform/#compiling-and-bundling) to configure `webpack`.\n\n### Debugging\n\nAs this library uses synchronous native methods, remote debugging (e.g. with Chrome) is no longer possible.\u003cbr /\u003e\nInstead, you should use [Flipper 🐬](https://fbflipper.com).\n\n## Basic usage example\n\n```ts\nimport { getCurrencies, getLocales } from \"react-native-localize\";\n\nconsole.log(getLocales());\nconsole.log(getCurrencies());\n```\n\n## API\n\n### getLocales()\n\nReturns the user preferred locales, in order.\n\n#### Method type\n\n```ts\ntype getLocales = () =\u003e Array\u003c{\n  languageCode: string;\n  scriptCode?: string;\n  countryCode: string;\n  languageTag: string;\n  isRTL: boolean;\n}\u003e;\n```\n\n#### Usage example\n\n```ts\nimport { getLocales } from \"react-native-localize\";\n\nconsole.log(getLocales());\n/* -\u003e [\n  { countryCode: \"GB\", languageTag: \"en-GB\", languageCode: \"en\", isRTL: false },\n  { countryCode: \"US\", languageTag: \"en-US\", languageCode: \"en\", isRTL: false },\n  { countryCode: \"FR\", languageTag: \"fr-FR\", languageCode: \"fr\", isRTL: false },\n] */\n```\n\n---\n\n### getNumberFormatSettings()\n\nReturns number formatting settings.\n\n#### Method type\n\n```ts\ntype getNumberFormatSettings = () =\u003e {\n  decimalSeparator: string;\n  groupingSeparator: string;\n};\n```\n\n#### Usage example\n\n```ts\nimport { getNumberFormatSettings } from \"react-native-localize\";\n\nconsole.log(getNumberFormatSettings());\n/* -\u003e {\n  decimalSeparator: \".\",\n  groupingSeparator: \",\",\n} */\n```\n\n---\n\n### getCurrencies()\n\nReturns the user preferred currency codes, in order.\n\n#### Method type\n\n```ts\ntype getCurrencies = () =\u003e string[];\n```\n\n#### Usage example\n\n```ts\nimport { getCurrencies } from \"react-native-localize\";\n\nconsole.log(getCurrencies());\n// -\u003e [\"EUR\", \"GBP\", \"USD\"]\n```\n\n---\n\n### getCountry()\n\nReturns the user current country code (based on its device locale, **not** on its position).\n\n#### Method type\n\n```ts\ntype getCountry = () =\u003e string;\n```\n\n#### Usage example\n\n```ts\nimport { getCountry } from \"react-native-localize\";\n\nconsole.log(getCountry());\n// -\u003e \"FR\"\n```\n\n#### Note\n\nDevices using Latin American regional settings will return \"UN\" instead of \"419\", as the latter is not a standard country code.\n\n---\n\n### getCalendar()\n\nReturns the user preferred calendar format.\n\n#### Method type\n\n```ts\ntype getCalendar = () =\u003e\n  | \"gregorian\"\n  | \"buddhist\"\n  | \"coptic\"\n  | \"ethiopic\"\n  | \"ethiopic-amete-alem\"\n  | \"hebrew\"\n  | \"indian\"\n  | \"islamic\"\n  | \"islamic-umm-al-qura\"\n  | \"islamic-civil\"\n  | \"islamic-tabular\"\n  | \"iso8601\"\n  | \"japanese\"\n  | \"persian\";\n```\n\n#### Usage example\n\n```ts\nimport { getCalendar } from \"react-native-localize\";\n\nconsole.log(getCalendar());\n// -\u003e \"gregorian\"\n```\n\n---\n\n### getTemperatureUnit()\n\nReturns the user preferred temperature unit.\n\n#### Method type\n\n```ts\ntype getTemperatureUnit = () =\u003e \"celsius\" | \"fahrenheit\";\n```\n\n#### Usage example\n\n```ts\nimport { getTemperatureUnit } from \"react-native-localize\";\n\nconsole.log(getTemperatureUnit());\n// -\u003e \"celsius\"\n```\n\n---\n\n### getTimeZone()\n\nReturns the user preferred timezone (based on its device settings, **not** on its position).\n\n#### Method type\n\n```ts\ntype getTimeZone = () =\u003e string;\n```\n\n#### Usage example\n\n```ts\nimport { getTimeZone } from \"react-native-localize\";\n\nconsole.log(getTimeZone());\n// -\u003e \"Europe/Paris\"\n```\n\n---\n\n### uses24HourClock()\n\nReturns `true` if the user prefers 24h clock format, `false` if they prefer 12h clock format.\n\n#### Method type\n\n```ts\ntype uses24HourClock = () =\u003e boolean;\n```\n\n#### Usage example\n\n```ts\nimport { uses24HourClock } from \"react-native-localize\";\n\nconsole.log(uses24HourClock());\n// -\u003e true\n```\n\n---\n\n### usesMetricSystem()\n\nReturns `true` if the user prefers metric measure system, `false` if they prefer imperial.\n\n#### Method type\n\n```ts\ntype usesMetricSystem = () =\u003e boolean;\n```\n\n#### Usage example\n\n```ts\nimport { usesMetricSystem } from \"react-native-localize\";\n\nconsole.log(usesMetricSystem());\n// -\u003e true\n```\n\n---\n\n### usesAutoDateAndTime()\n\nTells if the automatic date \u0026 time setting is enabled on the phone. **Android only**\n\n#### Method type\n\n```ts\ntype usesAutoDateAndTime = () =\u003e boolean | undefined;\n```\n\n#### Usage example\n\n```ts\nimport { usesAutoDateAndTime } from \"react-native-localize\";\n\nconsole.log(usesAutoDateAndTime()); // true or false\n```\n\n---\n\n### usesAutoTimeZone()\n\nTells if the automatic time zone setting is enabled on the phone. **Android only**\n\n#### Method type\n\n```ts\ntype usesAutoTimeZone = () =\u003e boolean | undefined;\n```\n\n#### Usage example\n\n```ts\nimport { usesAutoTimeZone } from \"react-native-localize\";\n\nconsole.log(usesAutoTimeZone());\n```\n\n---\n\n### findBestLanguageTag()\n\nReturns the best language tag possible and its reading direction. Useful to pick the best translation available.\n\n\u003e [!NOTE]\n\u003e\n\u003e It respects the user preferred languages list order (see [explanations](https://github.com/zoontek/react-native-localize/issues/57#issuecomment-508456427)).\n\n#### Method type\n\n```ts\ntype findBestLanguageTag = (\n  languageTags: string[],\n) =\u003e { languageTag: string; isRTL: boolean } | void;\n```\n\n#### Usage example\n\n```ts\nimport { findBestLanguageTag } from \"react-native-localize\";\n\nconsole.log(findBestLanguageTag([\"en-US\", \"en\", \"fr\"]));\n// -\u003e { languageTag: \"en-US\", isRTL: false }\n```\n\n---\n\n### openAppLanguageSettings()\n\nOpens the app language settings.\n\n\u003e [!WARNING]\n\u003e\n\u003e This feature is available only on Android 13+ and require [configuring your app's supported locales](https://developer.android.com/guide/topics/resources/app-languages#use-localeconfig).\n\n#### Method type\n\n```ts\ntype openAppLanguageSettings = () =\u003e Promise\u003cvoid\u003e;\n```\n\n#### Usage example\n\n```ts\nimport { openAppLanguageSettings } from \"react-native-localize\";\n\nopenAppLanguageSettings(\"application\").catch((error) =\u003e {\n  console.warn(\"Cannot open app language settings\", error);\n});\n```\n\n## Examples with [@formatjs/intl](https://formatjs.io/docs/intl)\n\nBrowse the files in the [/example](https://github.com/zoontek/react-native-localize/tree/master/example) directory.\n\n## How to update supported localizations (iOS)\n\nYou can add / remove supported localizations in your Xcode project infos:\n\n![](https://github.com/zoontek/react-native-localize/blob/master/docs/xcode-adding-locales.png?raw=true)\n\n## How to test your code\n\nBecause it's a native module, you need to mock this package.\u003cbr /\u003e\nThe package provides a default mock you may import in your `__mocks__` directory:\n\n```ts\n// __mocks__/react-native-localize.ts\nexport * from \"react-native-localize/mock\"; // or \"react-native-localize/mock/jest\"\n```\n\n## Sponsors\n\nThis module is provided **as is**, I work on it in my free time.\n\nIf you or your company uses it in a production app, consider sponsoring this project 💰. You also can contact me for **premium** enterprise support: help with issues, prioritize bugfixes, feature requests, etc.\n\n\u003ca href=\"https://github.com/sponsors/zoontek\"\u003e\u003cimg align=\"center\" alt=\"Sponsors list\" src=\"https://raw.githubusercontent.com/zoontek/sponsors/main/sponsorkit/sponsors.svg\"\u003e\u003c/a\u003e\n","funding_links":["https://github.com/sponsors/zoontek"],"categories":["Components","📦 Libraries","TypeScript","Internationalization (i18n)"],"sub_categories":["Internationalization","React / React Native","Graphics \u0026 Drawing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoontek%2Freact-native-localize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoontek%2Freact-native-localize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoontek%2Freact-native-localize/lists"}