Skip to content

zikojs/ziko-i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Reactive internalization provider for zikojs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Generated from zikojs/addons-template