Localization
The fluent feature lets generated table titles, column labels, and facet
labels use the application’s typed es-fluent resources. The application must
own and link those resources; gpui-table-component only supplies resources
for its built-in controls.
This example follows the development branch. Use a sibling gpui-table
checkout and GPUI Kit 0.11:
[dependencies]
gpui-kit = "0.11.0"
gpui-table = { path = "../gpui-table/crates/gpui-table", features = ["fluent"] }
gpui-table-component = { path = "../gpui-table/crates/gpui-table-component" }
es-fluent = "0.22.0"
Derive localized labels
Derive message metadata on the row and faceted value types:
use es_fluent::{EsFluentLabel, EsFluentVariants};
use gpui_table::{Filterable, GpuiTable, TableCell};
#[derive(
Clone,
Eq,
Hash,
PartialEq,
es_fluent::EsFluent,
Filterable,
TableCell,
)]
#[filter(fluent)]
enum Status {
Active,
Suspended,
}
#[derive(Clone, EsFluentLabel, EsFluentVariants, GpuiTable)]
#[fluent_variants(keys = ["label"])]
#[gpui_table(fluent = "label", filters)]
struct User {
#[gpui_table(filter(gpui_table_component::FacetedFilter::<Status>))]
status: Status,
}
#[gpui_table(fluent = "label")] selects the label key generated by
EsFluentVariants. Keep those row and facet messages in the same application
localization module as the rest of the GPUI interface.
Initialize and select the locale
After gpui_kit::component::init(cx), initialize table localization from the active
component locale:
gpui_table_component::i18n::init(cx)?;
To change locales later, synchronize the built-in component and table-core contexts together:
gpui_table_component::i18n::set_locale(cx, "en")?;
An application with its own embedded resource manager must apply the same
resolved language to that manager before rendering typed row labels. The
canonical
some-lib locale adapter
shows one complete resource-linking and synchronization path.
Initialization and locale selection return typed errors. Ordinary typed label and message rendering treats a missing localization global or missing resource as a hard failure, so perform locale setup before constructing or rendering generated filters.