{"id":18250672,"url":"https://github.com/jakex7/react-native-localization-settings","last_synced_at":"2025-04-12T16:36:58.859Z","repository":{"id":152068316,"uuid":"625274956","full_name":"jakex7/react-native-localization-settings","owner":"jakex7","description":"React Native module to expose per-app language preferences API on iOS and Android.","archived":false,"fork":false,"pushed_at":"2025-03-03T18:58:16.000Z","size":1461,"stargazers_count":93,"open_issues_count":5,"forks_count":18,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T17:13:38.437Z","etag":null,"topics":["hacktoberfest","i18n","i18n-react","i18next","l10n","language","per-app","react-native"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/jakex7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2023-04-08T15:54:14.000Z","updated_at":"2025-03-22T01:38:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"7c48f3d9-e7de-4a6e-9bcc-b6ff41b2fc32","html_url":"https://github.com/jakex7/react-native-localization-settings","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakex7%2Freact-native-localization-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakex7%2Freact-native-localization-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakex7%2Freact-native-localization-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakex7%2Freact-native-localization-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakex7","download_url":"https://codeload.github.com/jakex7/react-native-localization-settings/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248597488,"owners_count":21130885,"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":["hacktoberfest","i18n","i18n-react","i18next","l10n","language","per-app","react-native"],"created_at":"2024-11-05T09:45:31.994Z","updated_at":"2025-04-12T16:36:58.830Z","avatar_url":"https://github.com/jakex7.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Native Localization Settings\n\n`react-native-localization-settings` is a native module to expose per-app language preferences API on iOS and Android.\n\n![Cover image](docs/cover.png)\n\n## Supported platforms\n\n| Platform | Supported |\n|----------|:---------:|\n| iOS      |     ✅     |\n| Android* |     ✅     |\n\n_*per-app language settings was introduced in API level 33 (Android 13). On the older versions, the library uses\nSharedPreferences to store the language._\n\n## Installation\n\nTo get started with `react-native-localization-settings`, you'll need to install it using npm:\n\n```sh\nnpm install react-native-localization-settings\n```\n\nor with yarn:\n\n```sh\nyarn add react-native-localization-settings\n```\n\n## Setup\n\nTo get started, define the languages your app will support. If you're using Expo, you can leverage the Expo config plugin to generate the necessary native configurations.\n\n### Expo\n\nSimply add the config plugin to your `app.json` file and specify the list of supported languages:\n\n```json\n{\n  \"expo\": {\n    // ...\n    \"plugins\": [\n      [\n        \"react-native-localization-settings\", \n        { \n          \"languages\": [\"en\", \"pl\"] \n        }\n      ]\n    ]\n  }\n}\n```\n\nand run `npx expo prebuild`.\n\n### Bare react-native app\n\nIf your app isn’t using Expo, you’ll need to add the configuration manually.\n\n\u003cdetails\u003e\n\u003csummary\u003e\niOS configuration\n\u003c/summary\u003e\nOpen your project in XCode, in Project Navigator select project, go to `Info` tab, and\nunder `Localizations` section add languages you want to support.\n\n![XCode screenshot](docs/configuration-xcode-1.png)\n\nNext, you need to create a `Localization.strings` file.\n\n![XCode screenshot](docs/configuration-xcode-2.png)\n\nSelect newly created file and on the right side of the screen, under `Localizations` selection press `Localize`. Confirm\nthe popup.\n\n![XCode screenshot](docs/configuration-xcode-3.png)\n\nLastly, you need to select all elements in the section form previous step.\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003e\nAndroid configuration\n\u003c/summary\u003e\nCreate new file in `android/app/src/main/res/xml` directory named `locales_config.xml`. and define supported languages:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003clocale-config xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n  \u003clocale android:name=\"en\"/\u003e\n  \u003clocale android:name=\"pl\"/\u003e\n  \u003clocale android:name=\"fr\"/\u003e\n\u003c/locale-config\u003e\n```\n\nThen, open `android/app/src/main/AndroidManifest.xml` and add following line to the Application tag:\n\n```xml\n\u003capplication\n        android:name=\".MainApplication\"\n        android:localeConfig=\"@xml/locales_config\" \u003c!-- this line --\u003e\n\u003e\n```\n\u003c/details\u003e\n\n## API\n\n### getLanguage()\n\nFunction to get current language.\n\nReturns Language in IETF BCP 47 format (like 'en-US')\n\n```ts\ngetLanguage(); // 'en-US'\n```\n\n### setLanguage()\n\nFunction to set the current language.\nIt accepts a string with language code in IETF BCP 47 format (like 'en-US') or ISO 639-1 format (like 'en').\n\n```ts\nsetLanguage(\"en-US\");\n```\n\n## i18next\n\nThis library is fully compatible with [i18next](https://www.i18next.com/).\n\nTo use it with i18next, create a language detector by using `createLanguageDetector` with the specified `options`:\n```ts\nimport { createLanguageDetector } from 'react-native-localization-settings';\n\nconst languageDetector = createLanguageDetector({});\n\ni18next\n  .use(languageDetector)\n  .use(initReactI18next)\n  .init({\n    // ...\n  });\n```\n\n### Options\n\n```ts\ntype LanguageDetectorOptions = {\n  cacheCurrentLanguage?: boolean; // default: false - sets current detected language\n  async?: boolean;                // default: false - uses getLanguageAsync (set to true on old architecture)\n};\n```\n\n### Changing language\n\nThen, if you want to create custom in-app language selector, you should be able to change the language (along with the\nsettings per-app language) using standard i18next function:\n\n```ts\ni18next.changeLanguage('pl-PL');\n```\n\n## Why?\n\nUsers who speak multiple languages often set their device language to one language, such as English, but they may want\nto use other languages for certain apps, like Polish, Dutch, or French. To help apps provide a better experience for\nthese users, this package adds the ability to set language preferences for individual apps in the device's settings.\n\n## License\n\n[MIT](LICENSE)\n\n---\n\nMade with ❤️ by [Jakub Grzywacz](https://jakubgrzywacz.pl)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakex7%2Freact-native-localization-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakex7%2Freact-native-localization-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakex7%2Freact-native-localization-settings/lists"}