New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-simple-i18n

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-simple-i18n

Small i18n lib for react-native based on react-native-localize and i18n-js

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-simple-i18n 🌎

Small i18n lib for react-native based on react-native-localize, i18n-js and lodash.memoize

Version Install Size Downloads PRs Welcome Commitizen friendly MIT License

Watch on GitHub Star on GitHub Tweet

This library was inspired by How to use React Native Localize in React Native apps (written by Aman Mittal) so please go and leave this guy some 👏.

Disclaimer: This library only supports translations, it does NOT support cultural settings (currency, dates, times, etc)

Getting Started

Peer Dependencies

  • react: 16.8.0+
  • react-native: 0.59.0+
  • react-native-localize: 1.3.4+

Installation

npm install -S react-native-simple-i18n

How to use it

App.tsx
import React from 'react';
+ import { I18nProvider, useI18nProvider } from 'react-native-simple-i18n';
import ReduxProvider from 'src/components/ReduxProvider';
import Main from 'src/components/Main';

+ const messages = {
+   en: () => require('src/i18n/en.json'),
+   es: () => require('src/i18n/es.json'),
+   fr: () => require('src/i18n/fr.json'),
+ };

function App() {
+ const i18n = useI18nProvider(messages);
  return (
    <>
      <ReduxProvider>
+       <I18nProvider value={i18n}>
          <Main />
+       </I18nProvider>
      </ReduxProvider>
    </>
  );
}

export default App;
src/i18n/es.json
{
  "active": "Activo",
  "inactive": "Inactivo",
  "unknown": "Desconocido"
}
src/components/Main.tsx
import React from 'react';
import { Text, View } from 'react-native';
+ import { useI18n } from 'react-native-simple-i18n';

function Main() {
+ const { translate } = useI18n();
  return (
    <View>
      <Text>
+        {translate('active')}
      </Text>
    </View>
  );
}

export default Main;

License

MIT © jonathanpalma

Keywords

FAQs

Package last updated on 04 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc