Skip to content

Commit

Permalink
Localise all *_translations.json files
Browse files Browse the repository at this point in the history
- Refactor `localDir` to `localeDir`
  • Loading branch information
its-miroma committed Jun 12, 2024
1 parent 5a8d29d commit 7b19e0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions .vitepress/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ export function loadLocales(rootDir: string): LocaleConfig<DefaultTheme.Config>

/**
* Returns a resolving function for any navbar strings.
* @param localDir - The directory of the locale (null for English).
* @param localeDir - The directory of the locale (null for English).
*/
function getNavbarResolver(localDir: string | null): (key: string) => string {
function getNavbarResolver(localeDir: string | null): (key: string) => string {
// Load navbar_translations.json of locale and english.
const fallbackTranslations = JSON.parse(readFileSync(resolve(__dirname, "..", "navbar_translations.json"), "utf-8"));
let translations: any;

if(localDir == null) {
if(localeDir == null) {
translations = fallbackTranslations
} else {
if(!existsSync(resolve("translated", localDir, "navbar_translations.json"))) {
if(!existsSync(resolve("translated", localeDir, "navbar_translations.json"))) {
translations = fallbackTranslations;
} else {
translations = JSON.parse(readFileSync(resolve("translated", localDir, "navbar_translations.json"), "utf-8"));
translations = JSON.parse(readFileSync(resolve("translated", localeDir, "navbar_translations.json"), "utf-8"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ files:
- es-EC # Spanish, Ecuador
- es-AR # Spanish, Argentina
- es-MX # Spanish, Mexico
- source: sidebar_translations.json
- source: *_translations.json
ignore:
- /translated/**/*
translation: /translated/%locale_with_underscore%/%original_path%/%original_file_name%
Expand Down

0 comments on commit 7b19e0f

Please sign in to comment.