@brightspace-ui/intl 3.33.1 → 3.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/common.js CHANGED
@@ -5,31 +5,31 @@ export const supportedBaseLocales = ['ar', 'cy', 'da', 'de', 'en', 'es', 'fr', '
5
5
  export const supportedLangpacks = ['ar', 'cy', 'da', 'de', 'en', 'en-gb', 'es', 'es-es', 'fr', 'fr-fr', 'fr-on', 'haw', 'hi', 'ja', 'ko', 'mi', 'nl', 'pt', 'sv', 'th', 'tr', 'vi', 'zh-cn', 'zh-tw'];
6
6
 
7
7
  export const supportedLocalesDetails = [
8
- { code: 'ar-sa', dir: 'rtl', name: 'العربية (المملكة العربية السعودية)' },
9
- { code: 'cy-gb', dir: 'ltr', name: 'Cymraeg (Y Deyrnas Unedig)' },
10
- { code: 'da-dk', dir: 'ltr', name: 'Dansk (danmark)' },
11
- { code: 'de-de', dir: 'ltr', name: 'Deutsch (Deutschland)' },
12
- { code: 'en-ca', dir: 'ltr', name: 'English (Canada)' },
13
- { code: 'en-gb', dir: 'ltr', name: 'English (United Kingdom)' },
14
- { code: 'en-us', dir: 'ltr', name: 'English (United States)' },
15
- { code: 'es-es', dir: 'ltr', name: 'Español (España)' },
16
- { code: 'es-mx', overrideCode: 'es-419', dir: 'ltr', name: 'Español (Latinoamérica)' },
17
- { code: 'fr-ca', dir: 'ltr', name: 'Français (Canada)' },
18
- { code: 'fr-fr', dir: 'ltr', name: 'Français (France)' },
19
- { code: 'fr-on', overrideCode: 'fr-CA-Ontario', dir: 'ltr', name: 'Français (Ontario)' },
20
- { code: 'haw-us', dir: 'ltr', name: 'ʻŌlelo Hawaiʻi (ʻAmelika Hui Pū ʻIa)' },
21
- { code: 'hi-in', dir: 'ltr', name: 'हिंदी (भारत)' },
22
- { code: 'ja-jp', dir: 'ltr', name: '日本語 (日本)' },
23
- { code: 'ko-kr', dir: 'ltr', name: '한국어 (대한민국)' },
24
- { code: 'mi-nz', dir: 'ltr', name: 'Māori (Aotearoa)' },
25
- { code: 'nl-nl', dir: 'ltr', name: 'Nederlands (Nederland)' },
26
- { code: 'pt-br', dir: 'ltr', name: 'Português (Brasil)' },
27
- { code: 'sv-se', dir: 'ltr', name: 'Svenska (Sverige)' },
28
- { code: 'th-th', dir: 'ltr', name: 'ไทย (ไทย)' },
29
- { code: 'tr-tr', dir: 'ltr', name: 'Türkçe (Türkiye)' },
30
- { code: 'vi-vn', dir: 'ltr', name: 'Tiếng Việt (Việt Nam)' },
31
- { code: 'zh-cn', overrideCode: 'zh-Hans', dir: 'ltr', name: '中文(简体)' },
32
- { code: 'zh-tw', overrideCode: 'zh-Hant', dir: 'ltr', name: '中文(繁体)' }
8
+ { id: 16, code: 'ar-sa', pack: 'ar', dir: 'rtl', name: 'العربية (المملكة العربية السعودية)' },
9
+ { id: 31, code: 'cy-gb', pack: 'cy', dir: 'ltr', name: 'Cymraeg (Y Deyrnas Unedig)' },
10
+ { id: 28, code: 'da-dk', pack: 'da', dir: 'ltr', name: 'Dansk (danmark)' },
11
+ { id: 26, code: 'de-de', pack: 'de', dir: 'ltr', name: 'Deutsch (Deutschland)' },
12
+ { id: 13, code: 'en-ca', dir: 'ltr', name: 'English (Canada)' },
13
+ { id: 11, code: 'en-gb', pack: 'en-gb', dir: 'ltr', name: 'English (United Kingdom)' },
14
+ { id: 1, code: 'en-us', pack: 'en', dir: 'ltr', name: 'English (United States)' },
15
+ { id: 30, code: 'es-es', pack: 'es-es', dir: 'ltr', name: 'Español (España)' },
16
+ { id: 18, code: 'es-mx', pack: 'es', overrideCode: 'es-419', dir: 'ltr', name: 'Español (Latinoamérica)' },
17
+ { id: 2, code: 'fr-ca', pack: 'fr', dir: 'ltr', name: 'Français (Canada)' },
18
+ { id: 29, code: 'fr-fr', pack: 'fr-fr', dir: 'ltr', name: 'Français (France)' },
19
+ { id: 32, code: 'fr-on', pack: 'fr-on', overrideCode: 'fr-CA-Ontario', dir: 'ltr', name: 'Français (Ontario)' },
20
+ { id: 35, code: 'haw-us', pack: 'haw', dir: 'ltr', name: 'ʻŌlelo Hawaiʻi (ʻAmelika Hui Pū ʻIa)' },
21
+ { id: 33, code: 'hi-in', pack: 'hi', dir: 'ltr', name: 'हिंदी (भारत)' },
22
+ { id: 21, code: 'ja-jp', pack: 'ja', dir: 'ltr', name: '日本語 (日本)' },
23
+ { id: 22, code: 'ko-kr', pack: 'ko', dir: 'ltr', name: '한국어 (대한민국)' },
24
+ { id: 34, code: 'mi-nz', pack: 'mi', dir: 'ltr', name: 'Māori (Aotearoa)' },
25
+ { id: 25, code: 'nl-nl', pack: 'nl', dir: 'ltr', name: 'Nederlands (Nederland)' },
26
+ { id: 19, code: 'pt-br', pack: 'pt', dir: 'ltr', name: 'Português (Brasil)' },
27
+ { id: 24, code: 'sv-se', pack: 'sv', dir: 'ltr', name: 'Svenska (Sverige)' },
28
+ { id: 37, code: 'th-th', pack: 'th', dir: 'ltr', name: 'ไทย (ไทย)' },
29
+ { id: 23, code: 'tr-tr', pack: 'tr', dir: 'ltr', name: 'Türkçe (Türkiye)' },
30
+ { id: 36, code: 'vi-vn', pack: 'vi', dir: 'ltr', name: 'Tiếng Việt (Việt Nam)' },
31
+ { id: 17, code: 'zh-cn', pack: 'zh-cn', overrideCode: 'zh-Hans', dir: 'ltr', name: '中文(简体)' },
32
+ { id: 20, code: 'zh-tw', pack: 'zh-tw', overrideCode: 'zh-Hant', dir: 'ltr', name: '中文(繁体)' }
33
33
  ];
34
34
  export const supportedLocales = supportedLocalesDetails.map((l) => l.code);
35
35
 
package/lib/localize.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import './PluralRules.js';
2
- import { defaultLocale as fallbackLang, getDocumentLocaleSettings, supportedLangpacks } from './common.js';
2
+ import { defaultLocale as fallbackLang, getDocumentLocaleSettings, supportedLangpacks, supportedLocalesDetails } from './common.js';
3
3
  import { getLocalizeOverrideResources } from '../helpers/getLocalizeResources.js';
4
4
  import IntlMessageFormat from 'intl-messageformat';
5
5
 
@@ -220,18 +220,32 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
220
220
 
221
221
  if (importFunc === undefined) return;
222
222
 
223
+ // en-ca does not have an actual langpack, but supports overrides, so mark its usage
224
+ const enCA = langs.includes('en-ca') && langs.indexOf('en-ca') <= Math.max(langs.indexOf('en-us'), 0);
225
+
223
226
  // in dev, don't request unsupported langpacks
224
227
  if (!importFunc.toString().includes('switch') && !useBrowserLangs) {
225
228
  langs = langs.filter(lang => supportedLangpacks.includes(lang));
226
229
  }
227
230
 
228
231
  for (const lang of [...langs, fallbackLang]) {
229
-
230
232
  const resources = await Promise.resolve(importFunc(lang)).catch(() => {});
231
233
 
234
+ const osloLang = lang === 'en' && enCA ? 'en-ca' : lang;
235
+
232
236
  if (resources) {
233
237
 
234
238
  if (osloCollection) {
239
+ const oslo = this.documentLocaleSettings.oslo;
240
+ let languageId = 0;
241
+ if (oslo.batch) {
242
+ const batch = new URL(oslo.batch, document.location.origin);
243
+ languageId = supportedLocalesDetails.find(l => l.code === osloLang || l.pack === osloLang)?.id;
244
+ if (languageId && languageId !== batch.searchParams.get('languageId')) {
245
+ batch.searchParams.set('languageId', languageId);
246
+ oslo.batch = batch.toString();
247
+ }
248
+ }
235
249
  return await getLocalizeOverrideResources(
236
250
  lang,
237
251
  resources,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/intl",
3
- "version": "3.33.1",
3
+ "version": "3.34.0",
4
4
  "description": "Internationalization APIs for number, date, time and file size formatting and parsing in D2L Brightspace.",
5
5
  "main": "lib/number.js",
6
6
  "type": "module",