mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-19 17:44:18 +01:00
i18n: always have en-XA available
this is statically compiled anyways. we might want to only have this as a feature flag in the future to reduce binary size Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -47,27 +47,14 @@ pub struct Localization {
|
|||||||
impl Default for Localization {
|
impl Default for Localization {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
// Default to English (US)
|
// Default to English (US)
|
||||||
let default_locale = EN_US;
|
let default_locale = &EN_US;
|
||||||
let fallback_locale = default_locale.clone();
|
let fallback_locale = default_locale.to_owned();
|
||||||
let mut current_locale = default_locale.clone();
|
|
||||||
|
|
||||||
// Check if pseudolocale is enabled via environment variable
|
|
||||||
let enable_pseudolocale = std::env::var("NOTEDECK_PSEUDOLOCALE").is_ok();
|
|
||||||
|
|
||||||
// Build available locales list
|
// Build available locales list
|
||||||
let mut available_locales = vec![default_locale.clone()];
|
let available_locales = vec![EN_US.clone(), EN_XA.clone()];
|
||||||
|
|
||||||
// Add en-XA if pseudolocale is enabled
|
|
||||||
if enable_pseudolocale {
|
|
||||||
available_locales.push(EN_XA.clone());
|
|
||||||
current_locale = EN_XA.clone();
|
|
||||||
tracing::info!(
|
|
||||||
"Pseudolocale (en-XA) enabled via NOTEDECK_PSEUDOLOCALE environment variable"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
current_locale,
|
current_locale: default_locale.to_owned(),
|
||||||
available_locales,
|
available_locales,
|
||||||
fallback_locale,
|
fallback_locale,
|
||||||
normalized_key_cache: HashMap::new(),
|
normalized_key_cache: HashMap::new(),
|
||||||
@@ -77,11 +64,6 @@ impl Default for Localization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum StringCacheResult<'a> {
|
|
||||||
Hit(Cow<'a, str>),
|
|
||||||
NeedsInsert(IntlKeyBuf, String),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Localization {
|
impl Localization {
|
||||||
/// Creates a new Localization with the specified resource directory
|
/// Creates a new Localization with the specified resource directory
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
@@ -417,8 +399,9 @@ mod tests {
|
|||||||
|
|
||||||
// Test available locales
|
// Test available locales
|
||||||
let available = i18n.get_available_locales();
|
let available = i18n.get_available_locales();
|
||||||
assert_eq!(available.len(), 1);
|
assert_eq!(available.len(), 2);
|
||||||
assert_eq!(available[0].to_string(), "en-US");
|
assert_eq!(available[0].to_string(), "en-US");
|
||||||
|
assert_eq!(available[1].to_string(), "en-XA");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ pub use key::{IntlKey, IntlKeyBuf};
|
|||||||
|
|
||||||
pub use manager::CacheStats;
|
pub use manager::CacheStats;
|
||||||
pub use manager::Localization;
|
pub use manager::Localization;
|
||||||
pub use manager::StringCacheResult;
|
|
||||||
|
|
||||||
/// Re-export commonly used types for convenience
|
/// Re-export commonly used types for convenience
|
||||||
pub use fluent::FluentArgs;
|
pub use fluent::FluentArgs;
|
||||||
|
|||||||
Reference in New Issue
Block a user