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