Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP proof of concept to add localization using fluent-rs #546

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ tracing-appender = "0.2.3"
urlencoding = "2.1.3"
open = "5.3.0"
url = "2.5"
fluent-resmgr = "0.0.7"
fluent-fallback = "0.7.1"
fluent = "0.16.1"
unic-langid = "0.9.5"

[dev-dependencies]
tempfile = "3.13.0"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/en-US/notedeck.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
universe-title = Universe with Fluent Translation
10 changes: 10 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ use std::path::Path;
use std::time::Duration;
use tracing::{error, info, trace, warn};

use fluent_resmgr::resource_manager::ResourceManager;

#[derive(Debug, Eq, PartialEq, Clone)]
pub enum DamusState {
Initializing,
Expand Down Expand Up @@ -69,6 +71,8 @@ pub struct Damus {
pub debug: bool,
pub since_optimize: bool,
pub textmode: bool,

pub res_mgr: ResourceManager,
}

fn handle_key_events(input: &egui::InputState, _pixels_per_point: f32, columns: &mut Columns) {
Expand Down Expand Up @@ -471,6 +475,8 @@ impl Damus {
let app_rect_handler = AppSizeHandler::new(&path);
let support = Support::new(&path);

let res_mgr = ResourceManager::new("./assets/translations/{locale}/{res_id}".into());

Self {
pool,
debug,
Expand All @@ -492,6 +498,7 @@ impl Damus {
path,
app_rect_handler,
support,
res_mgr,
}
}

Expand Down Expand Up @@ -557,6 +564,8 @@ impl Damus {

let config = Config::new().set_ingester_threads(2);

let res_mgr = ResourceManager::new("../assets/translations/{locale}/{res_id}".into());

Self {
debug,
unknown_ids: UnknownIds::default(),
Expand Down Expand Up @@ -585,6 +594,7 @@ impl Damus {
path,
app_rect_handler,
support,
res_mgr,
}
}

Expand Down
Loading
Loading