1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-07 21:23:00 +03:00

Fall back to untranslated string rather than showing missing translation error (#8609)

This commit is contained in:
James Salter
2022-05-16 13:28:24 +01:00
committed by GitHub
parent fb30b67b14
commit fcc4d62ede
4 changed files with 45 additions and 10 deletions

View File

@@ -32,7 +32,7 @@ exports[`KeyboardShortcut doesn't render same modifier twice 1`] = `
>
<kbd>
missing translation: en|Ctrl
Ctrl
</kbd>
+
@@ -70,7 +70,7 @@ exports[`KeyboardShortcut doesn't render same modifier twice 2`] = `
>
<kbd>
missing translation: en|Ctrl
Ctrl
</kbd>
+
@@ -95,7 +95,7 @@ exports[`KeyboardShortcut renders alternative key name 1`] = `
>
<kbd>
missing translation: en|Page Down
Page Down
</kbd>
+

View File

@@ -8,7 +8,7 @@ exports[`KeyboardUserSettingsTab renders list of keyboard shortcuts 1`] = `
<div
className="mx_SettingsTab_heading"
>
missing translation: en|Keyboard
Keyboard
</div>
<KeyboardShortcutSection
category={
@@ -30,7 +30,7 @@ exports[`KeyboardUserSettingsTab renders list of keyboard shortcuts 1`] = `
<div
className="mx_SettingsTab_subheading"
>
missing translation: en|Composer
Composer
</div>
<div>
@@ -59,7 +59,7 @@ exports[`KeyboardUserSettingsTab renders list of keyboard shortcuts 1`] = `
>
<kbd>
missing translation: en|Ctrl
Ctrl
</kbd>
+
@@ -103,7 +103,7 @@ exports[`KeyboardUserSettingsTab renders list of keyboard shortcuts 1`] = `
>
<kbd>
missing translation: en|Ctrl
Ctrl
</kbd>
+
@@ -145,7 +145,7 @@ exports[`KeyboardUserSettingsTab renders list of keyboard shortcuts 1`] = `
<div
className="mx_SettingsTab_subheading"
>
missing translation: en|Navigation
Navigation
</div>
<div>
@@ -173,7 +173,7 @@ exports[`KeyboardUserSettingsTab renders list of keyboard shortcuts 1`] = `
>
<kbd>
missing translation: en|Enter
Enter
</kbd>
</KeyboardKey>

View File

@@ -27,6 +27,10 @@ import {
import { stubClient } from '../test-utils';
describe('languageHandler', function() {
/*
See /__mocks__/browser-request.js/ for how we are stubbing out translations
to provide fixture data for these tests
*/
const basicString = 'Rooms';
const selfClosingTagSub = 'Accept <policyLink /> to continue:';
const textInTagSub = '<a>Upgrade</a> to your own domain';
@@ -35,6 +39,7 @@ describe('languageHandler', function() {
type TestCase = [string, string, Record<string, unknown>, Record<string, unknown>, TranslatedString];
const testCasesEn: TestCase[] = [
// description of the test case, translationString, variables, tags, expected result
['translates a basic string', basicString, {}, undefined, 'Rooms'],
[
'handles plurals when count is 0',
@@ -217,4 +222,17 @@ describe('languageHandler', function() {
});
});
});
describe('when languages dont load', () => {
it('_t', async () => {
const STRING_NOT_IN_THE_DICTIONARY = "a string that isn't in the translations dictionary";
expect(_t(STRING_NOT_IN_THE_DICTIONARY, {}, undefined)).toEqual(STRING_NOT_IN_THE_DICTIONARY);
});
it('_tDom', async () => {
const STRING_NOT_IN_THE_DICTIONARY = "a string that isn't in the translations dictionary";
expect(_tDom(STRING_NOT_IN_THE_DICTIONARY, {}, undefined)).toEqual(
<span lang="en">{ STRING_NOT_IN_THE_DICTIONARY }</span>);
});
});
});