({
lang,
extensions,
}: UnicodeLocaleId)
| 13 | } |
| 14 | |
| 15 | export function emitUnicodeLocaleId({ |
| 16 | lang, |
| 17 | extensions, |
| 18 | }: UnicodeLocaleId): string { |
| 19 | const chunks = [emitUnicodeLanguageId(lang)] |
| 20 | for (const ext of extensions) { |
| 21 | chunks.push(ext.type) |
| 22 | switch (ext.type) { |
| 23 | case 'u': |
| 24 | chunks.push( |
| 25 | ...ext.attributes, |
| 26 | ...ext.keywords.reduce((all: string[], kv) => all.concat(kv), []) |
| 27 | ) |
| 28 | break |
| 29 | case 't': |
| 30 | chunks.push( |
| 31 | emitUnicodeLanguageId(ext.lang), |
| 32 | ...ext.fields.reduce((all: string[], kv) => all.concat(kv), []) |
| 33 | ) |
| 34 | break |
| 35 | default: |
| 36 | chunks.push(ext.value) |
| 37 | break |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | return chunks.filter(Boolean).join('-') |
| 42 | } |
no test coverage detected