Internationalization (i18n)
Ongenet uses Avalonia resource dictionaries for UI strings. English is the source locale; additional languages are parallel .axaml files with identical keys.
File layout
| File | Purpose |
|---|---|
Ongenet.App/Localization/Loc.cs |
C# string lookup (Loc.Get, Loc.Format) |
Ongenet.App/Localization/LocalizationService.cs |
Loads/swaps locale dictionaries at runtime |
Ongenet.App/Resources/Strings.en.axaml |
English (master catalog) |
Ongenet.App/Resources/Strings.ja.axaml |
Japanese |
Using strings in XAML
Bind user-visible text with DynamicResource so language changes apply without reopening windows:
<TextBlock Text="{DynamicResource Main_Open}"/>
<Button ToolTip.Tip="{DynamicResource Main_OpenTip}"/>
Do not localize icon glyphs (↶, ▸), bindings, version numbers, or user/project data.
Using strings in C#
View models inherit L() from ViewModelBase:
public string Title => L("Settings_Title");
public string Status => L("ProjectClips_Detail", kind, length, count);
Elsewhere:
Loc.Get("Dialog_OK");
Loc.Format("Menu_RemoveMidiMapping", ccNumber);
Subscribe to ILocalizationService.CultureChanged when you build dynamic menus or need to refresh many properties.
Key naming
Flat PascalCase with area prefix:
Main_Open,Main_OpenTipSettings_TabGeneral,Settings_LanguageDialog_OK,Dialog_CancelGuide_GettingStarted_Title,Guide_GettingStarted_BodyMain_Scripting,Scripting_*— Scripting centre tab, IDE, and export buttons (Scripting_ExportProject,Scripting_ExportPreset, …) (scripting.md)Scripts_*— scripting panel toolbar and output (scripting.md)AudioEditor_*— standalone Audio Editor (audio-editor.md)PolyPitch_*/Timeline_Open_Pitch_Editor— pitch editor (polyphonic-pitch.md)Settings_PluginIsolation*— plugin sandbox toggle (plugin-isolation.md)Guide_AudioEditor_*,Guide_PitchEditor_*,Guide_Scripting_*— in-app Guide sections
Suffix Tip for tooltips, Title for window titles, A11yName / A11yHelp for accessibility.
Changing language in the app
Settings → General → Language — choose System default, English, or 日本語. The choice is stored in AppSettings.UiCulture and applied immediately.
Adding a new language
- Copy
Strings.en.axamltoStrings.<culture>.axaml(e.g.Strings.de.axaml). - Translate values only — never rename keys.
- Register the culture in
LocalizationService.SupportedCultureIdsand add a display label toSupportedLocalesand the General settings combo inGeneralSettingsViewModel. - Extend
LocalizationKeyParityTeststo include the new file. - If the script exists, add phrase hints to
scripts/i18n_translate_ja.pyas a reference for DAW terminology, then translate manually or regenerate. - Smoke-test dense UI (transport bar, track inspector) for overflow; add CJK/Cyrillic font fallbacks in
App.axamlif needed.
Maintenance scripts
| Script | Purpose |
|---|---|
scripts/i18n_extract.py |
Scan AXAML for hardcoded literals → update Strings.en.axaml and {DynamicResource} bindings |
scripts/i18n_translate_ja.py |
Bootstrap Strings.ja.axaml from English (review with a native speaker before release) |
After adding new English keys manually, re-run the Japanese script and fix any awkward machine translations.
CI
LocalizationKeyParityTests fails if Strings.ja.axaml (and other registered locales) are missing keys present in English or contain empty values.