Forked from yongwei/rag-flex
Project Files
src / locales / README.md
This directory contains all translation files for the RAG-Flex plugin.
src/locales/ βββ README.md # This file (English) βββ README.zh-TW.md # Traditional Chinese documentation βββ README.ja.md # Japanese documentation βββ types.ts # TypeScript type definitions for translations βββ en.ts # English translations βββ zh-TW.ts # Traditional Chinese translations βββ ja.ts # Japanese translations βββ index.ts # Exports all translations and types
types.tsDefines the TypeScript interfaces for all translatable content:
SupportedLanguage: Union type of all supported language codesTranslations: Interface defining the structure of translation objectsen.tsContains all English translations. Export name: en
zh-TW.tsContains all Traditional Chinese translations. Export name: zhTW
ja.tsContains all Japanese translations. Export name: ja
index.tsCentral export point that:
translations object mapping language codes to translation objectsTo add support for a new language (e.g., Japanese):
Create src/locales/ja.ts:
types.tsAdd the new language code to SupportedLanguage:
index.tsImport and add the new language to the translations object:
If you want automatic language detection for the new language, update src/i18n.ts:
In src/config.ts, add the new option:
Many translation strings accept parameters:
Make sure to:
After adding or modifying translations:
Current translation coverage (per language file):
Total per language: ~44 translatable items
If you have questions about the translation system, refer to:
src/i18n.ts - Core internationalization logictypes.ts - TypeScript types for structure referenceType Checking: Ensure TypeScript compilation succeeds
Visual Testing:
Functional Testing:
/**
* Japanese translations for RAG-Flex plugin
*/
import type { Translations } from "./types";
export const ja: Translations = {
config: {
embeddingModel: {
displayName: "εγθΎΌγΏγ’γγ«",
subtitle: "εγθΎΌγΏγ’γγ«γιΈζοΌδΊεγ«γγ¦γ³γγΌγεΏ
θ¦οΌ"
},
// ... rest of translations
},
// ... implement all sections
};
export type SupportedLanguage = "en" | "zh-TW" | "ja";
import { ja } from "./ja";
export const translations: Record<SupportedLanguage, Translations> = {
"en": en,
"zh-TW": zhTW,
"ja": ja
};
export function detectSystemLanguage(): SupportedLanguage {
const envLang = process.env.LANG || process.env.LANGUAGE || process.env.LC_ALL || "";
// ... existing checks ...
// Japanese
if (envLang.includes("ja") || envLang.includes("jp")) {
return "ja";
}
return "en";
}
.field(
"language",
"select",
{
displayName: "Language / θͺθ¨ / θ¨θͺ",
subtitle: "Select interface language / ιΈζδ»ι’θͺθ¨ / γ€γ³γΏγΌγγ§γΌγΉθ¨θͺγιΈζ",
options: ["en", "zh-TW", "ja"],
enumTitles: ["English", "ηΉι«δΈζ", "ζ₯ζ¬θͺ"],
},
language,
)
// Function signature in types.ts
loadingEmbeddingModel: (modelPath: string) => string;
// Implementation in language file
loadingEmbeddingModel: (modelPath) => `Loading model: ${modelPath}...`,
lms dev