# libj-culture-manager

> Part of libj tools

Latest version **3.0.0** (published 2019-08-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install libj-culture-manager
pnpm add libj-culture-manager
yarn add libj-culture-manager
bun add libj-culture-manager
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2019-08-17 |
| First published | 2019-08-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 528.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | saeidfarahi |

## Links

- npm: https://www.npmjs.com/package/libj-culture-manager
- Repository: https://github.com/saeidjoker/libj-culture-manager
- Homepage: https://github.com/saeidjoker/libj-culture-manager#readme
- Issues: https://github.com/saeidjoker/libj-culture-manager/issues
- npm.io page: https://npm.io/package/libj-culture-manager

## Dependencies (2)

- [core-js](https://npm.io/package/core-js.md) ^3.2.1
- [libj-url](https://npm.io/package/libj-url.md) ^1.4.1

## Recent versions

- 3.0.0 (latest) — 2019-08-17
- 2.0.0 — 2019-08-17
- 1.3.0 — 2019-08-17
- 1.2.0 — 2019-08-17
- 1.1.1 — 2019-08-15
- 1.1.0 — 2019-08-15
- 1.0.6 — 2019-08-15
- 1.0.4 — 2019-08-10
- 1.0.3 — 2019-08-10
- 1.0.2 — 2019-08-09
- 1.0.1 — 2019-08-09

## 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
```

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

---
_Source: https://npm.io/package/libj-culture-manager · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
