More translations

This commit is contained in:
IQuant 2024-06-09 17:16:33 +03:00
parent 49ea071608
commit 7722b25ad5
8 changed files with 88 additions and 31 deletions

View file

@ -1966,7 +1966,7 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]]
name = "noita-proxy"
version = "0.10.0"
version = "0.11.0"
dependencies = [
"bincode",
"bitcode",
@ -1976,6 +1976,7 @@ dependencies = [
"eframe",
"egui-file-dialog",
"egui_extras",
"fluent-bundle",
"fluent-templates",
"image 0.25.1",
"lz4_flex",

View file

@ -3,7 +3,7 @@ members = ["tangled"]
[package]
name = "noita-proxy"
version = "0.10.0"
version = "0.11.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -36,6 +36,7 @@ bincode = "1.3.3"
rustc-hash = "1.1.0"
fluent-templates = "0.9.4"
unic-langid = { version = "0.9.5", features = ["serde"] }
fluent-bundle = "0.15.3"
[profile.dev]
opt-level = 1

View file

@ -14,9 +14,29 @@ lang_picker = Choose a language
button_confirm = Confirm
button_continue = Continue
button_retry = Retry
button_select_again = Select again
button_set_lang = Select language
modman = Mod manager
modman_found_automatically = Found a path automatically:
modman_use_this = Use this one
modman_select_manually = Select manually
modman_select_manually = Select manually
modman_path_to_exe = Select path to noita.exe
modman_invalid_path = This path is not valid
modman_downloading = Downloading mod...
modman_receiving_rel_info = Receiving release info...
modman_unpacking = Unpacking mod...
modman_installed = Mod has been installed!
modman_will_install_to = Proxy will install the mod to:
modman_another_path = Select a different path
player_host = Host
player_me = Me
player_player = Player
version_latest = (latest)
version_check_failed = (could not check for updates)
version_checking = (checking for updates)
version_new_available = Update available to { $new_version }

View file

@ -14,9 +14,29 @@ lang_picker = Выберите язык
button_confirm = Подтвердить
button_continue = Продолжить
button_retry = Попробовать снова
button_select_again = Выбрать ещё раз
button_set_lang = Выбрать язык
modman = Автоустановка мода
modman_found_automatically = Автоматически найденный путь:
modman_use_this = Использовать этот
modman_select_manually = Выбрать вручную
modman_select_manually = Выбрать вручную
modman_path_to_exe = Выберите путь к noita.exe
modman_invalid_path = Этот путь не подходит
modman_downloading = Идёт скачивание мода...
modman_receiving_rel_info = Идёт получение информации о релизе...
modman_unpacking = Идёт распаковка мода...
modman_installed = Мод установлен!
modman_will_install_to = Прокси установит мод в:
modman_another_path = Выбрать другой путь
player_host = Хост
player_me = Я
player_player = Игрок
version_latest = (последняя)
version_check_failed = (не удалось проверить обновления)
version_checking = (проверка обновлений)
version_new_available = Доступно обновление до { $new_version }

View file

@ -1,5 +1,6 @@
use std::sync::RwLock;
use std::{collections::HashMap, sync::RwLock};
use fluent_bundle::FluentValue;
use fluent_templates::{LanguageIdentifier, Loader};
use unic_langid::langid;
@ -48,3 +49,13 @@ pub fn tr(text_id: &str) -> String {
.try_lookup(&LANG.read().unwrap(), text_id)
.unwrap_or_else(|| text_id.to_string())
}
pub fn tr_a(text_id: &str, args: &[(&str, FluentValue)]) -> String {
let mut args_hm = HashMap::new();
for (key, arg) in args.iter() {
args_hm.insert(key, arg.clone());
}
LOCALES
.try_lookup_with_args(&LANG.read().unwrap(), text_id, &args_hm)
.unwrap_or_else(|| text_id.to_string())
}

View file

@ -365,7 +365,7 @@ impl eframe::App for App {
let username = steam.get_user_name(peer.into());
let avatar = steam.get_avatar(ctx, peer.into());
if let Some(avatar) = avatar {
avatar.display_with_labels(ui, &username, role);
avatar.display_with_labels(ui, &username, &role);
ui.add_space(5.0);
} else {
ui.label(&username);
@ -413,7 +413,7 @@ impl eframe::App for App {
}
}
AppState::ModManager => {
egui::Window::new("Mod manager")
egui::Window::new(tr("modman"))
.auto_sized()
.anchor(Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
@ -464,14 +464,14 @@ impl eframe::App for App {
}
}
fn peer_role(peer: net::omni::OmniPeerId, netman: &Arc<net::NetManager>) -> &str {
fn peer_role(peer: net::omni::OmniPeerId, netman: &Arc<net::NetManager>) -> String {
if peer == netman.peer.host_id() {
"Host"
tr("player_host")
} else {
if Some(peer) == netman.peer.my_id() {
"Me"
tr("player_me")
} else {
"Player"
tr("player_player")
}
}
}

View file

@ -46,7 +46,7 @@ impl Default for Modmanager {
state: Default::default(),
file_dialog: FileDialog::default()
.anchor(Align2::CENTER_CENTER, [0.0, 0.0])
.title("Select path to noita.exe"),
.title(&tr("modman_path_to_exe")),
}
}
}
@ -130,8 +130,8 @@ impl Modmanager {
}
}
State::InvalidPath => {
ui.label("This path is not valid");
if ui.button("Select again").clicked() {
ui.label(tr("modman_invalid_path"));
if ui.button(tr("button_select_again")).clicked() {
self.select_noita_file();
}
}
@ -156,10 +156,8 @@ impl Modmanager {
}
State::ConfirmInstall => {
let mod_path = settings.mod_path();
ui.label(format!(
"Proxy will install the mod to {}",
mod_path.display()
));
ui.label(tr("modman_will_install_to"));
ui.label(mod_path.display().to_string());
ui.horizontal(|ui| {
if ui.button(tr("button_confirm")).clicked() {
let download_path = PathBuf::from("mod.zip");
@ -174,13 +172,13 @@ impl Modmanager {
self.state = State::DownloadMod(promise)
}
if ui.button("Select a different path").clicked() {
if ui.button(tr("modman_another_path")).clicked() {
self.select_noita_file()
}
});
}
State::DownloadMod(promise) => {
ui.label("Downloading mod...");
ui.label(tr("modman_downloading"));
match promise.ready() {
Some(Ok(downloader)) => {
downloader.show_progress(ui);
@ -200,14 +198,14 @@ impl Modmanager {
}
Some(Err(err)) => self.state = State::ReleasesError(err.clone()),
None => {
ui.label("Receiving release info...");
ui.label(tr("modman_receiving_rel_info"));
ui.spinner();
}
}
}
State::UnpackMod(promise) => match promise.ready() {
Some(Ok(_)) => {
ui.label("Mod has been installed!");
ui.label(tr("modman_installed"));
if ui.button(tr("button_continue")).clicked() {
self.state = State::Done;
};
@ -216,18 +214,18 @@ impl Modmanager {
self.state = State::ReleasesError(err.clone());
}
None => {
ui.label("Unpacking mod");
ui.label(tr("modman_unpacking"));
}
},
State::Error(err) => {
ui.label(format!("Encountered an error: {}", err));
if ui.button("Retry").clicked() {
if ui.button(tr("button_retry")).clicked() {
self.state = State::JustStarted;
}
}
State::ReleasesError(err) => {
ui.label(format!("Encountered an error: {}", err));
if ui.button("Retry").clicked() {
if ui.button(tr("button_retry")).clicked() {
self.state = State::JustStarted;
}
}

View file

@ -10,7 +10,10 @@ use poll_promise::Promise;
use reqwest::blocking::Client;
use tracing::info;
use crate::releases::{get_latest_release, Downloader, ReleasesError, Version};
use crate::{
lang::{tr, tr_a},
releases::{get_latest_release, Downloader, ReleasesError, Version},
};
struct VersionCheckResult {
newest: Version,
@ -57,24 +60,27 @@ impl SelfUpdateManager {
newest: _,
ord: Ordering::Equal,
})) => {
ui.label("(latest)");
ui.label(tr("version_latest"));
}
Some(&Some(VersionCheckResult { newest, ord: _ })) => {
if ui
.small_button(format!("Update available to {}", newest))
.small_button(tr_a(
"version_new_available",
&[("new_version", newest.to_string().into())],
))
.clicked()
{
self.request_update = true;
}
}
Some(None) => {
ui.label("(could not check for updates)");
ui.label(tr("version_check_failed"));
}
None => {
ui.label("(checking for updates)");
ui.label(tr("version_checking"));
}
}
ui.label(concat!("Noita Proxy version v", env!("CARGO_PKG_VERSION"),));
ui.label(concat!("Noita Proxy v", env!("CARGO_PKG_VERSION"),));
});
}