i18n: make localization context non-global

- Simplify Localization{Context,Manager} to just Localization
- Fixed a bunch of lifetime issueo
- Removed all Arcs and Locks
- Removed globals
  * widgets now need access to &mut Localization for i18n

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-06-29 11:05:31 -07:00
parent d1e222f732
commit 3d4db820b4
47 changed files with 1414 additions and 1166 deletions

View File

@@ -1,8 +1,9 @@
use egui::{Color32, RichText, Widget};
use nostrdb::ProfileRecord;
use notedeck::{fonts::NamedFontFamily, tr};
use notedeck::{fonts::NamedFontFamily, tr, Localization};
pub struct Username<'a> {
i18n: &'a mut Localization,
profile: Option<&'a ProfileRecord<'a>>,
pk: &'a [u8; 32],
pk_colored: bool,
@@ -20,10 +21,15 @@ impl<'a> Username<'a> {
self
}
pub fn new(profile: Option<&'a ProfileRecord>, pk: &'a [u8; 32]) -> Self {
pub fn new(
i18n: &'a mut Localization,
profile: Option<&'a ProfileRecord>,
pk: &'a [u8; 32],
) -> Self {
let pk_colored = false;
let abbrev: usize = 1000;
Username {
i18n,
profile,
pk,
pk_colored,
@@ -53,6 +59,7 @@ impl Widget for Username<'_> {
}
} else {
let mut txt = RichText::new(tr!(
self.i18n,
"nostrich",
"Default username when profile is not available"
))