-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): i18n.loadLocaleData() is deprecated. Intl.PluralRules…
… used instead.
- Loading branch information
1 parent
637f5cf
commit fc638f5
Showing
28 changed files
with
272 additions
and
486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,39 @@ | ||
import React from 'react' | ||
import { getByText, render, act } from '@testing-library/react' | ||
import { i18n } from '@lingui/core' | ||
import { I18nProvider } from '@lingui/react' | ||
import { en, cs } from 'make-plural/plurals' | ||
import React from "react" | ||
import { getByText, render, act } from "@testing-library/react" | ||
import { i18n } from "@lingui/core" | ||
import { I18nProvider } from "@lingui/react" | ||
|
||
import { messages } from './locales/en/messages' | ||
import { messages as csMessages } from './locales/cs/messages' | ||
import App from './App' | ||
import { messages } from "./locales/en/messages" | ||
import { messages as csMessages } from "./locales/cs/messages" | ||
import App from "./App" | ||
|
||
i18n.load({ | ||
en: messages, | ||
cs: csMessages | ||
cs: csMessages, | ||
}) | ||
i18n.loadLocaleData({ | ||
en: { plurals: en }, | ||
cs: { plurals: cs } | ||
}); | ||
|
||
const TestingProvider = ({ children }: any) => ( | ||
<I18nProvider i18n={i18n}> | ||
{children} | ||
</I18nProvider> | ||
<I18nProvider i18n={i18n}>{children}</I18nProvider> | ||
) | ||
|
||
test('Test that lang is translated correctly in English' , () => { | ||
test("Test that lang is translated correctly in English", () => { | ||
act(() => { | ||
i18n.activate('en') | ||
i18n.activate("en") | ||
}) | ||
const { getByTestId, container } = render(<App />, { wrapper: TestingProvider }); | ||
expect(getByTestId('h3-title')).toBeInTheDocument() | ||
const { getByTestId, container } = render(<App />, { | ||
wrapper: TestingProvider, | ||
}) | ||
expect(getByTestId("h3-title")).toBeInTheDocument() | ||
expect(getByText(container, "Language switcher example:")).toBeDefined() | ||
}); | ||
}) | ||
|
||
test('Test that lang is translated correctly in Czech', () => { | ||
test("Test that lang is translated correctly in Czech", () => { | ||
act(() => { | ||
i18n.activate('cs') | ||
i18n.activate("cs") | ||
}) | ||
const { getByTestId, container } = render(<App />, { wrapper: TestingProvider }); | ||
expect(getByTestId('h3-title')).toBeInTheDocument() | ||
const { getByTestId, container } = render(<App />, { | ||
wrapper: TestingProvider, | ||
}) | ||
expect(getByTestId("h3-title")).toBeInTheDocument() | ||
expect(getByText(container, "Příklad přepínače jazyků:")).toBeDefined() | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.