0.2.2 ā€¢ Published 4 years ago

i18n-butler v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

I18n Butler

coverage

I18n simple and convenient with React and Redux

  • šŸ‘Øā€šŸ’» Provide I18n as JSON
  • šŸ™Œ Use I18n as React Hook
  • šŸ„³ Works wherever Redux works (yes, also with React and React Native)
  • šŸ„³ No dependencies
  • šŸ”§ Tool for Excel2JSON conversion and reverse

Getting Started

Install I18n Butler

$ yarn add i18n-butler
# or
$ npm install i18n-butler

Usage

I18n Butler offers one method only, which creates a React Hook.

I18n

šŸšØ I18n presumes you provide a reducer that is accessible via state.i18n and provides the current language, e.g. { lang: 'en' }. You might detect this dynamically by using Redux Saga. Now create the Hook.

// useTranslation.js

import I18n from 'i18n-butler'

const i18n = {
  helloWorld: {
    translation: {
      en: 'Hello World',
      de: 'Hallo Welt'
    },
    context: 'app', // For custom group / filter / sort
    group: 'common' // For custom group / filter / sort
  }
}

export const { useTranslation } = I18n({
  i18n,
  fallback: 'en',
  state: state => state.i18n
});

Use the hook in any component.

import { useTranslation } from "../hooks/useTranslation";

const Home = () => {
  const { i18n, t } = useTranslation();
  return <div>{t(i18n.helloWorld)}</div>;
};

export default Home;

XLSX

Use this command to convert from Excel to JSON. Script is constantly watching your XLSX šŸ‘€, write I18n in Excel, see result instantly in your App.

$ yarn xlsx -t json -i ./examples/i18n.xlsx -o ./examples/i18n.json

Use this command to convert from JSON to Excel.

$ yarn xlsx -t xlsx  -i ./examples/i18n.json -o ./examples/i18n.xlsx

Licence (MIT)

Changelog

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago