Skip to content

kevinmartin/L10n.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

L10n.js

Build Status

Localization (L10n) mapping and information with support for over 140 localizations.

Information provided by script includes language fallbacks, language name and locale name, text direction (ltr or rtl), and character set (charset).

Including L10n.js (in the browser)

<script src="L10n.js"></script>

Including L10n.js (in NodeJS or RequireJS)

var L10n = require('L10n');

Usage

var locale = new L10n('spa');

locale.get(); // 'spa'
locale.set('eng');
locale.get(); // 'eng'

locale.map('eng'); // 'en'
locale.map('fre'); // 'fr'
locale.map('spa'); // 'sp'

locale.info(); // {language: 'English (United States)', locale: 'eng', fallback: 'eng', charset: 'utf-8', direction: 'ltr'}
locale.info('en_us'); // {language: 'English (United States)', locale: 'en_us', fallback: 'eng', charset: 'utf-8', direction: 'ltr'}

// Some variations for country-level language codes
locale.info('en_us');
locale.info('en_US');
locale.info('en-us');
locale.info('EN-US');

// Information given by L10n.prototype.info(...);
locale.info('en_us').language // 'English (United States)'
locale.info('en_us').locale // 'en_us'
locale.info('en_us').fallback // 'eng'
locale.info('en_us').charset // 'utf-8'
locale.info('en_us').direction // 'ltr'

About

Localization (L10n) mapping and information

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published