Skip to content

kpwzto/next-locale-database

Repository files navigation

Next locale database

Installation

Get the latest version by NPM:

$ npm install next-locale-database

Get the latest version by yarn:

$ yarn add next-locale-database

Usage

Use hook

Import next-locale-database:

import useLocale from "next-locale-database";

And use hook in your function component:

  const {getLang} =  useLocale();

Get locale string in your component

  <Component>
    { getLang('{"en": "Example", "vi", "Ví dụ"}') }
  </Component>

Get locale string in your component with force a language

  <Component>
    { getLang('{"en": "Example", "vi", "Ví dụ"}', 'vi') } // Return: Ví dụ
  </Component>

License

MIT license. © kpwzto

About

Get string locale with json type get from database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published