From cc06e0ff93b43472c331ad9c90840ee6d9fcb303 Mon Sep 17 00:00:00 2001 From: Colton Shaw <46071821+coltoneshaw@users.noreply.github.com> Date: Mon, 21 Jun 2021 05:51:11 -0400 Subject: [PATCH] Updated lanquage selectors and fixed traditional chinese (#598) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated lanquage selectors and fixed traditional chinese #448 - Modified the language selectors to remain the base language regardless of the translation. - Traditional Chinese also had the wrong code and the name/code swapped. * Removed the split on `-` This was causing an issue with Chinese traditional / simplified. * Updated supported lanquages for chinese removed `zh` and replaced it with `zh-cn`. Modified the supported languages to match the `navigator.language` for chinese. * Updated chinese lanquage codes Updated the Chinese language codes to match the rest of the language codes. * Fixing snapshots and fixing a deprecation problem Co-authored-by: Jesús Espino --- webapp/src/combinedProviders.tsx | 2 +- .../components/properties/user/user.test.tsx | 11 +++----- .../sidebarSettingsMenu.test.tsx.snap | 18 ++++++------- .../sidebar/sidebarSettingsMenu.tsx | 26 +++++++++---------- webapp/src/i18n.tsx | 8 +++--- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/webapp/src/combinedProviders.tsx b/webapp/src/combinedProviders.tsx index 9a20efd54..e5ffe08f4 100644 --- a/webapp/src/combinedProviders.tsx +++ b/webapp/src/combinedProviders.tsx @@ -22,7 +22,7 @@ const CombinedProviders = React.memo((props: Props): JSX.Element => { const {language, setLanguage, user} = props return ( diff --git a/webapp/src/components/properties/user/user.test.tsx b/webapp/src/components/properties/user/user.test.tsx index 4690ce116..01c2c88f2 100644 --- a/webapp/src/components/properties/user/user.test.tsx +++ b/webapp/src/components/properties/user/user.test.tsx @@ -3,7 +3,7 @@ import React from 'react' import {IntlProvider} from 'react-intl' -import {render, wait} from '@testing-library/react' +import {render, waitFor} from '@testing-library/react' import {act} from 'react-dom/test-utils' @@ -55,11 +55,10 @@ describe('components/properties/user', () => { ) let container - act(() => { + await waitFor(() => { const renderResult = render(component) container = renderResult.container }) - await wait() expect(container).toMatchSnapshot() }) @@ -74,11 +73,10 @@ describe('components/properties/user', () => { ) let container - act(() => { + await waitFor(() => { const renderResult = render(component) container = renderResult.container }) - await wait() expect(container).toMatchSnapshot() }) @@ -93,11 +91,10 @@ describe('components/properties/user', () => { ) let container: Element | DocumentFragment = {} as Element - act(() => { + await waitFor(() => { const renderResult = render(component) container = renderResult.container }) - await wait() if (container) { // this is the actual element where the click event triggers diff --git a/webapp/src/components/sidebar/__snapshots__/sidebarSettingsMenu.test.tsx.snap b/webapp/src/components/sidebar/__snapshots__/sidebarSettingsMenu.test.tsx.snap index c717fb2f3..64a9aa4e5 100644 --- a/webapp/src/components/sidebar/__snapshots__/sidebarSettingsMenu.test.tsx.snap +++ b/webapp/src/components/sidebar/__snapshots__/sidebarSettingsMenu.test.tsx.snap @@ -112,7 +112,7 @@ exports[`components/sidebar/SidebarSettingsMenu languages menu open should match
- German + Deutsch
- Japanese + 日本語
- French + Français
- Dutch + Nederlands
- Russian + Pусский
- Traditional Chinese + 中文 (繁體)
- Simplified Chinese + 中文 (简体)
- Turkish + Türkçe
{ { code: 'es', name: 'spanish', - displayName: 'Spanish', + displayName: 'Español', }, { code: 'de', name: 'german', - displayName: 'German', + displayName: 'Deutsch', }, { code: 'ja', name: 'japanese', - displayName: 'Japanese', + displayName: '日本語', }, { code: 'fr', name: 'french', - displayName: 'French', + displayName: 'Français', }, { code: 'nl', name: 'dutch', - displayName: 'Dutch', + displayName: 'Nederlands', }, { code: 'ru', name: 'russian', - displayName: 'Russian', + displayName: 'Pусский', }, { - code: 'chinese', - name: 'zh', - displayName: 'Traditional Chinese', + code: 'zh-cn', + name: 'chinese', + displayName: '中文 (繁體)', }, { - code: 'zh_Hans', + code: 'zh-tx', name: 'simplified-chinese', - displayName: 'Simplified Chinese', + displayName: '中文 (简体)', }, { code: 'tr', name: 'turkish', - displayName: 'Turkish', + displayName: 'Türkçe', }, { code: 'oc', @@ -160,7 +160,7 @@ const SidebarSettingsMenu = React.memo((props: Props) => { setLanguage(language.code)} rightIcon={intl.locale.toLowerCase() === language.code ? : null} /> diff --git a/webapp/src/i18n.tsx b/webapp/src/i18n.tsx index 5b255e825..bc2794171 100644 --- a/webapp/src/i18n.tsx +++ b/webapp/src/i18n.tsx @@ -13,7 +13,7 @@ import messages_tr from '../i18n/tr.json' import messages_zhHant from '../i18n/zh_Hant.json' import messages_zhHans from '../i18n/zh_Hans.json' -const supportedLanguages = ['de', 'fr', 'ja', 'nl', 'ru', 'es', 'oc', 'tr', 'zh', 'zh_Hant', 'zh_Hans'] +const supportedLanguages = ['de', 'fr', 'ja', 'nl', 'ru', 'es', 'oc', 'tr', 'zh-cn', 'zh-tw'] export function getMessages(lang: string): {[key: string]: string} { switch (lang) { @@ -33,11 +33,9 @@ export function getMessages(lang: string): {[key: string]: string} { return messages_oc case 'tr': return messages_tr - case 'zh': + case 'zh-cn': return messages_zhHant - case 'zh_Hant': - return messages_zhHant - case 'zh_Hans': + case 'zh-tw': return messages_zhHans } return messages_en