next-locale-database
v0.1.5-rc6
Published
Get locale string from a string mapping next/router.
Downloads
6
Maintainers
Readme
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