Skip to main content

localized_symbol

Function localized_symbol 

Source
pub fn localized_symbol<'a>(symbol: &'a str, lang: &str) -> &'a str
Expand description

symbol in lang’s own words, when this crate knows one – symbol unchanged otherwise, the same “unrecognised passes through” discipline Preferences::parse itself already keeps. signalk-server states every symbol in English regardless of who is reading it (confirmed live: a mariner’s own distance preference set to nautical miles comes back with "symbol":"nmi" whatever locale the request was made under) – this is the one place that turns it into something else.

Deliberately not part of Preferences itself: a caller already has this crate’s own English symbol, from Preferences::symbol or one of its four named accessors, and reaches for this only when it wants a mariner’s own words instead, which not every caller does – one happy with English survives this table changing without needing to call anything differently.

lang is a BCP-47 language tag, "de" or "de-DE" alike – only its own primary language subtag is read, via [language_tags], rather than this crate learning to split locale strings by hand. An unparseable lang reads the same as a language this crate has nothing for: symbol unchanged. Reading a mariner’s own chosen language at all is not this crate’s job, the same “not this crate’s job” boundary Preferences itself already draws for where a token lives on disk or which GSettings key a discovery preference is in.