Skip to content
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
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"vscode": {
"extensions": [
"rust-lang.rust-analyzer",
"bungcip.better-toml",
"serayuzgur.crates",
"tamasfe.even-better-toml",
"fill-labs.dependi",
"statiolake.vscode-rustfmt"
]
}
Expand Down
7 changes: 7 additions & 0 deletions .vscode/i18n-ally-custom-framework.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
languageIds:
- rust

usageMatchRegex:
- "[^\\w\\d]t!\\([\\s\\n\\r]*['\"]({key})['\"]"

monopoly: true
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
"--message-format=json",
"--all-features",
],
"i18n-ally.localesPaths": [
"locales"
],
}
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ log = "0.4.17"
byte-unit = "4.0.18"
zip = { version = "0.6", default-features = false, features = ["deflate"] }
anyhow = "1.0.72"
rust-i18n = "3.1.2"

[patch.crates-io]
native-tls = { git = "https://github.com/skyline-rs/rust-native-tls", branch = "switch-timeout-panic" }
Expand All @@ -64,6 +65,11 @@ plugin-dependencies = [
{ name = "libparam_hook.nro", url = "https://github.com/ultimate-research/params-hook-plugin/releases/download/v0.1.1/libparam_hook.nro" },
]

[package.metadata.i18n]
load-path = "locales"
default-locale = "en_us"
available-locales = ["en_us", "fr"]

[features]
outside_training_mode = []
layout_arc_from_file = []
113 changes: 113 additions & 0 deletions locales/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"common": {
"Welcome!": "welcome!",
"plugin_title": "Training Modpack",
"hold_button": "Hold %{button}",
"open_menu": "Open Menu",
"language": "Language",
"modpack_menu": "Modpack Menu",
"welcome": "Welcome!",
"yes": "yes",
"no": "no",
"on": "on",
"off": "off"
},
"buttons": {
"start": "Start",
"a": "a",
"b": "b",
"x": "x",
"y": "y",
"l": "l",
"r": "r",
"z": "z",
"dpad_Down": "dpad down",
"dpad_Left": "dpad left",
"dpad_Right": "dpad right",
"dpad_Up": "dpad up",
"pro": {
"l": "pro l",
"r": "pro r; gcc z",
"zl_gcc_l": "pro zl; gcc l",
"zr_gcc_r": "pro zr; gcc r"
},
"analog_stick": {
"up": "up",
"down": "down",
"left": "left",
"right": "right"
}
},
"menus": {
"mash_settings": {
"tab_name": "Mash Settings",
"mash_toggles": {
"title": "Mash Toggles",
"description": "Actions to be performed as soon as possible"
},
"followup_toggles": {
"title": "Followup Toggles",
"description": "Actions to be performed after a mash option"
},
"mash_triggers": {
"title": "Mash Triggers",
"description": "Configure what causes the cpu to perform a mash option"
},
"attack_angle": {
"title": "Attack Angle",
"description": "For attacks that can be angled, such as some forward tilts"
},
"throw_options": {
"title": "Throw Options",
"description": "Throw to be performed when a grab is landed"
},
"throw_delay": {
"title": "Throw Delay",
"description": "How many frames to delay the throw option"
},
"pummel_delay": {
"title": "Pummel Delay",
"description": "How many frames after a grab to wait before starting to pummel"
},
"falling_aerials": {
"title": "Falling Aerials",
"description": "Should aerials be performed when rising or when falling"
},
"full_hop": {
"title": "Full Hop",
"description": "Should the cpu perform a full hop or a short hop"
},
"aerial_delay": {
"title": "Aerial Delay",
"description": "How long to delay a mash aerial attack"
},
"fast_fall": {
"title": "Fast Fall",
"description": "Should the cpu fastfall during a jump"
},
"fast_fall_delay": {
"title": "Fast Fall Delay",
"description": "How many frames the cpu should delay their fastfall"
},
"oos_offset": {
"title": "OoS Offset",
"description": "How many times the cpu shield can be hit before performing a mash option"
},
"reaction_time": {
"title": "Reaction Time",
"description": "How many frames to delay before performing a mash option"
}
},
"misc_settings": {
"tab_name": "Misc Settings",
"language": {
"title": "Language",
"help_text": "Language: Select your preferred language",
"locales": {
"en_us": "English (US)",
"fr": "French"
}
}
}
}
}
99 changes: 99 additions & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"common": {
"plugin_title": "Modpack d'Entraînement'",
"hold_button": "Maintenir %{button}",
"open_menu": "Ouvrir le Menu",
"language": "Langue",
"modpack_menu": "Menu du Modpack",
"yes": "Oui",
"no": "Non",
"on": "Activé",
"off": "Désactivé"
},
"buttons": {
"start": "Start",
"a": "A",
"b": "B",
"x": "X",
"y": "Y",
"l": "L",
"r": "R",
"z": "z",
"dpad_Up": "dpad haut",
"dpad_Down": "dpad bas",
"dpad_Left": "dpad gauche",
"dpad_Right": "dpad droite",
"pro": {
"l": "pro l",
"r": "pro r; gcc z",
"zl_gcc_l": "pro zl; gcc l",
"zr_gcc_r": "pro zr; gcc r"
},
"analog_stick": {
"up": "haut",
"down": "bas",
"left": "gauche",
"right": "droite"
}
},
"menus": {
"mash_settings": {
"mash_toggles": {
"title": "Options de Mashing",
"description": "Mashing à effectuer dès que possible"
},
"followup_toggles": {
"title": "Options de Followups",
"description": "Followups à effectuer dès que possible"
},
"mash_triggers": {
"title": "Déclencheurs de Mashing",
"description": "Configurer les actions qui feront réagir le CPU."
},
"attack_angle": {
"title": "Angle d'Attaque",
"description": "Modifie l'angle des attaques qui peuvent être orientées, par ex. le F-Tilt de Falco."
},
"throw_options": {
"title": "Options de Grabs",
"description": "Définit dans quelle direction le CPU doit faire un grab."
},
"throw_delay": {
"title": "Délai de Grab",
"description": "De combien de frames retarder le grab."
},
"pummel_delay": {
"title": "Délai de Pummel",
"description": "Combien de frames attendre avant de pummel pendant un grab."
},
"falling_aerials": {
"title": "Aerials descendants",
"description": "Définit si les Aerials doivent se faire pendant la montée ou la descente d'un saut."
},
"full_hop": {
"title": "Saut",
"description": "Définit si le CPU doit faire un Saut ou un Demi-Saut"
},
"aerial_delay": {
"title": "Délai d'Aerial",
"description": "De combien de frames retarder l'Aerial."
},
"fast_fall": {
"title": "Fast Fall",
"description": "Définit si le CPU doit Fast Fall pendant son saut."
},
"fast_fall_delay": {
"title": "Délai de Fast Fall",
"description": "De combien de frames retarder le Fast Fall."
},
"oos_offset": {
"title": "Coups avant Out of Shield",
"description": "Combien de fois le shield doit être touché avant que l'option Out of Shield se lance."
},
"reaction_time": {
"title": "Temps de réaction",
"description": "De combien de frames retarder l'option de mashing."
}
}
}
}
85 changes: 85 additions & 0 deletions src/common/localization.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
use crate::common::MENU;
use crate::logging::*;
use crate::training::ui::notifications::notification;
use training_mod_consts::Locale;
use training_mod_sync::*;

#[repr(u8)]
#[derive(Debug)]
pub enum ModLanguageId {
English,
French,
}

impl From<u8> for ModLanguageId {
fn from(byte: u8) -> Self {
match byte {
0 => Self::English,
1 => Self::French,
_ => Self::English,
}
}
}

impl From<&str> for ModLanguageId {
fn from(locale_code: &str) -> Self {
match locale_code {
"en_us" => Self::English,
"fr" => Self::French,
_ => Self::English,
}
}
}

impl From<Locale> for ModLanguageId {
fn from(locale_code: Locale) -> Self {
match locale_code {
Locale::ENGLISH_US => Self::English,
Locale::FRENCH => Self::French,
_ => Self::English,
}
}
}

impl ModLanguageId {
pub fn get_locale_code(&self) -> &str {
match self {
ModLanguageId::English => "en_us",
ModLanguageId::French => "fr",
}
}
}

pub fn init() {
info!("Initializing localization");
handle_language_change();
info!(
"Initialized localization with {:#?}",
ModLanguageId::from(read(&MENU).selected_locale)
);
}

pub fn set_language() {
let locale: ModLanguageId = ModLanguageId::from(read(&MENU).selected_locale);
info!("Setting language to {:?}", locale);

let locale_code = locale.get_locale_code();

if rust_i18n::available_locales!().contains(&locale_code) {
rust_i18n::set_locale(locale_code);

notification("Language".to_string(), locale_code.to_string(), 360);
} else {
info!("{} not found using en_us instead.", locale_code);
rust_i18n::set_locale("en_us");
}
}

pub fn handle_language_change() {
let has_locale_changed =
*ModLanguageId::from(read(&MENU).selected_locale).get_locale_code() != *rust_i18n::locale();

if has_locale_changed {
set_language();
}
}
1 change: 1 addition & 0 deletions src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod dev_config;
pub mod dialog;
pub mod events;
pub mod input;
pub mod localization;
pub mod menu;
pub mod offsets;
pub mod raygun_printer;
Expand Down
Loading