Skip to content

feat: add Vietnamese language support #821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/i18n/countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import plLocale from 'i18n-iso-countries/langs/pl.json';
import ptLocale from 'i18n-iso-countries/langs/pt.json';
import ruLocale from 'i18n-iso-countries/langs/ru.json';
import ukLocale from 'i18n-iso-countries/langs/uk.json';
import viLocale from 'i18n-iso-countries/langs/vi.json';

import { getPrimaryLanguageSubtag } from './lib';

Expand All @@ -39,6 +40,7 @@ COUNTRIES.registerLocale(ptLocale);
COUNTRIES.registerLocale(ruLocale);
// COUNTRIES.registerLocale(thLocale); // Doesn't exist in lib.
COUNTRIES.registerLocale(ukLocale);
COUNTRIES.registerLocale(viLocale);

/**
* Provides a lookup table of country IDs to country names for the current locale.
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '@formatjs/intl-pluralrules/locale-data/pt';
import '@formatjs/intl-pluralrules/locale-data/ru';
import '@formatjs/intl-pluralrules/locale-data/th';
import '@formatjs/intl-pluralrules/locale-data/uk';
import '@formatjs/intl-pluralrules/locale-data/vi';

import '@formatjs/intl-relativetimeformat/polyfill';
import '@formatjs/intl-relativetimeformat/locale-data/ar';
Expand All @@ -33,6 +34,7 @@ import '@formatjs/intl-relativetimeformat/locale-data/pt';
import '@formatjs/intl-relativetimeformat/locale-data/ru';
import '@formatjs/intl-relativetimeformat/locale-data/th';
import '@formatjs/intl-relativetimeformat/locale-data/uk';
import '@formatjs/intl-relativetimeformat/locale-data/vi';

const cookies = new Cookies();
const supportedLocales = [
Expand All @@ -51,7 +53,8 @@ const supportedLocales = [
'pt-br', // Portuguese (Brazil)
'ru', // Russian
'th', // Thai
'uk', // Ukrainian
'uk', // Ukrainian,
'vi', // Vietnamese
];
const rtlLocales = [
'ar', // Arabic
Expand Down Expand Up @@ -220,6 +223,7 @@ const messagesShape = {
ru: PropTypes.objectOf(PropTypes.string), // Russian
th: PropTypes.objectOf(PropTypes.string), // Thai
uk: PropTypes.objectOf(PropTypes.string), // Ukrainian
vi: PropTypes.objectOf(PropTypes.string), // Vietnamese
};

const optionsShape = {
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/lib.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('lib', () => {
messages: {},
});

expect(console.warn).toHaveBeenCalledTimes(15);
expect(console.warn).toHaveBeenCalledTimes(16);
expect(console.warn).toHaveBeenCalledWith('Missing locale: ar');
expect(console.warn).toHaveBeenCalledWith('Missing locale: es-419');
expect(console.warn).toHaveBeenCalledWith('Missing locale: fr');
Expand All @@ -94,6 +94,7 @@ describe('lib', () => {
expect(console.warn).toHaveBeenCalledWith('Missing locale: ru');
expect(console.warn).toHaveBeenCalledWith('Missing locale: th');
expect(console.warn).toHaveBeenCalledWith('Missing locale: uk');
expect(console.warn).toHaveBeenCalledWith('Missing locale: vi');
});
});

Expand Down Expand Up @@ -198,6 +199,7 @@ describe('lib', () => {
expect(isRtl('es-419')).toBe(false);
expect(isRtl('de')).toBe(false);
expect(isRtl('ru')).toBe(false);
expect(isRtl('vi')).toBe(false);
});
});

Expand Down