3.0.0 • Published 5 years ago

libj-culture-manager v3.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

libj-culture-manager

Part of libj tools

Supports these cultures: en (English), fa (Farsi), ar (Arabic), fr (French), de (German), es (Spanish), ru (Russian), tr (Turkish), ps (Pashto), ur (Urdu)

Usage (npm)

npm install libj-culture-manager
import 'libj-culture-manager'
//Now, cultureManager, validCultures are available globally

First set cultures (must be a subset of supported cultures above, or an exception will be thrown)

var cultures = ['en', 'fr', 'es']

cultureManager.setCultures(cultures)

Then set active culture of current page (default is en)

cultureManager.setActiveCulture('fr')

var activeCulture = cultureManager.getActiveCulture()
/*
returns an instance of Culture
{
    code: 'fr',
    name: 'Francias',
    direction: 'ltr',
    url: '/fr/<current_path>?<current_query_string>#<current_hash>' 
}
*/

Then define a fallback culture (default is en)

cultureManager.setFallbackCulture('es')

var fallbackCulture = cultureManager.getFallbackCulture()
/*
returns an instance of Culture
{
    code: 'es',
    name: 'Espanol',
    direction: 'ltr',
    url: '/es/<current_path>?<current_query_string>#<current_hash>' 
}
*/

Other methods_

var isSupported = cultureManager.isCultureSupported('af')
/* will throw and exception */

isSupported = cultureManager.isCultureSupported('ru')
/* returns true */

var all = cultureManager.getAllCultures();
/*
returns an array of Culture objects
[
    { 
        code: 'en', 
        name: 'English', 
        direction: 'ltr', 
        url: '/en/<current_path>?<current_query_string>#<current_hash>' 
    },
    {
        code: 'fa',
        name: 'فارسی',
        direction: 'rtl',
        url: '/fa/<current_path>?<current_query_string>#<current_hash>' 
    },
    .
    .
    .
]
*/

Test

  • Run this in a separate command line to start node server
node server.js
  • Run one of the following to re-create bundles
npm run dev
npm run dev:watch

Build

npm run build
npm run build:watch

Make sure to test everything in all browsers (specially IE 10/11)

3.0.0

5 years ago

2.0.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.6

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago