Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions scripts/build-intl-polyfills.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ import languages from '../src/frontend/languages.json' with {type: 'json'};
import messages from '../translations/messages.json' with {type: 'json'};

const relativeTimeFormatSupportedLocales = getSupportedLocalesFromDir(
path.dirname(fileURLToPath(import.meta.resolve('@formatjs/intl-relativetimeformat/polyfill-force.js'))),
path.dirname(
fileURLToPath(
import.meta
.resolve('@formatjs/intl-relativetimeformat/polyfill-force.js'),
),
),
);
const pluralRulesSupportedLocales = getSupportedLocalesFromDir(
path.dirname(fileURLToPath(import.meta.resolve('@formatjs/intl-pluralrules/polyfill-force.js'))),
path.dirname(
fileURLToPath(
import.meta.resolve('@formatjs/intl-pluralrules/polyfill-force.js'),
),
),
);

build();
Expand Down Expand Up @@ -46,7 +55,8 @@ function getPolyfillableLocales() {
const localesToPolyfill = [];

for (const locale of comapeoSupportedLocales) {
const canPolyfillLocale = isFullySupportedLocale(locale);
const baseTag = locale.split('-')[0];
const canPolyfillLocale = isFullySupportedLocale(baseTag);

if (!canPolyfillLocale) {
console.warn(`Cannot polyfill data for locale: ${locale}`);
Expand All @@ -73,9 +83,13 @@ function writePolyfillFile(locales, outputPath) {

// Write lines to load base polyfills
writer.write(
createImportStatement('@formatjs/intl-getcanonicallocales/polyfill-force.js'),
createImportStatement(
'@formatjs/intl-getcanonicallocales/polyfill-force.js',
),
);
writer.write(
createImportStatement('@formatjs/intl-locale/polyfill-force.js'),
);
writer.write(createImportStatement('@formatjs/intl-locale/polyfill-force.js'));

writer.write('\n');

Expand All @@ -85,15 +99,19 @@ function writePolyfillFile(locales, outputPath) {
);
for (const locale of locales) {
writer.write(
createImportStatement(`@formatjs/intl-pluralrules/locale-data/${locale}.js`),
createImportStatement(
`@formatjs/intl-pluralrules/locale-data/${locale}.js`,
),
);
}

writer.write('\n');

// Write lines to load relative time format polyfill
writer.write(
createImportStatement('@formatjs/intl-relativetimeformat/polyfill-force.js'),
createImportStatement(
'@formatjs/intl-relativetimeformat/polyfill-force.js',
),
);
for (const locale of locales) {
writer.write(
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/languages.json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to add "gu" and "gu-IN"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had gu-IN but I added gu

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@
"nativeName": "ဗမာစကာ",
"englishName": "Burmese"
},
"my-MM": {
"nativeName": "ဗမာစကာ",
"englishName": "Burmese (Myanmar)"
},
Comment on lines +594 to +597
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also add the one without the regional variant. For each one that has a regional variant we need to make sure it the one without the regional variant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already there:

  "my": {
    "nativeName": "ဗမာစကာ",
    "englishName": "Burmese"
  },

"mzr": {
"nativeName": "Marúbo",
"englishName": "Marubo"
Expand Down
Loading