Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
keichan34 committed Aug 20, 2024
2 parents 82b6977 + 58edd26 commit d289849
Show file tree
Hide file tree
Showing 55 changed files with 2,338 additions and 506 deletions.
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__';
}
}
Loading

0 comments on commit d289849

Please sign in to comment.