Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Formatjs | 13,729 | 7,980 | 2,984 | 5 days ago | 293 | September 06, 2022 | 37 | TypeScript | ||
The monorepo home to all of the FormatJS related libraries, most notably react-intl. | ||||||||||
Js Lingui | 3,756 | 47 | 69 | 3 days ago | 73 | June 22, 2022 | 23 | mit | TypeScript | |
๐ ๐ A readable, automated, and optimized (3 kb) internationalization for JavaScript | ||||||||||
Twinkle Tray | 3,299 | 3 days ago | 229 | mit | JavaScript | |||||
Easily manage the brightness of your monitors in Windows from the system tray | ||||||||||
Nodejs.org | 2,713 | 11 hours ago | 4 | May 05, 2022 | 40 | other | JavaScript | |||
The Node.jsยฎ Website | ||||||||||
React Native I18n | 2,176 | 705 | 29 | 6 days ago | 27 | July 18, 2018 | 75 | mit | Objective-C | |
React Native + i18n.js | ||||||||||
Next Translate | 2,175 | 1 | 14 | a day ago | 208 | September 21, 2022 | 102 | mit | JavaScript | |
Next.js plugin + i18n API for Next.js ๐ - Load page translations and use them in an easy way! | ||||||||||
React Native Localize | 2,035 | 58 | 67 | 4 days ago | 40 | September 27, 2022 | 2 | mit | Java | |
๐ A toolbox for your React Native app localization | ||||||||||
Typesafe I18n | 1,611 | 12 days ago | 219 | July 16, 2022 | 2 | mit | TypeScript | |||
A fully type-safe and lightweight internationalization library for all your TypeScript and JavaScript projects. | ||||||||||
Reactnativelocalization | 875 | 119 | 14 | a year ago | 60 | February 21, 2022 | 64 | mit | JavaScript | |
Class to localize the ReactNative interface | ||||||||||
Fluent.js | 829 | 8 | 15 | 14 days ago | 9 | December 21, 2021 | 91 | apache-2.0 | JavaScript | |
JavaScript implementation of Project Fluent |
A toolbox for your React Native app localization.
package version | react-native version |
---|---|
3.0.0+ | 0.70.0+ |
2.0.0+ | 0.60.0+ |
$ npm install --save react-native-localize
# --- or ---
$ yarn add react-native-localize
Don't forget to run pod install
after thatย !
This package supports react-native-web
. Follow their official guide to configure webpack
.
As this library uses synchronous native methods, remote debugging (e.g. with Chrome) is no longer possible.
Instead, you should use Flipper ๐ฌ.
import { getCurrencies, getLocales } from "react-native-localize";
console.log(getLocales());
console.log(getCurrencies());
Returns the user preferred locales, in order.
type getLocales = () => Array<{
languageCode: string;
scriptCode?: string;
countryCode: string;
languageTag: string;
isRTL: boolean;
}>;
import { getLocales } from "react-native-localize";
console.log(getLocales());
/* -> [
{ countryCode: "GB", languageTag: "en-GB", languageCode: "en", isRTL: false },
{ countryCode: "US", languageTag: "en-US", languageCode: "en", isRTL: false },
{ countryCode: "FR", languageTag: "fr-FR", languageCode: "fr", isRTL: false },
] */
Returns number formatting settings.
type getNumberFormatSettings = () => {
decimalSeparator: string;
groupingSeparator: string;
};
import { getNumberFormatSettings } from "react-native-localize";
console.log(getNumberFormatSettings());
/* -> {
decimalSeparator: ".",
groupingSeparator: ",",
} */
Returns the user preferred currency codes, in order.
type getCurrencies = () => string[];
import { getCurrencies } from "react-native-localize";
console.log(getCurrencies());
// -> ["EUR", "GBP", "USD"]
Returns the user current country code (based on its device locale, not on its position).
type getCountry = () => string;
import { getCountry } from "react-native-localize";
console.log(getCountry());
// -> "FR"
Devices using Latin American regional settings will return "UN" instead of "419", as the latter is not a standard country code.
Returns the user preferred calendar format.
type getCalendar = () =>
| "gregorian"
| "buddhist"
| "coptic"
| "ethiopic"
| "ethiopic-amete-alem"
| "hebrew"
| "indian"
| "islamic"
| "islamic-umm-al-qura"
| "islamic-civil"
| "islamic-tabular"
| "iso8601"
| "japanese"
| "persian";
import { getCalendar } from "react-native-localize";
console.log(getCalendar());
// -> "gregorian"
Returns the user preferred temperature unit.
type getTemperatureUnit = () => "celsius" | "fahrenheit";
import { getTemperatureUnit } from "react-native-localize";
console.log(getTemperatureUnit());
// -> "celsius"
Returns the user preferred timezone (based on its device settings, not on its position).
type getTimeZone = () => string;
import { getTimeZone } from "react-native-localize";
console.log(getTimeZone());
// -> "Europe/Paris"
Returns true
if the user prefers 24h clock format, false
if they prefer 12h clock format.
type uses24HourClock = () => boolean;
import { uses24HourClock } from "react-native-localize";
console.log(uses24HourClock());
// -> true
Returns true
if the user prefers metric measure system, false
if they prefer imperial.
type usesMetricSystem = () => boolean;
import { usesMetricSystem } from "react-native-localize";
console.log(usesMetricSystem());
// -> true
Tells if the automatic date & time setting is enabled on the phone. Android only
type usesAutoDateAndTime = () => boolean | undefined;
import { usesAutoDateAndTime } from "react-native-localize";
console.log(usesAutoDateAndTime()); // true or false
Tells if the automatic time zone setting is enabled on the phone. Android only
type usesAutoTimeZone = () => boolean | undefined;
import { usesAutoTimeZone } from "react-native-localize";
console.log(usesAutoTimeZone());
Returns the best language tag possible and its reading direction (โ ๏ธ it respects the user preferred languages list order, see explanations). Useful to pick the best translation available.
type findBestLanguageTag = (
languageTags: string[],
) => { languageTag: string; isRTL: boolean } | void;
import { findBestLanguageTag } from "react-native-localize";
console.log(findBestLanguageTag(["en-US", "en", "fr"]));
// -> { languageTag: "en-US", isRTL: false }
Browse the files in the /example directory.
You can add / remove supported localizations in your Xcode project infos:
Because it's a native module, you need to mock this package.
The package provides a default mock you may use in your __mocks__/react-native-localize.js or jest.setup.js.
import localizeMock from "react-native-localize/mock";
jest.mock("react-native-localize", () => localizeMock);
This module is provided as is, I work on it in my free time.
If 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.