diff --git a/pagetop/src/app.rs b/pagetop/src/app.rs index 8e3c75f2..dbb39ddd 100644 --- a/pagetop/src/app.rs +++ b/pagetop/src/app.rs @@ -34,7 +34,7 @@ impl Application { LazyStatic::force(&trace::TRACING); // Valida el identificador global de idioma. - LazyStatic::force(&locale::DEFAULT_LANGID); + LazyStatic::force(&locale::LANGID); #[cfg(feature = "database")] // Conecta con la base de datos. diff --git a/pagetop/src/core/component/context.rs b/pagetop/src/core/component/context.rs index dec94143..b6311bec 100644 --- a/pagetop/src/core/component/context.rs +++ b/pagetop/src/core/component/context.rs @@ -1,13 +1,13 @@ use crate::core::module::{all::theme_by_single_name, ThemeStaticRef}; use crate::html::{html, Assets, IdentifierValue, JavaScript, Markup, StyleSheet}; -use crate::locale::{LanguageIdentifier, DEFAULT_LANGID}; +use crate::locale::{LanguageIdentifier, LANGID}; use crate::server::HttpRequest; use crate::{concat_string, config, util, LazyStatic}; use std::collections::HashMap; use std::str::FromStr; -static DEFAULT_THEME: LazyStatic = +static THEME: LazyStatic = LazyStatic::new(|| match theme_by_single_name(&config::SETTINGS.app.theme) { Some(theme) => theme, None => &crate::core::basic::Basic, @@ -38,8 +38,8 @@ impl Default for RenderContext { #[rustfmt::skip] fn default() -> Self { RenderContext { - langid : &DEFAULT_LANGID, - theme : *DEFAULT_THEME, + langid : &LANGID, + theme : *THEME, request : None, stylesheets: Assets::::new(), javascripts: Assets::::new(), @@ -60,7 +60,7 @@ impl RenderContext { self.langid = langid; } ContextOp::Theme(theme_name) => { - self.theme = theme_by_single_name(theme_name).unwrap_or(*DEFAULT_THEME); + self.theme = theme_by_single_name(theme_name).unwrap_or(*THEME); } ContextOp::Request(request) => { self.request = request; diff --git a/pagetop/src/locale.rs b/pagetop/src/locale.rs index 74af781a..4fe64bde 100644 --- a/pagetop/src/locale.rs +++ b/pagetop/src/locale.rs @@ -105,7 +105,7 @@ static FALLBACK_LANGID: LazyStatic = LazyStatic::new(|| lang /// Almacena el Identificador de Idioma Unicode /// ([Unicode Language Identifier](https://unicode.org/reports/tr35/tr35.html#Unicode_language_identifier)) /// global para la aplicación a partir de `SETTINGS.app.language`. -pub(crate) static DEFAULT_LANGID: LazyStatic<&LanguageIdentifier> = +pub(crate) static LANGID: LazyStatic<&LanguageIdentifier> = LazyStatic::new(|| langid_for(config::SETTINGS.app.language.as_str())); pub fn langid_for(language: &str) -> &LanguageIdentifier {