Skip to content

Commit b95237f

Browse files
authored
refactor: move locales folder (#3374)
* chore: move locales out * fix: correct import * move generate local script
1 parent d182528 commit b95237f

File tree

161 files changed

+106
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+106
-104
lines changed

apps/desktop/configs/vite.render.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const viteRenderBaseConfig = {
3535
alias: {
3636
"~": resolve("src/renderer/src"),
3737
"@pkg": resolve("package.json"),
38-
"@locales": resolve("locales"),
38+
"@locales": resolve("../../locales"),
3939
"@follow/electron-main": resolve("src/main/src"),
4040
},
4141
},

apps/desktop/electron.vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default defineConfig({
1919
alias: {
2020
"@shared": resolve("packages/shared/src"),
2121
"@pkg": resolve("./package.json"),
22-
"@locales": resolve("./locales"),
22+
"@locales": resolve("../../locales"),
2323
"~": resolve("./src/main/src"),
2424
},
2525
},
@@ -38,7 +38,7 @@ export default defineConfig({
3838
resolve: {
3939
alias: {
4040
"@pkg": resolve("./package.json"),
41-
"@locales": resolve("./locales"),
41+
"@locales": resolve("../../locales"),
4242
},
4343
},
4444
},

apps/desktop/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"dev:electron": "electron-vite dev",
2929
"dev:server": "pnpm run --filter=ssr dev",
3030
"dev:web": "cross-env WEB_BUILD=1 vite",
31-
"generator:i18n-template": "tsx scripts/generate-i18n-locale.ts",
3231
"publish": "electron-vite build && electron-forge publish",
3332
"start": "electron-vite preview",
3433
"update:main-hash": "tsx plugins/vite/generate-main-hash.ts"

apps/desktop/plugins/vite/locales.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function localesPlugin(): Plugin {
1212
generateBundle(_options, bundle) {
1313
const __dirname = dirname(fileURLToPath(import.meta.url))
1414

15-
const localesDir = path.resolve(__dirname, "../../locales")
15+
const localesDir = path.resolve(__dirname, "../../../../locales")
1616

1717
const namespaces = fs.readdirSync(localesDir).filter((dir) => dir !== ".DS_Store")
1818
const languageResources = {} as any

apps/desktop/plugins/vite/utils/i18n-completeness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ function calculateCompleteness(localesDir: string): LanguageCompletion {
5858
}
5959
const __dirname = dirname(fileURLToPath(import.meta.url))
6060

61-
const i18n = calculateCompleteness(path.resolve(__dirname, "../../../locales"))
61+
const i18n = calculateCompleteness(path.resolve(__dirname, "../../../../../locales"))
6262
export default i18n

apps/desktop/src/main/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"baseUrl": ".",
1414
"paths": {
1515
"@pkg": ["../../package.json"],
16-
"@locales/*": ["../../locales/*"],
16+
"@locales/*": ["../../../../locales/*"],
1717
"~/*": ["./src/*"]
1818
}
1919
}

apps/desktop/src/renderer/src/@types/default-resource.ts

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
// This file is auto-generated by scripts/generate-i18n-locale.ts
22
// DONT EDIT THIS FILE MANUALLY
3-
import en from "../../../../locales/app/en.json"
4-
import common_ardz from "../../../../locales/common/ar-DZ.json"
5-
import common_ariq from "../../../../locales/common/ar-IQ.json"
6-
import common_arkw from "../../../../locales/common/ar-KW.json"
7-
import common_arma from "../../../../locales/common/ar-MA.json"
8-
import common_arsa from "../../../../locales/common/ar-SA.json"
9-
import common_artn from "../../../../locales/common/ar-TN.json"
10-
import common_de from "../../../../locales/common/de.json"
11-
import common_en from "../../../../locales/common/en.json"
12-
import common_es from "../../../../locales/common/es.json"
13-
import common_fi from "../../../../locales/common/fi.json"
14-
import common_fr from "../../../../locales/common/fr.json"
15-
import common_it from "../../../../locales/common/it.json"
16-
import common_ja from "../../../../locales/common/ja.json"
17-
import common_ko from "../../../../locales/common/ko.json"
18-
import common_pt from "../../../../locales/common/pt.json"
19-
import common_ru from "../../../../locales/common/ru.json"
20-
import common_tr from "../../../../locales/common/tr.json"
21-
import common_zhCN from "../../../../locales/common/zh-CN.json"
22-
import common_zhHK from "../../../../locales/common/zh-HK.json"
23-
import common_zhTW from "../../../../locales/common/zh-TW.json"
24-
import errors_en from "../../../../locales/errors/en.json"
25-
import external_en from "../../../../locales/external/en.json"
26-
import lang_ardz from "../../../../locales/lang/ar-DZ.json"
27-
import lang_ariq from "../../../../locales/lang/ar-IQ.json"
28-
import lang_arkw from "../../../../locales/lang/ar-KW.json"
29-
import lang_arma from "../../../../locales/lang/ar-MA.json"
30-
import lang_arsa from "../../../../locales/lang/ar-SA.json"
31-
import lang_artn from "../../../../locales/lang/ar-TN.json"
32-
import lang_de from "../../../../locales/lang/de.json"
33-
import lang_en from "../../../../locales/lang/en.json"
34-
import lang_es from "../../../../locales/lang/es.json"
35-
import lang_fi from "../../../../locales/lang/fi.json"
36-
import lang_fr from "../../../../locales/lang/fr.json"
37-
import lang_it from "../../../../locales/lang/it.json"
38-
import lang_ja from "../../../../locales/lang/ja.json"
39-
import lang_ko from "../../../../locales/lang/ko.json"
40-
import lang_pt from "../../../../locales/lang/pt.json"
41-
import lang_ru from "../../../../locales/lang/ru.json"
42-
import lang_tr from "../../../../locales/lang/tr.json"
43-
import lang_zhCN from "../../../../locales/lang/zh-CN.json"
44-
import lang_zhHK from "../../../../locales/lang/zh-HK.json"
45-
import lang_zhTW from "../../../../locales/lang/zh-TW.json"
46-
import settings_en from "../../../../locales/settings/en.json"
47-
import shortcuts_en from "../../../../locales/shortcuts/en.json"
3+
import en from "@locales/app/en.json"
4+
import common_ardz from "@locales/common/ar-DZ.json"
5+
import common_ariq from "@locales/common/ar-IQ.json"
6+
import common_arkw from "@locales/common/ar-KW.json"
7+
import common_arma from "@locales/common/ar-MA.json"
8+
import common_arsa from "@locales/common/ar-SA.json"
9+
import common_artn from "@locales/common/ar-TN.json"
10+
import common_de from "@locales/common/de.json"
11+
import common_en from "@locales/common/en.json"
12+
import common_es from "@locales/common/es.json"
13+
import common_fi from "@locales/common/fi.json"
14+
import common_fr from "@locales/common/fr.json"
15+
import common_it from "@locales/common/it.json"
16+
import common_ja from "@locales/common/ja.json"
17+
import common_ko from "@locales/common/ko.json"
18+
import common_pt from "@locales/common/pt.json"
19+
import common_ru from "@locales/common/ru.json"
20+
import common_tr from "@locales/common/tr.json"
21+
import common_zhCN from "@locales/common/zh-CN.json"
22+
import common_zhHK from "@locales/common/zh-HK.json"
23+
import common_zhTW from "@locales/common/zh-TW.json"
24+
import errors_en from "@locales/errors/en.json"
25+
import external_en from "@locales/external/en.json"
26+
import lang_ardz from "@locales/lang/ar-DZ.json"
27+
import lang_ariq from "@locales/lang/ar-IQ.json"
28+
import lang_arkw from "@locales/lang/ar-KW.json"
29+
import lang_arma from "@locales/lang/ar-MA.json"
30+
import lang_arsa from "@locales/lang/ar-SA.json"
31+
import lang_artn from "@locales/lang/ar-TN.json"
32+
import lang_de from "@locales/lang/de.json"
33+
import lang_en from "@locales/lang/en.json"
34+
import lang_es from "@locales/lang/es.json"
35+
import lang_fi from "@locales/lang/fi.json"
36+
import lang_fr from "@locales/lang/fr.json"
37+
import lang_it from "@locales/lang/it.json"
38+
import lang_ja from "@locales/lang/ja.json"
39+
import lang_ko from "@locales/lang/ko.json"
40+
import lang_pt from "@locales/lang/pt.json"
41+
import lang_ru from "@locales/lang/ru.json"
42+
import lang_tr from "@locales/lang/tr.json"
43+
import lang_zhCN from "@locales/lang/zh-CN.json"
44+
import lang_zhHK from "@locales/lang/zh-HK.json"
45+
import lang_zhTW from "@locales/lang/zh-TW.json"
46+
import settings_en from "@locales/settings/en.json"
47+
import shortcuts_en from "@locales/shortcuts/en.json"
4848
/**
4949
* This file is the language resource that is loaded in full when the app is initialized.
5050
* When switching languages, the app will automatically download the required language resources,

apps/desktop/src/renderer/src/lib/load-language.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const loadLanguageAndApply = async (lang: string) => {
5252

5353
const res = await Promise.allSettled(
5454
namespaces.map(async (ns) => {
55-
const loader = nsGlobbyMap[`../../locales/${ns}/${lang}.json`]
55+
const loader = nsGlobbyMap[`../../../../locales/${ns}/${lang}.json`]
5656

5757
if (!loader) return
5858
const nsResources = await loader().then((m: any) => m.default)

apps/desktop/src/renderer/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"paths": {
2323
"~/*": ["src/*"],
2424
"@pkg": ["../../package.json"],
25-
"@locales/*": ["../../locales/*"]
25+
"@locales/*": ["../../../../locales/*"]
2626
}
2727
},
2828
"references": [{ "path": "../main" }]

apps/ssr/client/@types/default-resource.ts

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
// This file is auto-generated by scripts/generate-i18n-locale.ts
22
// DONT EDIT THIS FILE MANUALLY
3-
import common_ardz from "../../../desktop/locales/common/ar-DZ.json"
4-
import common_ariq from "../../../desktop/locales/common/ar-IQ.json"
5-
import common_arkw from "../../../desktop/locales/common/ar-KW.json"
6-
import common_arma from "../../../desktop/locales/common/ar-MA.json"
7-
import common_arsa from "../../../desktop/locales/common/ar-SA.json"
8-
import common_artn from "../../../desktop/locales/common/ar-TN.json"
9-
import common_de from "../../../desktop/locales/common/de.json"
10-
import common_en from "../../../desktop/locales/common/en.json"
11-
import common_es from "../../../desktop/locales/common/es.json"
12-
import common_fi from "../../../desktop/locales/common/fi.json"
13-
import common_fr from "../../../desktop/locales/common/fr.json"
14-
import common_it from "../../../desktop/locales/common/it.json"
15-
import common_ja from "../../../desktop/locales/common/ja.json"
16-
import common_ko from "../../../desktop/locales/common/ko.json"
17-
import common_pt from "../../../desktop/locales/common/pt.json"
18-
import common_ru from "../../../desktop/locales/common/ru.json"
19-
import common_tr from "../../../desktop/locales/common/tr.json"
20-
import common_zhCN from "../../../desktop/locales/common/zh-CN.json"
21-
import common_zhHK from "../../../desktop/locales/common/zh-HK.json"
22-
import common_zhTW from "../../../desktop/locales/common/zh-TW.json"
23-
import errors_en from "../../../desktop/locales/errors/en.json"
24-
import external_en from "../../../desktop/locales/external/en.json"
25-
import lang_ardz from "../../../desktop/locales/lang/ar-DZ.json"
26-
import lang_ariq from "../../../desktop/locales/lang/ar-IQ.json"
27-
import lang_arkw from "../../../desktop/locales/lang/ar-KW.json"
28-
import lang_arma from "../../../desktop/locales/lang/ar-MA.json"
29-
import lang_arsa from "../../../desktop/locales/lang/ar-SA.json"
30-
import lang_artn from "../../../desktop/locales/lang/ar-TN.json"
31-
import lang_de from "../../../desktop/locales/lang/de.json"
32-
import lang_en from "../../../desktop/locales/lang/en.json"
33-
import lang_es from "../../../desktop/locales/lang/es.json"
34-
import lang_fi from "../../../desktop/locales/lang/fi.json"
35-
import lang_fr from "../../../desktop/locales/lang/fr.json"
36-
import lang_it from "../../../desktop/locales/lang/it.json"
37-
import lang_ja from "../../../desktop/locales/lang/ja.json"
38-
import lang_ko from "../../../desktop/locales/lang/ko.json"
39-
import lang_pt from "../../../desktop/locales/lang/pt.json"
40-
import lang_ru from "../../../desktop/locales/lang/ru.json"
41-
import lang_tr from "../../../desktop/locales/lang/tr.json"
42-
import lang_zhCN from "../../../desktop/locales/lang/zh-CN.json"
43-
import lang_zhHK from "../../../desktop/locales/lang/zh-HK.json"
44-
import lang_zhTW from "../../../desktop/locales/lang/zh-TW.json"
3+
import common_ardz from "@locales/common/ar-DZ.json"
4+
import common_ariq from "@locales/common/ar-IQ.json"
5+
import common_arkw from "@locales/common/ar-KW.json"
6+
import common_arma from "@locales/common/ar-MA.json"
7+
import common_arsa from "@locales/common/ar-SA.json"
8+
import common_artn from "@locales/common/ar-TN.json"
9+
import common_de from "@locales/common/de.json"
10+
import common_en from "@locales/common/en.json"
11+
import common_es from "@locales/common/es.json"
12+
import common_fi from "@locales/common/fi.json"
13+
import common_fr from "@locales/common/fr.json"
14+
import common_it from "@locales/common/it.json"
15+
import common_ja from "@locales/common/ja.json"
16+
import common_ko from "@locales/common/ko.json"
17+
import common_pt from "@locales/common/pt.json"
18+
import common_ru from "@locales/common/ru.json"
19+
import common_tr from "@locales/common/tr.json"
20+
import common_zhCN from "@locales/common/zh-CN.json"
21+
import common_zhHK from "@locales/common/zh-HK.json"
22+
import common_zhTW from "@locales/common/zh-TW.json"
23+
import errors_en from "@locales/errors/en.json"
24+
import external_en from "@locales/external/en.json"
25+
import lang_ardz from "@locales/lang/ar-DZ.json"
26+
import lang_ariq from "@locales/lang/ar-IQ.json"
27+
import lang_arkw from "@locales/lang/ar-KW.json"
28+
import lang_arma from "@locales/lang/ar-MA.json"
29+
import lang_arsa from "@locales/lang/ar-SA.json"
30+
import lang_artn from "@locales/lang/ar-TN.json"
31+
import lang_de from "@locales/lang/de.json"
32+
import lang_en from "@locales/lang/en.json"
33+
import lang_es from "@locales/lang/es.json"
34+
import lang_fi from "@locales/lang/fi.json"
35+
import lang_fr from "@locales/lang/fr.json"
36+
import lang_it from "@locales/lang/it.json"
37+
import lang_ja from "@locales/lang/ja.json"
38+
import lang_ko from "@locales/lang/ko.json"
39+
import lang_pt from "@locales/lang/pt.json"
40+
import lang_ru from "@locales/lang/ru.json"
41+
import lang_tr from "@locales/lang/tr.json"
42+
import lang_zhCN from "@locales/lang/zh-CN.json"
43+
import lang_zhHK from "@locales/lang/zh-HK.json"
44+
import lang_zhTW from "@locales/lang/zh-TW.json"
4545
/**
4646
* This file is the language resource that is loaded in full when the app is initialized.
4747
* When switching languages, the app will automatically download the required language resources,

apps/ssr/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
],
2424
"paths": {
2525
"~/*": ["./src/*"],
26-
"@client/*": ["./client/*"]
26+
"@client/*": ["./client/*"],
27+
"@locales/*": ["../../locales/*"]
2728
}
2829
},
2930
"include": [

apps/ssr/vite.config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default () => {
1212
alias: {
1313
"@pkg": resolve(__dirname, "../../package.json"),
1414
"@client": resolve(__dirname, "./client"),
15+
"@locales": resolve(__dirname, "../../locales"),
1516
},
1617
},
1718
define: {

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default defineConfig(
8989
},
9090
// @ts-expect-error
9191
{
92-
files: ["apps/desktop/locales/**/*.json"],
92+
files: ["locales/**/*.json"],
9393
plugins: {
9494
"recursive-sort": recursiveSort,
9595
"check-i18n-json": checkI18nJson,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
},
1414
"scripts": {
1515
"build:web": "turbo run Folo#build:web",
16-
"dedupe:locales": "eslint --fix apps/desktop/locales/**/*.json",
16+
"dedupe:locales": "eslint --fix locales/**/*.json",
1717
"depcheck": "npx depcheck --quiet",
1818
"format": "prettier --write .",
1919
"format:check": "prettier --check .",
20+
"generator:i18n-template": "tsx scripts/generate-i18n-locale.ts",
2021
"hotfix": "vv -c bump.hotfix.config.js",
2122
"icons:sync": "tsx scripts/svg-to-rn.ts && prettier --write apps/mobile/src/icons/**/*.tsx && eslint --fix apps/mobile/src/icons/**/*.tsx",
2223
"icons:update": "tsx scripts/update-icon.ts",

packages/constants/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"@pkg": ["../../package.json"]
1010
}
1111
},
12-
"include": ["src/**/*", "../../locales/**/*.json"]
12+
"include": ["src/**/*", "../../../../locales/**/*.json"]
1313
}

packages/shared/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"paths": {
1212
"@shared/*": ["./src/*"],
1313
"@pkg": ["../../package.json"],
14-
"@locales/*": ["../../locales/*"],
14+
"@locales/*": ["../../../../locales/*"],
1515
"~/*": ["./src/*"]
1616
}
1717
}

apps/desktop/scripts/generate-i18n-locale.ts renamed to scripts/generate-i18n-locale.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ async function selectLocale(): Promise<string> {
179179

180180
const __dirname = dirname(fileURLToPath(import.meta.url))
181181
const LOCALE_DIR = path.resolve(__dirname, "../locales")
182-
const CONFIG_DIR = path.resolve(__dirname, "../src/renderer/src/@types")
182+
const CONFIG_DIR = path.resolve(__dirname, "../apps/desktop/src/renderer/src/@types")
183183

184184
async function main() {
185185
const selectedLocale = await selectLocale()
@@ -253,11 +253,11 @@ function updateDefaultResourceFile(sourceFile: ts.SourceFile, locale: string): s
253253
const newImports = [
254254
createImportDeclaration(
255255
`lang_${locale.replace("-", "")}`,
256-
`../../../../locales/lang/${locale}.json`,
256+
`@locales/lang/${locale}.json`,
257257
),
258258
createImportDeclaration(
259259
`common_${locale.replace("-", "")}`,
260-
`../../../../locales/common/${locale}.json`,
260+
`@locales/common/${locale}.json`,
261261
),
262262
]
263263
importsAdded = true

0 commit comments

Comments
 (0)