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

@@ -13,7 +13,7 @@ use crate::{
Error,
};
use notedeck::{storage, DataPath, DataPathType, Directory};
use notedeck::{storage, DataPath, DataPathType, Directory, Localization};
use tokenator::{ParseError, TokenParser, TokenWriter};
pub static DECKS_CACHE_FILE: &str = "decks_cache.json";
@@ -22,6 +22,7 @@ pub fn load_decks_cache(
path: &DataPath,
ndb: &Ndb,
timeline_cache: &mut TimelineCache,
i18n: &mut Localization,
) -> Option<DecksCache> {
let data_path = path.path(DataPathType::Setting);
@@ -40,7 +41,7 @@ pub fn load_decks_cache(
serde_json::from_str::<SerializableDecksCache>(&decks_cache_str).ok()?;
serializable_decks_cache
.decks_cache(ndb, timeline_cache)
.decks_cache(ndb, timeline_cache, i18n)
.ok()
}
@@ -91,6 +92,7 @@ impl SerializableDecksCache {
self,
ndb: &Ndb,
timeline_cache: &mut TimelineCache,
i18n: &mut Localization,
) -> Result<DecksCache, Error> {
let account_to_decks = self
.decks_cache
@@ -102,7 +104,7 @@ impl SerializableDecksCache {
})
.collect::<Result<HashMap<Pubkey, Decks>, Error>>()?;
Ok(DecksCache::new(account_to_decks))
Ok(DecksCache::new(account_to_decks, i18n))
}
}