ziko-i18n
v1.0.1
Published
reactive i18n provider for zikojs
Readme
ziko-i18n
Reactive internalization provider for zikojs
Install
npm i ziko-i18n
API Design
createI18nProvider(lang, locals, target?): intitialize once.const [t, setLang] = useTranslation(): use anywherr, with :t(key): reactive translationsetLang(lang, rtl = false): change language globally
Usage
import { tags } from 'ziko/ui'
import {createI18NProvider, createI18NProvider} from 'ziko-i18n'
import locals from './locals.json'
createI18nProvider('en', locals)
const App = () =>{
const {div, p, button}= tags
const [t, setLang] = useTranslation();
return div(
p(t('p1')),
p(t('p2')),
button("EN").onClick(()=> setLang('en')),
button("FR").onClick(()=> setLang('fr')),
button("AR").onClick(()=> setLang('ar', true)) // true to make the the direction rtl
)
}Features
Reactivity
Simple Architechture
No Nesting
No Wrapping components
Automatically updates
langattributHandle directions
Lightweight
Licence
This projet is licensed under the terms of MIT License
