npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-easy-localization-and-rtl

v1.1.0

Published

A simple module to add localization and RTL support to your react native app

Readme

React Native Easy Localization and RTL

This library is for creating multi-Language supported apps easily on android and ios using react native without any reloads. It helps to change language and layout easily using predefined styles.

Lets build an RTL layout stylesheet library for ease of use

Getting Started

yarn add react-native-localization react-native-easy-localization-and-rtl

npm i --save react-native-localization react-native-easy-localization-and-rtl

This Library use react-native-localization.

Installation

#react-native >= 0.60
cd ios && pod install && cd ..

#react-native < 0.60
react-native link react-native-localization

for manual installation guide https://github.com/stefalda/ReactNativeLocalization

Usage

import { RTLProvider } from "react-native-easy-localization-and-rtl";
// wrap your app in this provider
<RTLProvider>
  <App />
</RTLProvider>;

Setting up Language Object

There are two ways u can setup the Language Object

1. Initializing RTLProvider with your own version of Localized String (Recommended) Using react-native-localization lib you can create the localized strings and pass it in this library.

//LocalizedConstants.js

import { initializeRTL } from "react-native-easy-localization-and-rtl";
import LocalizedStrings from "react-native-localization";

const localizedString = new LocalizedStrings({
  en: {
    region: "Select Your Region",
    loginMsg: " Kindly enter email address and password to Login",
    noAccount: "Don’t have an account? Click Sign Up button",
    forgotPassword: "Forgot Password",
    login: "Login",
    signup: "Sign up",
    email: "Email Address",
    password: "Password",
    addPhoto: "Add Photo",
    name: "Name and Surname",
  },
  ar: {
    region: "حدد منطقتك",
    loginMsg: "يرجى إدخال عنوان البريد الإلكتروني وكلمة المرور لتسجيل الدخول",
    noAccount: "ليس لديك حساب؟ انقر فوق زر التسجيل",
    forgotPassword: "هل نسيت كلمة المرور",
    login: "تسجيل الدخول",
    signup: "سجل",
  },
});

initializeRTL(localizedString);

export { localizedString };

2. Directly Initializing This will have some problems with intellisense (I am working on its fix)

//LocalizedConstants.js
import { LocalizationString } from "react-native-easy-localization-and-rtl";
const strings = LocalizationString({
  en: {
    region: "Select Your Region",
    loginMsg: " Kindly enter email address and password to Login",
    noAccount: "Don’t have an account? Click Sign Up button",
    forgotPassword: "Forgot Password",
    login: "Login",
    signup: "Sign up",
    email: "Email Address",
    password: "Password",
    addPhoto: "Add Photo",
    name: "Name and Surname",
    helloWorld: "Hello World",
  },
  ar: {
    region: "حدد منطقتك",
    loginMsg: "يرجى إدخال عنوان البريد الإلكتروني وكلمة المرور لتسجيل الدخول",
    noAccount: "ليس لديك حساب؟ انقر فوق زر التسجيل",
    forgotPassword: "هل نسيت كلمة المرور",
    login: "تسجيل الدخول",
    signup: "سجل",
  },
});

export { strings };

Using High Order Class Component

for localized string object you can use either the one passed in props or the object that u created


import React, { Component } from 'react'
import { Text, View } from 'react-native'
import {withRtl} from "react-native-easy-localization-and-rtl"
//If you want to use localized object directly both are same instances so will always be same
import {strings} from './LocalizedConstants.js'


class App extends Component {

  componentDidMount(){
    console.log('Currently Active Language',this.props.language)
    console.log('Currently Active Layout',this.props.isRtl)
    console.log('Currently Active Styles',this.props.RtlStyles)


  }

  onPress=()=>{
    this.props.setLanguage('ar')
  }

  render() {
    return (
      <View style={{...this.props.RtlStyles.containerColumn}}>
        <Text style={{...this.props.RtlStyles.text}} onPress={onPress}>{this.props.localizedString.name} </Text>
        <Text>{strings.name} </Text>
      </View>
    )
  }
}

export withRtl(App)

Using in Functional Component

import React from "react";
import { View, Text } from "react-native";
import { useRtlContext } from "react-native-easy-localization-and-rtl";

export default function App() {
  const { RtlStyles, isRtl, language, setLanguage } = useRtlContext();

  return (
    <View style={{ ...RtlStyles.containerColumn }}>
      <Text
        style={{ ...this.props.RtlStyles.text }}
        onPress={() => {
          setLanguage("ar");
        }}
      >
        {strings.name}
      </Text>
    </View>
  );
}

Available Style Object

RtlStyles

  • containerColumn
  • containerRow
  • text
  • containerColumnInverse
  • containerRowInverse
  • textInverse
  • flipHorizontal

APIs

All Functions

LocalizedStrings functions

Note: Dont use setLanguage directly on localizedString object

  • setLanguage(languageCode) - to force manually a particular language
  • getLanguage() - to get the current displayed language
  • getInterfaceLanguage() - to get the current device interface language
  • formatString() - to format the passed string replacing its placeholders with the other arguments strings
  • setContent(languageObject) - overwrites the current language obj

for further details visit https://github.com/stefalda/ReactNativeLocalization

RTL functions

  • getSheet(LocalizedStrings) - get stylesheet for the current language
  • isRTL(LocalizedStrings) - get RTL status : boolean

Examples

Format String Examples

  en:{
    bread:"bread",
    butter:"butter",
    question:"I'd like {0} and {1}, or just {0}"
  }
  ...
  strings.formatString(strings.question, strings.bread, strings.butter)

Overwrite Locale

You might have default localized in the build but then download the latest localization strings from a server. Use setContent to overwrite the whole object. NOTE that this will remove all other localizations if used.

strings.setContent({
  en: {
    how: "How do you want your egg todajsie?",
    boiledEgg: "Boiled eggsie",
    softBoiledEgg: "Soft-boiled egg",
    choice: "How to choose the egg",
  },
});

You can also only overwrite a specific language using

strings.setContent(
  Object.assign({}, strings.getContent(), {
    en: {
      how: "How do you want your egg todajsie?",
      boiledEgg: "Boiled eggsie",
      softBoiledEgg: "Soft-boiled egg",
      choice: "How to choose the egg",
    },
  })
);