Expand description
The plugin: I18nPlugin connects an I18n to an application.
- It installs the interface’s strings provider
(
egui_pop_core::strings), so egui-pop’s own text and the titles of what plugins declare are translated, and keeps it current. - It declares the
appearance.languagesetting (system, then each locale with a catalogue, shown by its own name), kept in the host’s store like every setting. When it changes, the locale switches, thelocale.changedsignal ({ "from", "to", "setting" }) goes to the host’s journal, and the next frame shows the new language.systemreads an environment variable first when one is named (I18nPlugin::env), then the system’s language. - It declares the
i18n.resolvestep (ADR 0011): every lookup a plugin hooks runs through it, with{ "key", "locale", "args" }; a before-hook may redirect it (another key or locale), a run-hook replace it (its result is the text,nullfor none), an after-hook observe it. Without hooks, lookups do not run the step. With hooks, each distinct lookup runs it once, at the next frame, and its answer is kept until the locale or the catalogues change.ShowKeysis such a hook: it shows keys instead of text. - It adds the
i18ndebug collector: the locale, its chain, the locales, the keys missing per locale; actionsset_localeandclear_missing.
Structs§
- I18n
Plugin - Translations for an application, as a plugin (see the module).
- Show
Keys - A debug aid: every lookup shows its key instead of its text, through
a run-hook on
i18n.resolve. Connected while thedeveloper.show_keyssetting is on.
Constants§
- LOCALE_
CHANGED - The signal published when the locale changes.
- PLUGIN
- The plugin’s id.
- SETTING_
LANGUAGE - The language setting:
systemor a locale. - SETTING_
SHOW_ KEYS - Shows keys instead of text, through
ShowKeyswhen the application has it. - SHOW_
KEYS ShowKeys’ id.- STEP_
RESOLVE - The step every hooked lookup runs through.
- SYSTEM
- The setting’s value that follows the system.
Functions§
- global
- The catalogues last installed (
install, or a connected plugin; an empty English one before): whatcrate::tr!reads. - install
- Installs catalogues in an egui context, for an application that does
not use
Appand itsI18nPlugin:t,textandofread them in this context,crate::tr!reads them throughglobal, and egui-pop’s own text is translated through aProviderinstalled as the context’s strings provider.I18nPlugininstalls its catalogues this way when it connects. - of
- The catalogues installed in an egui context, by
installor the plugin. - set_
language - Switches the application’s language through its setting
(
systemor a locale with a catalogue). - t
- The text of
keyin the context’s language, with Fluent arguments; else the key itself. Without catalogues installed (installor the plugin), the interface’s strings provider answers (or the key shows). - text
twith the English shown when no catalogue has the key.