Reactive internalization provider for zikojs
npm i ziko-i18n
createI18nProvider(lang, locals, target?): intitialize once.const [t, setLang] = useTranslation(): use anywherr, with :t(key): reactive translationsetLang(lang, rtl = false): change language globally
import { tags } from 'ziko/dom'
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
)
}- Reactivity
- Simple Architechture
- No Nesting
- No Wrapping components
- Automatically updates
langattribut - Handle directions
- Lightweight
This projet is licensed under the terms of MIT License