mirror of
https://github.com/Theaninova/mhlib.git
synced 2026-01-07 01:02:49 +00:00
translations
This commit is contained in:
@@ -30,8 +30,8 @@ func set_menu(name: String) -> void:
|
|||||||
button.connect(\"pressed\", callable.bindv(action.args))
|
button.connect(\"pressed\", callable.bindv(action.args))
|
||||||
|
|
||||||
for node in menu.find_children(\"*\"):
|
for node in menu.find_children(\"*\"):
|
||||||
if node.has_method(\"set_text\"):
|
if \"text\" in node:
|
||||||
node.text = translations.tr(node.text)
|
node.text = translations.get_message(node.text)
|
||||||
|
|
||||||
func _on_close_pressed() -> void:
|
func _on_close_pressed() -> void:
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
@@ -41,6 +41,9 @@ func _on_action_SetMenu(name: String) -> void:
|
|||||||
|
|
||||||
func _on_action_CheckStartGame() -> void:
|
func _on_action_CheckStartGame() -> void:
|
||||||
print(\"CheckStartGame\")
|
print(\"CheckStartGame\")
|
||||||
|
|
||||||
|
func _on_action_DisplayEndscreen() -> void:
|
||||||
|
get_tree().quit()
|
||||||
"
|
"
|
||||||
|
|
||||||
[node name="Root" type="MarginContainer"]
|
[node name="Root" type="MarginContainer"]
|
||||||
|
|||||||
10
rust/Cargo.lock
generated
10
rust/Cargo.lock
generated
@@ -156,6 +156,15 @@ version = "1.8.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "encoding_rs"
|
||||||
|
version = "0.8.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "exr"
|
name = "exr"
|
||||||
version = "1.6.3"
|
version = "1.6.3"
|
||||||
@@ -425,6 +434,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"binrw",
|
"binrw",
|
||||||
|
"encoding_rs",
|
||||||
"godot",
|
"godot",
|
||||||
"image",
|
"image",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ crate-type = ["cdylib", "lib"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
itertools = "0.10.5"
|
itertools = "0.10.5"
|
||||||
unicode-segmentation = "1.10.1"
|
unicode-segmentation = "1.10.1"
|
||||||
|
encoding_rs = "0.8.32"
|
||||||
binrw = "0.11.1"
|
binrw = "0.11.1"
|
||||||
serde = {version = "1.0.160", features = ["derive"]}
|
serde = {version = "1.0.160", features = ["derive"]}
|
||||||
serde-xml-rs = "0.6.0"
|
serde-xml-rs = "0.6.0"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use crate::formats::sprites::Sprites;
|
|||||||
use crate::formats::txt::{decrypt_txt, DecryptError};
|
use crate::formats::txt::{decrypt_txt, DecryptError};
|
||||||
use crate::formats::ui_xml::UiTag;
|
use crate::formats::ui_xml::UiTag;
|
||||||
use binrw::BinRead;
|
use binrw::BinRead;
|
||||||
|
use encoding_rs::WINDOWS_1252;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
@@ -82,7 +83,7 @@ where
|
|||||||
.file_stem()
|
.file_stem()
|
||||||
.and_then(OsStr::to_str)
|
.and_then(OsStr::to_str)
|
||||||
.ok_or(Error::Custom("Stem".to_string()))?;
|
.ok_or(Error::Custom("Stem".to_string()))?;
|
||||||
let decr = decrypt_txt(data.into_iter()).map_err(|e| Error::DecryptError(e))?;
|
let decr = decrypt_txt(data.into_iter()).map_err(Error::DecryptError)?;
|
||||||
if stem.starts_with("tile_collision") {
|
if stem.starts_with("tile_collision") {
|
||||||
Ok(DatafileFile::TileCollision(decr))
|
Ok(DatafileFile::TileCollision(decr))
|
||||||
} else if stem == "sprites" {
|
} else if stem == "sprites" {
|
||||||
@@ -94,8 +95,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"csv" => Ok(DatafileFile::Translations(
|
"csv" => Ok(DatafileFile::Translations(
|
||||||
String::from_utf8(data)
|
WINDOWS_1252
|
||||||
.unwrap()
|
.decode(data.as_slice())
|
||||||
|
.0
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(|l| l.trim())
|
.map(|l| l.trim())
|
||||||
.filter(|l| !l.is_empty())
|
.filter(|l| !l.is_empty())
|
||||||
|
|||||||
@@ -187,8 +187,16 @@ impl ResourceFormatLoaderVirtual for DatafileLoader {
|
|||||||
Ok(DatafileFile::Translations(translations)) => {
|
Ok(DatafileFile::Translations(translations)) => {
|
||||||
let mut translation = Translation::new();
|
let mut translation = Translation::new();
|
||||||
for (key, message) in translations {
|
for (key, message) in translations {
|
||||||
translation.add_message(key.into(), message.join("\n").into(), "".into());
|
translation.add_message(
|
||||||
|
format!("%{}%", key).into(),
|
||||||
|
message.join("\n").into(),
|
||||||
|
"".into(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
self.save_to_cache(
|
||||||
|
translation.share().upcast(),
|
||||||
|
format!("{}.res", datafile_path),
|
||||||
|
);
|
||||||
translation.to_variant()
|
translation.to_variant()
|
||||||
}
|
}
|
||||||
Ok(DatafileFile::Vorbis(vorbis)) => {
|
Ok(DatafileFile::Vorbis(vorbis)) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user