Skip to content
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

Add react-i18next for multi-language support #917

Merged
merged 28 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9c28260
Proof-of-concept initial commit for i18n
keichan34 Aug 8, 2024
da2efe1
Add language switcher, locale file generation process
keichan34 Aug 8, 2024
903aac7
Add more Japanese translations
keichan34 Aug 14, 2024
097204f
Fix E2E tests
keichan34 Aug 14, 2024
3d36e71
Update Japanese translation
sanak Aug 14, 2024
237d54a
Review fixes
keichan34 Aug 14, 2024
69383e7
Review fixes
keichan34 Aug 14, 2024
38a195b
Review fixes - rename I prefix to ~Internal postfix
keichan34 Aug 14, 2024
7e721ca
Add simple i18n switcher test
keichan34 Aug 14, 2024
3a6eff1
Merge pull request #1 from sanak/update-locales-ja-2024081401
keichan34 Aug 14, 2024
52ccd77
Add more translatable strings (translations to come later)
keichan34 Aug 15, 2024
0970145
Add more translatable strings
keichan34 Aug 15, 2024
e4a566b
Finish up strings
keichan34 Aug 15, 2024
69f0acd
Initial RTL support
keichan34 Aug 15, 2024
ff8fd41
Update Hebrew translation.json
HarelM Aug 15, 2024
b6f75a1
Apply suggestions from code review
HarelM Aug 15, 2024
7014f1d
Review comment: refactor to minimize Trans component
keichan34 Aug 19, 2024
a5742b8
Add comment about eslint disable lines
keichan34 Aug 19, 2024
0e4c831
Review comment: Fix import name of DataProperty
keichan34 Aug 19, 2024
cc9fb15
Review comment: make style spec labels non-translatable (will be hand…
keichan34 Aug 19, 2024
5735a7c
Review comment: Refactor to i18nProps
keichan34 Aug 19, 2024
b507f61
Review comment: Reduce duplication in ModalSourcesTypeEditor
keichan34 Aug 19, 2024
4d38c21
Review comment: English default; remove English translation files
keichan34 Aug 19, 2024
e00badd
Finish Japanese translations
keichan34 Aug 19, 2024
3dcfa25
Fix errors and warning when switching between languages
keichan34 Aug 19, 2024
13d0b04
Attempt to fix Firefox E2E test by upgrading cypress
keichan34 Aug 19, 2024
9fd292c
Log missing translations
keichan34 Aug 19, 2024
12f870a
Remove ModalSurvey and references
keichan34 Aug 19, 2024
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
35 changes: 35 additions & 0 deletions cypress/e2e/i18n.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { MaputnikDriver } from "./maputnik-driver";

describe("i18n", () => {
let { beforeAndAfter, get, when, then } = new MaputnikDriver();
beforeAndAfter();

describe("language detector", () => {
it("English", () => {
const url = "?lng=en";
when.visit(url);
then(get.elementByTestId("maputnik-lang-select")).shouldHaveValue("en");
});

it("Japanese", () => {
const url = "?lng=ja";
when.visit(url);
then(get.elementByTestId("maputnik-lang-select")).shouldHaveValue("ja");
});
});

describe("language switcher", () => {
beforeEach(() => {
when.setStyle("layer");
});

it("the language switcher switches to Japanese", () => {
const selector = "maputnik-lang-select";
then(get.elementByTestId(selector)).shouldExist();
when.select(selector, "ja");
then(get.elementByTestId(selector)).shouldHaveValue("ja");

then(get.elementByTestId("nav:settings")).shouldHaveText("スタイル設定");
});
});
});
4 changes: 3 additions & 1 deletion cypress/e2e/maputnik-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ export class MaputnikDriver {
this.helper.when.acceptConfirm();
}
// when methods should not include assertions
this.helper.get.elementByTestId("toolbar:link").should("be.visible");
const toolbarLink = this.helper.get.elementByTestId("toolbar:link")
toolbarLink.scrollIntoView();
toolbarLink.should("be.visible");
},

typeKeys: (keys: string) => this.helper.get.element("body").type(keys),
Expand Down
17 changes: 17 additions & 0 deletions i18next-parser.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
output: 'src/locales/$LOCALE/$NAMESPACE.json',
locales: [ 'ja', 'he' ],

// Because some keys are dynamically generated, i18next-parser can't detect them.
// We add these keys manually, so we don't want to remove them.
keepRemoved: true,

// We use plain English keys, so we disable key and namespace separators.
keySeparator: false,
namespaceSeparator: false,

defaultValue: (locale, ns, key) => {
// The default value is a string that indicates that the string is not translated.
return '__STRING_NOT_TRANSLATED__';
HarelM marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading
Loading