Skip to content

Repository files navigation

MaintainabilityTest CoveragenpmnpmSnyk Vulnerabilities for npm packageNPM

Rosetty React

Complete Intl/I18n solution for React based on Rosetty. Old Owner: @flexper

Usage

//In your app.js file, add the following code:import{RosettyProvider}from'rosetty-react';import{fr}from'date-fns/locale';constlocales={fr: {dict: {},locale: fr}};constdefaultLanguage='fr';constApp=({ children })=>(<RosettyProviderlocales={locales}defaultLanguage={defaultLanguage}>{children}</RosettyProvider>);module.exports=App;//In your components file, add the following code:import{useRosetty}from'rosetty-react';constHome=()=>{const{ t }=useRosetty();return<h1>{t('home')}</h1>;};module.exports=Home;

API

RosettyProvider

Options

Field NameTypeDescription
localesRecord<string, Language>Specify dictionnary and locale to use for each lang
defaultLanguagestring?Specify default language to use (should be the same as config)

Return: Rosetty Context HOC + {actualLang: string} who contain your current language

Return a component who instantiate the Rosetty Context.

WARNING FOR LOCALE !

You need to import locale from date-fns package.

const{ enGB }=require('date-fns/locale');

Maintain

This package use TSdx. Please check documentation to update this package.

About

Complete Intl/I18n solution for React

Topics

Resources

Stars

2 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages