Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.28 KB

File metadata and controls

57 lines (40 loc) · 1.28 KB

ziko-i18n

ziko-i18n banner

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 translation
    • setLang(lang, rtl = false) : change language globally

Usage

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 
    )
}

Features

  • Reactivity
  • Simple Architechture
  • No Nesting
  • No Wrapping components
  • Automatically updates lang attribut
  • Handle directions
  • Lightweight

Licence

This projet is licensed under the terms of MIT License