Skip to content

myTapp/localyze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

localyze

minimalist localization tool for both node.js and browser

supports multifile translation and model diff

npm i localyze
  • browser
import Localyze from 'localyze';
  • node
const Localyze = require('localyze');
  • quick-start
new Localyze({
    language: 'pt-br',
    translation: {
        'pt-br': 'pt-br/pt-br.json'
    },
    ready: ({ localyze }) => {
        console.log(localyze`input.invalid`);
    }
});
  • multifile example
new Localyze({
    language: 'pt-br',
    model: 'model.json',
    translation: {
        'pt-br': ['pt-br/login.json', 'pt-br/home.json'],
        'es-esp': ['es-esp/login.json', 'es-esp/home.json']
    },
    ready: ({ localyze }) => {
        console.log(localyze`input.invalid`);
    }
});
  • add new file to translation:
localyze.addTranslationFile('pt-br', 'pt-br/dashboard.json', (success) => {
    console.log(success);
});
  • transform output
localyze('input.valid', 'lower') // toLowerCase
localyze('input.warning', 'upper') // toUpperCase
localyze('input.error', 'capitalize') // Capitalize
localyze('input.error', 'title') // Capitalize Every Word