Function: normalizeLocale()
normalizeLocale(
tag):string|undefined
Give the canonical BCP 47 form of a language tag (zh-cn gives zh-CN, iw gives he). The POSIX locales of the environment are converted: their encoding and modifier dropped, _ replaced by - (zh_CN.UTF-8 gives zh-CN, en_US@euro gives en-US).
Parameters
tag
string
The tag; surrounding spaces are ignored.
Returns
string | undefined
The canonical tag; undefined for an invalid tag, a tag whose language is not 2 or 3 letters, C, POSIX, * and the empty string.
Example
typescript
import {normalizeLocale} from 'lakutata/com/i18n'
console.log(normalizeLocale('zh_CN.UTF-8')) //zh-CN
console.log(normalizeLocale('zh-hant-tw')) //zh-Hant-TW
console.log(normalizeLocale('C')) //undefined