LanguagePolicy class

Language policy with fallback for each language as most specific to default en-us -> en -> default.

Extends

Map<string, string[]>

Constructors

LanguagePolicy(string[])

Initializes a new instance of the LanguagePolicy class.

Properties

locales
Map

Inherited Properties

size

Methods

defaultPolicy(string[])

Walk through all of the cultures and create a dictionary map with most specific to least specific.

Example

Example output "en-us" will generate fallback rule like this: "en-us" -> "en" -> "" "en" -> "" So that when we get a locale such as en-gb, we can try to resolve to "en-gb" then "en" then "" See commented section for full sample of output of this function.

Inherited Methods

clear()
delete(string)
entries()

Returns an iterable of key, value pairs for every entry in the map.

forEach((value: string[], key: string, map: Map<string, string[]>) => void, any)
get(string)
has(string)
keys()

Returns an iterable of keys in the map

set(string, string[])
values()

Returns an iterable of values in the map

Constructor Details

LanguagePolicy(string[])

Initializes a new instance of the LanguagePolicy class.

new LanguagePolicy(defaultLanguages: string[])

Parameters

defaultLanguages

string[]

Default languages to use.

Property Details

locales

static locales: string[]

Property Value

string[]

Map

static Map: MapConstructor

Property Value

MapConstructor

Inherited Property Details

size

size: number

Property Value

number

Inherited From Map.size

Method Details

defaultPolicy(string[])

Walk through all of the cultures and create a dictionary map with most specific to least specific.

Example

Example output "en-us" will generate fallback rule like this: "en-us" -> "en" -> "" "en" -> "" So that when we get a locale such as en-gb, we can try to resolve to "en-gb" then "en" then "" See commented section for full sample of output of this function.

static function defaultPolicy(defaultLanguages?: string[]): Map<string, string[]>

Parameters

defaultLanguages

string[]

Default languages to use.

Returns

Map<string, string[]>

A Map object with a string array for each key.

Inherited Method Details

clear()

function clear()

Inherited From Map.clear

delete(string)

function delete(key: string): boolean

Parameters

key

string

Returns

boolean

Inherited From Map.delete

entries()

Returns an iterable of key, value pairs for every entry in the map.

function entries(): IterableIterator<[string, string[]]>

Returns

IterableIterator<[string, string[]]>

Inherited From Map.entries

forEach((value: string[], key: string, map: Map<string, string[]>) => void, any)

function forEach(callbackfn: (value: string[], key: string, map: Map<string, string[]>) => void, thisArg?: any)

Parameters

callbackfn

(value: string[], key: string, map: Map<string, string[]>) => void

thisArg

any

Inherited From Map.forEach

get(string)

function get(key: string): string[] | undefined

Parameters

key

string

Returns

string[] | undefined

Inherited From Map.get

has(string)

function has(key: string): boolean

Parameters

key

string

Returns

boolean

Inherited From Map.has

keys()

Returns an iterable of keys in the map

function keys(): IterableIterator<string>

Returns

IterableIterator<string>

Inherited From Map.keys

set(string, string[])

function set(key: string, value: string[]): this

Parameters

key

string

value

string[]

Returns

this

Inherited From Map.set

values()

Returns an iterable of values in the map

function values(): IterableIterator<string[]>

Returns

IterableIterator<string[]>

Inherited From Map.values