Skip to main content

Module plugin

Module plugin 

Source
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.language setting (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, the locale.changed signal ({ "from", "to", "setting" }) goes to the host’s journal, and the next frame shows the new language. system reads an environment variable first when one is named (I18nPlugin::env), then the system’s language.
  • It declares the i18n.resolve step (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, null for 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. ShowKeys is such a hook: it shows keys instead of text.
  • It adds the i18n debug collector: the locale, its chain, the locales, the keys missing per locale; actions set_locale and clear_missing.

Structs§

I18nPlugin
Translations for an application, as a plugin (see the module).
ShowKeys
A debug aid: every lookup shows its key instead of its text, through a run-hook on i18n.resolve. Connected while the developer.show_keys setting is on.

Constants§

LOCALE_CHANGED
The signal published when the locale changes.
PLUGIN
The plugin’s id.
SETTING_LANGUAGE
The language setting: system or a locale.
SETTING_SHOW_KEYS
Shows keys instead of text, through ShowKeys when 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): what crate::tr! reads.
install
Installs catalogues in an egui context, for an application that does not use App and its I18nPlugin: t, text and of read them in this context, crate::tr! reads them through global, and egui-pop’s own text is translated through a Provider installed as the context’s strings provider. I18nPlugin installs its catalogues this way when it connects.
of
The catalogues installed in an egui context, by install or the plugin.
set_language
Switches the application’s language through its setting (system or a locale with a catalogue).
t
The text of key in the context’s language, with Fluent arguments; else the key itself. Without catalogues installed (install or the plugin), the interface’s strings provider answers (or the key shows).
text
t with the English shown when no catalogue has the key.