libj-culture-manager
v3.0.0
Published
Part of libj tools
Downloads
4
Readme
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
- Navigate to http://localhost:3000
Build
npm run build
npm run build:watch