Giter Site home page Giter Site logo

i18n's Introduction

Bit.I18N

Small internationalization module to localize strings in JavaScript

Usage

Download or clone the repo to get the i18n.js file, add it to your project and create a reference to it your bundles or pages.

Important

the values are case sensitive test is not the same as Test

Examples

getAll

Takes as optional argument the culture, if no argument is passed it returns all the resources

Throws an exception if the argument is not a string

Returns the collection of resources as a collection of Cultures which each has a collection of key value pairs with the localized strings

bitI18N.getAll();
bitI18N.getAll('es');
bitI18N.getAll('es-MX');

get

Takes as arguments:

  1. the key of the value to be found
  2. the culture of the value to be found (OPTIONAL), If the culture is not passed as argument, it will take the default browser culture

Throws an exception if:

  1. the argument key is not a string, is null or undefined
  2. the argument culture is not a string, is null or undefined

Returns a localized string if found in the culture, string not found otherwise

bitI18N.get('test'); // uses default browser culture
bitI18N.get('test', 'es');
bitI18N.get('test', 'es-MX');

setMany

Takes as arguments:

  1. a resources dictionaty

Throws an exception if:

  1. the value of any key is not a string, is null or undefined
bitI18N.setMany({
    es: {
        'Test': 'prueba'
    },
    en: {
        'Test': 'test'
    }
});

set

Takes as arguments:

  1. the culture of a localized resource
  2. the key of a localized resource
  3. the value of a localized resource

Throws an exception if:

  1. the argument culture is not a string, is null or undefined
  2. the argument key is not a string, is null or undefined
  3. the argument value is not a string, is null or undefined
bitI18N.set('es', 'test', 'Prueba');
bitI18N.set('en', 'test', 'Test');

i18n's People

Contributors

b1tf8er avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.