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:
@@ -8,7 +8,9 @@ use std::f32::consts::PI;
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::timeline::{TimelineCache, TimelineKind, TimelineTab, ViewFilter};
|
||||
use notedeck::{note::root_note_id_from_selected_id, tr, NoteAction, NoteContext, ScrollInfo};
|
||||
use notedeck::{
|
||||
note::root_note_id_from_selected_id, tr, Localization, NoteAction, NoteContext, ScrollInfo,
|
||||
};
|
||||
use notedeck_ui::{
|
||||
anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE},
|
||||
NoteOptions, NoteView,
|
||||
@@ -103,7 +105,12 @@ fn timeline_ui(
|
||||
return None;
|
||||
};
|
||||
|
||||
timeline.selected_view = tabs_ui(ui, timeline.selected_view, &timeline.views);
|
||||
timeline.selected_view = tabs_ui(
|
||||
ui,
|
||||
note_context.i18n,
|
||||
timeline.selected_view,
|
||||
&timeline.views,
|
||||
);
|
||||
|
||||
// need this for some reason??
|
||||
ui.add_space(3.0);
|
||||
@@ -263,7 +270,12 @@ fn goto_top_button(center: Pos2) -> impl egui::Widget {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tabs_ui(ui: &mut egui::Ui, selected: usize, views: &[TimelineTab]) -> usize {
|
||||
pub fn tabs_ui(
|
||||
ui: &mut egui::Ui,
|
||||
i18n: &mut Localization,
|
||||
selected: usize,
|
||||
views: &[TimelineTab],
|
||||
) -> usize {
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
|
||||
let tab_res = egui_tabs::Tabs::new(views.len() as i32)
|
||||
@@ -281,9 +293,13 @@ pub fn tabs_ui(ui: &mut egui::Ui, selected: usize, views: &[TimelineTab]) -> usi
|
||||
let ind = state.index();
|
||||
|
||||
let txt = match views[ind as usize].filter {
|
||||
ViewFilter::Notes => tr!("Notes", "Label for notes-only filter"),
|
||||
ViewFilter::Notes => tr!(i18n, "Notes", "Label for notes-only filter"),
|
||||
ViewFilter::NotesAndReplies => {
|
||||
tr!("Notes & Replies", "Label for notes and replies filter")
|
||||
tr!(
|
||||
i18n,
|
||||
"Notes & Replies",
|
||||
"Label for notes and replies filter"
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user