Skip to content

Commit 0d28995

Browse files
committed
Revert hopefully unnecessary changes
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent 64b9f7e commit 0d28995

File tree

10 files changed

+16
-41
lines changed

10 files changed

+16
-41
lines changed

documentation/frontend/reference/i18n.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ line arguments. There are three main modes of operation:
6969
empty, written to `untranslated-locales.json`.
7070

7171
- Pass the fallback locale mappings to the underlying Vue i18n plugin. This is
72-
configured in the plugin configuration file,
73-
`frontend/src/plugins/i18n.config.ts`.
72+
configured in the plugin configuration file, `frontend/src/i18n/vue-i18n.ts`.
7473

7574
## Test locales
7675

frontend/i18n/scripts/metadata.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export const getWpLocalesMetadata = async (
200200
* Some locales have custom pluralization rules that differ from the default
201201
* rules provided by Vue i18n. This function extracts the pluralization rules
202202
* from the locales metadata and logs them in a format that can be copied to
203-
* the `i18n.config.ts` settings file.
203+
* the `vue-i18n.ts` settings file.
204204
* There shouldn't be a need to update it often, but it's here for reference.
205205
* @param {import('./types').RawI18nLocaleProps[]} locales
206206
*/

frontend/i18n/scripts/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface RawI18nLocalePropsWithPlurals
1919
extends Omit<RawI18nLocaleProps, "nplurals" | "pluralExpression"> {
2020
nplurals: number
2121
/**
22-
* The plural expression used for custom pluralization, ee the `i18n.config.ts` settings file
22+
* The plural expression used for custom pluralization, ee the `vue-i18n.ts` settings file
2323
*/
2424
pluralExpression: string
2525
}

frontend/i18n/i18n.config.ts renamed to frontend/i18n/vue-i18n.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineI18nConfig } from "#imports"
22

3-
import localeFallback from "~~/i18n/locale-fallback.json"
3+
import localeFallback from "./locale-fallback.json"
44

55
import type { Locale } from "@intlify/core-base"
66

@@ -20,9 +20,7 @@ const custom5Rule = (n: number): number =>
2020
export default defineI18nConfig(() => ({
2121
globalInjection: true,
2222
fallbackLocale: localeFallback as { [x: string]: Locale[] },
23-
fallbackWarn: true,
24-
missingWarn: true,
25-
formatFallbackMessages: true,
23+
silentFallbackWarn: true,
2624
pluralizationRules: {
2725
ar: custom5Rule,
2826
arq: custom5Rule,

frontend/nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export default defineNuxtConfig({
128128
* */
129129
detectBrowserLanguage: false,
130130
trailingSlash: false,
131+
vueI18n: "./vue-i18n",
131132
},
132133
sentry: {
133134
sourceMapsUploadOptions: {

frontend/src/app.vue

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
computed,
44
onMounted,
55
useHead,
6-
useI18n,
76
useLocaleHead,
87
useRuntimeConfig,
98
} from "#imports"
@@ -67,21 +66,6 @@ useHead({
6766
onMounted(() => {
6867
updateBreakpoint()
6968
featureFlagStore.syncAnalyticsWithLocalStorage()
70-
console.log("i18n")
71-
const i18n = useI18n({ useScope: "global" })
72-
console.log(i18n)
73-
console.log(
74-
"available locales",
75-
i18n.availableLocales,
76-
JSON.stringify(i18n.availableLocales)
77-
)
78-
console.log("locale properties", i18n.localeProperties.value)
79-
console.log("locale", i18n.locale.value)
80-
console.log(
81-
"fallbackLocale",
82-
i18n.fallbackLocale.value,
83-
JSON.stringify(i18n.fallbackLocale.value)
84-
)
8569
})
8670
</script>
8771

frontend/src/components/meta/CustomButtonComponents.stories.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useI18n } from "#imports"
21
import { h } from "vue"
32

43
import VLoadMore from "~/components/VLoadMore.vue"
@@ -9,11 +8,6 @@ const Template: Story = {
98
render: (args) => ({
109
components: { VLoadMore },
1110
setup() {
12-
const i18n = useI18n({ useScope: "global" })
13-
console.log(i18n)
14-
console.log("locale properties", i18n.localeProperties.value)
15-
console.log("locale", i18n.locale.value)
16-
console.log("fallbackLocale", i18n.fallbackLocale.value)
1711
return () =>
1812
h("div", { class: "flex p-4", id: "wrapper" }, [
1913
h(VLoadMore, {

frontend/test/locales/ar.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,5 @@
557557
"collection.resultCountLabel.tag.audio.countMore": "Top {count} audio files with the selected tag",
558558
"collection.resultCountLabel.tag.image.zero": "لا صور مع العلامة المختارة",
559559
"collection.resultCountLabel.tag.image.count": "{count} {count} الصور مع علامة مختارة",
560-
"collection.resultCountLabel.tag.image.countMore": "Top {count} images with the selected tag",
561-
"theme.theme": "Theme"
560+
"collection.resultCountLabel.tag.image.countMore": "Top {count} images with the selected tag"
562561
}

frontend/test/playwright/e2e/translation-banner.spec.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
goToSearchTerm,
55
preparePageForTests,
66
} from "~~/test/playwright/utils/navigation"
7-
import { getLanguageSelect } from "~~/test/playwright/utils/components"
87

98
// Do not use one of the test locales, as those all have "complete" generated translations
109
const locale = "ru"
@@ -16,10 +15,9 @@ test.describe("translation banner", () => {
1615
test("Can see the translation banner and go to the correct link", async ({
1716
page,
1817
}) => {
19-
await goToSearchTerm(page, "dog")
20-
await getLanguageSelect(page).selectOption("ru")
21-
22-
await expect(page.locator("text= 100")).toBeVisible()
18+
await goToSearchTerm(page, "dog", { mode: "SSR", locale })
19+
await page.goto(localeSearchPath)
20+
await expect(page.locator("text= 100")).toBeVisible({ timeout: 500 })
2321

2422
await page.click("text=contributing a translation")
2523
await expect(page).toHaveURL(
@@ -32,14 +30,14 @@ test.describe("translation banner", () => {
3230
}) => {
3331
await preparePageForTests(page, "xl", { dismissBanners: true })
3432

35-
await page.goto(localeSearchPath)
33+
await goToSearchTerm(page, "dog", { mode: "SSR", locale })
3634
await expect(page.locator('[data-testid="banner-translation"]')).toBeHidden(
3735
{ timeout: 500 }
3836
)
3937
})
4038

4139
test("Can close the translation banner", async ({ page }) => {
42-
await page.goto(localeSearchPath)
40+
await goToSearchTerm(page, "dog", { mode: "SSR", locale })
4341
await page.click('[data-testid="banner-translation"] button:visible')
4442

4543
const banner = page.locator('.span:has-text("Help us get to 100 percent")')

frontend/test/playwright/utils/expect-snapshot.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "@playwright/test"
2-
import type { LanguageDirection } from "~~/test/playwright/utils/i18n"
2+
import { type LanguageDirection, t } from "~~/test/playwright/utils/i18n"
33
import { sleep } from "~~/test/playwright/utils/navigation"
44
import { getThemeSwitcher } from "~~/test/playwright/utils/components"
55

@@ -34,10 +34,12 @@ export type ExpectScreenshotAreaSnapshot = (
3434
) => Promise<void>
3535

3636
type EffectiveColorMode = "dark" | "light"
37+
const themeOption = (colorMode: EffectiveColorMode, dir: LanguageDirection) =>
38+
t(`theme.choices.${colorMode}`, dir)
3739

3840
export const turnOnDarkMode = async (page: Page, dir: LanguageDirection) => {
3941
const themeSwitcher = getThemeSwitcher(page, dir)
40-
await themeSwitcher.selectOption("dark")
42+
await themeSwitcher.selectOption(themeOption("dark", dir))
4143
await expect(themeSwitcher).toHaveValue("dark")
4244
}
4345

0 commit comments

Comments
 (0)