Documentation
¶
Overview ¶
Package i18n provides runtime-switchable UI string translations. Locale files are embedded at build time. English is default/fallback language.
Index ¶
- func Available() []string
- func DetectOSLanguage(available []string) string
- func IsRTL() bool
- func Load(code string) error
- type Cmdbar
- type Dialogs
- type Help
- type Inputs
- type JournalRefs
- type Lang
- type Meta
- type Modes
- type Noun
- type Nouns
- type Palette
- type SettingsEditor
- type Terms
- type Verbs
- type Welcome
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Available ¶
func Available() []string
Available returns the list of language codes available in the embedded FS, sorted alphabetically. Adding a new <code>.toml file is sufficient to make a language available; no registry update is needed.
func DetectOSLanguage ¶
DetectOSLanguage evaluates a list candidate language codes from OS env vars and returns the best-matching code from available, falling back to "en" if no match.
Types ¶
type Cmdbar ¶
type Cmdbar struct {
NoFileOpen string `toml:"no_file_open"`
ReloadSuccess string `toml:"reload_success"`
ReloadFailed string `toml:"reload_failed"`
CreatedFile string `toml:"created_file"`
CreatedTemplate string `toml:"created_template"`
AlreadyExistsOpened string `toml:"already_exists_opened"`
CreateFailed string `toml:"create_failed"`
CopiedFile string `toml:"copied_file"`
CopyFailed string `toml:"copy_failed"`
JournalError string `toml:"journal_error"`
RenameFailed string `toml:"rename_failed"`
RenamedTo string `toml:"renamed_to"`
RenamedLinks string `toml:"renamed_links"`
DeleteFailed string `toml:"delete_failed"`
Deleted string `toml:"deleted"`
Opened string `toml:"opened"`
OverwriteFailed string `toml:"overwrite_failed"`
PaneTooNarrow string `toml:"pane_too_narrow"`
PaneTooShort string `toml:"pane_too_short"`
StateNotSaved string `toml:"state_not_saved"`
VaultCfgNotSaved string `toml:"vault_cfg_not_saved"`
SwapUnreadable string `toml:"swap_unreadable"`
SwapOpened string `toml:"swap_opened"`
SwapDiscarded string `toml:"swap_discarded"`
SwapPending string `toml:"swap_pending"`
SwapFound string `toml:"swap_found"`
DiskChangedEdits string `toml:"disk_changed_edits"`
DiskChanged string `toml:"disk_changed"`
DirCreateFailed string `toml:"dir_create_failed"`
AssetNotFound string `toml:"asset_not_found"`
LinkOutsideVault string `toml:"link_outside_vault"`
UnsupportedURL string `toml:"unsupported_url"`
URLOpenFailed string `toml:"url_open_failed"`
FileNotFound string `toml:"file_not_found"`
UnknownNamespace string `toml:"unknown_namespace"`
ReviewOpened string `toml:"review_opened"`
ReviewError string `toml:"review_error"`
ReviewUsage string `toml:"review_usage"`
JournalOpenUsage string `toml:"journal_open_usage"`
NoteAddUsage string `toml:"note_copy_usage"`
NoteCopyUsage string `toml:"note_add_usage"`
TemplateAddUsage string `toml:"template_add_usage"`
NoteOpenUsage string `toml:"note_open_usage"`
NoteRenameUsage string `toml:"note_rename_usage"`
TemplateOpenUsage string `toml:"template_open_usage"`
TemplateRenameUsage string `toml:"template_rename_usage"`
FileAlreadyOpen string `toml:"file_already_open"`
}
Cmdbar holds status bar messages (errors, warnings, successes). %s/%d placeholders must be preserved in translations.
type Dialogs ¶
type Dialogs struct {
// Exists conflict title (noun-free; body text provides context)
ExistsTitle string `toml:"exists_title"`
// Rename conflict body
DestExistsBody string `toml:"dest_exists_body"`
// Template-from-template conflict body
TmplExistsBody string `toml:"tmpl_exists_body"`
// Unsaved changes
UnsavedTitle string `toml:"unsaved_title"`
UnsavedCloseBody string `toml:"unsaved_close_body"`
UnsavedQuitBody string `toml:"unsaved_quit_body"`
// Swap file recovery
RecoverSwapTitle string `toml:"recover_swap_title"`
// File changed on disk
DiskChangedTitle string `toml:"disk_changed_title"`
DiskChangedBody string `toml:"disk_changed_body"`
DiskChangedConflictBody string `toml:"disk_changed_conflict_body"`
// Delete confirmations (%s = filename)
DeleteFileTitle string `toml:"delete_file_title"`
DeleteFileBody string `toml:"delete_file_body"`
DeleteEntryTitle string `toml:"delete_entry_title"`
DeleteEntryBody string `toml:"delete_entry_body"`
DeleteNoteTitle string `toml:"delete_note_title"`
// Buttons
ButtonOverwrite string `toml:"button_overwrite"`
ButtonCancel string `toml:"button_cancel"`
ButtonReplace string `toml:"button_replace"`
ButtonDiscard string `toml:"button_discard"`
ButtonDiscardQuit string `toml:"button_discard_quit"`
ButtonDelete string `toml:"button_delete"`
ButtonOpenExisting string `toml:"button_open_existing"`
ButtonOpenSwap string `toml:"button_open_swap"`
ButtonReload string `toml:"button_reload"`
ButtonReloadDiscard string `toml:"button_reload_discard"`
ButtonKeep string `toml:"button_keep"`
ButtonKeepEdits string `toml:"button_keep_edits"`
}
Dialogs holds titles, body text, and button labels for confirmation dialogs.
type Help ¶
type Help struct {
Title string
SectionView string `toml:"section_view"`
SectionNormal string `toml:"section_normal"`
SectionVisual string `toml:"section_visual"`
SectionInsert string `toml:"section_insert"`
SectionPanels string `toml:"section_panels"`
SectionFiles string `toml:"section_files"`
SectionPanes string `toml:"section_panes"`
SectionCmds string `toml:"section_cmds"`
}
Help holds the help modal title and mode section headings.
type Inputs ¶
type Inputs struct {
TypeToFilter string `toml:"type_to_filter"`
TypeToFilterNotes string `toml:"type_to_filter_notes"`
TypeToFilterTemplates string `toml:"type_to_filter_templates"`
TypeToFilterBookmarks string `toml:"type_to_filter_bookmarks"`
TypeToFilterVaults string `toml:"type_to_filter_vaults"`
TypeToFilterThemes string `toml:"type_to_filter_themes"`
TypeToFilterLinks string `toml:"type_to_filter_links"`
TypeToFilterAssets string `toml:"type_to_filter_assets"`
TypeToFilterLangs string `toml:"type_to_filter_langs"`
FilterJournal string `toml:"filter_journal"`
EnterNoteName string `toml:"enter_note_name"`
EnterNewName string `toml:"enter_new_name"`
EnterTemplateName string `toml:"enter_template_name"`
EnterVaultPathNew string `toml:"enter_vault_path_new"`
EnterVaultPathExists string `toml:"enter_vault_path_exists"`
EnterAssetPath string `toml:"enter_asset_path"`
EnterAliasName string `toml:"enter_alias_name"`
EnterDirPath string `toml:"enter_dir_path"`
EnterCommand string `toml:"enter_command"`
}
Inputs holds placeholder text for palette and modal input fields.
type JournalRefs ¶
type JournalRefs struct {
Today string
Yesterday string
Tomorrow string
ThisWeek string `toml:"this_week"`
LastWeek string `toml:"last_week"`
NextWeek string `toml:"next_week"`
ThisMonth string `toml:"this_month"`
LastMonth string `toml:"last_month"`
ThisYear string `toml:"this_year"`
LastYear string `toml:"last_year"`
}
JournalRefs holds display names for the journal date-reference picker.
type Lang ¶
type Lang struct {
Terms Terms
Meta Meta
Palette Palette
Dialogs Dialogs
Cmdbar Cmdbar
Welcome Welcome
Help Help
Modes Modes
JournalRefs JournalRefs `toml:"journal_refs"`
Inputs Inputs
SettingsEditor SettingsEditor `toml:"settings_editor"`
}
Lang is the top-level translation struct. Each field group maps to a TOML table.
var Active *Lang
Active is the currently loaded language in TUI.
type Modes ¶
type Modes struct {
View string
Normal string
Insert string
Replace string
Visual string
VLine string `toml:"v_line"`
}
Modes holds the status bar mode indicator labels.
type Noun ¶
Noun holds CLDR plural-category forms of a term. Languages use the subset of categories their grammar requires. Empty categories fall back to Other, then One, at runtime.
type Nouns ¶
type Nouns struct {
Vault Noun
Note Noun
Journal Noun
Template Noun
Asset Noun
File Noun
Link Noun
Bookmark Noun
Theme Noun
Fold Noun
Setting Noun
}
Nouns holds domain and UI-feature nouns.
type Palette ¶
type Palette struct {
Active string `toml:"active"`
// Notes
NotesOpen string `toml:"notes_open"`
NotesInsertTmpl string `toml:"notes_insert_tmpl"`
NotesCreate string `toml:"notes_create"`
NotesCopy string `toml:"notes_copy"`
NotesCreateTmpl string `toml:"notes_create_tmpl"`
NotesDelete string `toml:"notes_delete"`
NotesRename string `toml:"notes_rename"`
// Templates
TemplatesOpen string `toml:"templates_open"`
TemplatesCreate string `toml:"templates_create"`
TemplatesDelete string `toml:"templates_delete"`
TemplatesRename string `toml:"templates_rename"`
// Journals
JournalsOpen string `toml:"journals_open"`
// Vaults
VaultsSwitch string `toml:"vaults_switch"`
VaultsLoad string `toml:"vaults_load"`
VaultsCreate string `toml:"vaults_create"`
// Bookmarks
BookmarkCurrent string `toml:"bookmark_current"`
BookmarkEdit string `toml:"bookmark_edit"`
BookmarksOpen string `toml:"bookmarks_open"`
// Themes
ThemesChange string `toml:"themes_change"`
// Links
LinksInsert string `toml:"links_insert"`
LinksInsertAsset string `toml:"links_insert_asset"`
LinksOpen string `toml:"links_open"`
// Folds
FoldsExpand string `toml:"folds_expand"`
FoldsCollapse string `toml:"folds_collapse"`
// Assets
AssetsAdd string `toml:"assets_add"`
AssetsOpen string `toml:"assets_open"`
AssetsAddExtDir string `toml:"assets_add_ext_dir"`
// Settings
TabsToSpaces string `toml:"tabs_to_spaces"`
SettingsChangeLang string `toml:"settings_change_lang"`
SettingsEditGlobal string `toml:"settings_edit_global"`
SettingsEditVault string `toml:"settings_edit_vault"`
SettingsDiscardPrompt string `toml:"settings_discard_prompt"`
}
Palette holds command palette entry labels. Each entry is a fully pre-composed string. Translators write the complete label for their language rather than filling in noun/verb placeholders, which gives full control over articles, grammatical gender, word order, and other language-specific needs.
type SettingsEditor ¶
type SettingsEditor struct {
TitleGlobal string `toml:"title_global"`
TitleVault string `toml:"title_vault"`
ColSetting string `toml:"col_setting"`
ColCurrent string `toml:"col_current"`
ColNewValue string `toml:"col_new_value"`
DiscardPrompt string `toml:"discard_prompt"`
HelpText string `toml:"help_text"`
LabelExt string `toml:"label_ext"`
LabelTheme string `toml:"label_theme"`
LabelStartMode string `toml:"label_start_mode"`
LabelLinkFormat string `toml:"label_link_format"`
LabelWeekStart string `toml:"label_week_start"`
LabelTabSpaces string `toml:"label_tab_spaces"`
LabelShiftWidth string `toml:"label_shift_width"`
LabelFoldLevel string `toml:"label_fold_level"`
LabelExpandTabs string `toml:"label_expand_tabs"`
LabelShowSidebar string `toml:"label_show_sidebar"`
LabelNoteFrontmatter string `toml:"label_note_frontmatter"`
LabelAutoJournalPeriods string `toml:"label_auto_journal_periods"`
LabelFuzzySearch string `toml:"label_fuzzy_search"`
LabelCheckboxStates string `toml:"label_checkbox_states"`
LabelStartJournal string `toml:"label_start_journal"`
}
SettingsEditor holds all UI strings for the in-app settings editor modal.
type Verbs ¶
type Verbs struct {
Open string
Close string
Create string
Delete string
Rename string
Save string
Cancel string
Replace string
Switch string
Edit string
Add string
Insert string
Copy string
}
Verbs holds common action verbs.
type Welcome ¶
type Welcome struct {
Title string
CreateNew string `toml:"create_new"`
OpenExisting string `toml:"open_existing"`
PathPromptNew string `toml:"path_prompt_new"`
PathPromptExisting string `toml:"path_prompt_existing"`
// Individual hint phrases composed at render time.
HintConfirm string `toml:"hint_confirm"`
HintQuit string `toml:"hint_quit"`
HintBack string `toml:"hint_back"`
}
Welcome holds strings used in the first-run welcome modal.