♻️ Major code restructuring
This commit is contained in:
parent
a96e203bb3
commit
fa66d628a0
221 changed files with 228 additions and 315 deletions
35
src/base/component/translate.rs
Normal file
35
src/base/component/translate.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
pub struct Translate(L10n);
|
||||
|
||||
impl ComponentTrait for Translate {
|
||||
fn new() -> Self {
|
||||
Translate::default()
|
||||
}
|
||||
|
||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||
PrepareMarkup::With(self.l10n().escaped(cx.langid()))
|
||||
}
|
||||
}
|
||||
|
||||
impl Translate {
|
||||
pub fn with(l10n: L10n) -> Self {
|
||||
Translate(l10n)
|
||||
}
|
||||
|
||||
// Translate BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
pub fn alter_l10n(&mut self, l10n: L10n) -> &mut Self {
|
||||
self.0 = l10n;
|
||||
self
|
||||
}
|
||||
|
||||
// Translate GETTERS.
|
||||
|
||||
pub fn l10n(&self) -> &L10n {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue