diff --git a/core/embed/rust/src/lib.rs b/core/embed/rust/src/lib.rs index 53f083458d..22d2ddd884 100644 --- a/core/embed/rust/src/lib.rs +++ b/core/embed/rust/src/lib.rs @@ -28,6 +28,8 @@ mod storage; mod time; #[cfg(feature = "ui_debug")] mod trace; +#[cfg(feature = "translations")] +pub mod translations; #[cfg(feature = "ui")] #[macro_use] diff --git a/core/embed/rust/src/ui/translations/crowdin.py b/core/embed/rust/src/translations/crowdin.py similarity index 100% rename from core/embed/rust/src/ui/translations/crowdin.py rename to core/embed/rust/src/translations/crowdin.py diff --git a/core/embed/rust/src/ui/translations/crowdin.yml b/core/embed/rust/src/translations/crowdin.yml similarity index 100% rename from core/embed/rust/src/ui/translations/crowdin.yml rename to core/embed/rust/src/translations/crowdin.yml diff --git a/core/embed/rust/src/ui/translations/cs.json b/core/embed/rust/src/translations/cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/cs.json rename to core/embed/rust/src/translations/cs.json diff --git a/core/embed/rust/src/ui/translations/en.json b/core/embed/rust/src/translations/en.json similarity index 100% rename from core/embed/rust/src/ui/translations/en.json rename to core/embed/rust/src/translations/en.json diff --git a/core/embed/rust/src/ui/translations/flash.rs b/core/embed/rust/src/translations/flash.rs similarity index 100% rename from core/embed/rust/src/ui/translations/flash.rs rename to core/embed/rust/src/translations/flash.rs diff --git a/core/embed/rust/src/ui/translations/fonts/font_pixeloperator_bold_8_cs.json b/core/embed/rust/src/translations/fonts/font_pixeloperator_bold_8_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_pixeloperator_bold_8_cs.json rename to core/embed/rust/src/translations/fonts/font_pixeloperator_bold_8_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_pixeloperator_bold_8_fr.json b/core/embed/rust/src/translations/fonts/font_pixeloperator_bold_8_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_pixeloperator_bold_8_fr.json rename to core/embed/rust/src/translations/fonts/font_pixeloperator_bold_8_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_pixeloperator_regular_8_cs.json b/core/embed/rust/src/translations/fonts/font_pixeloperator_regular_8_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_pixeloperator_regular_8_cs.json rename to core/embed/rust/src/translations/fonts/font_pixeloperator_regular_8_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_pixeloperator_regular_8_fr.json b/core/embed/rust/src/translations/fonts/font_pixeloperator_regular_8_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_pixeloperator_regular_8_fr.json rename to core/embed/rust/src/translations/fonts/font_pixeloperator_regular_8_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_pixeloperatormono_regular_8_cs.json b/core/embed/rust/src/translations/fonts/font_pixeloperatormono_regular_8_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_pixeloperatormono_regular_8_cs.json rename to core/embed/rust/src/translations/fonts/font_pixeloperatormono_regular_8_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_pixeloperatormono_regular_8_fr.json b/core/embed/rust/src/translations/fonts/font_pixeloperatormono_regular_8_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_pixeloperatormono_regular_8_fr.json rename to core/embed/rust/src/translations/fonts/font_pixeloperatormono_regular_8_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_roboto_bold_20_cs.json b/core/embed/rust/src/translations/fonts/font_roboto_bold_20_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_roboto_bold_20_cs.json rename to core/embed/rust/src/translations/fonts/font_roboto_bold_20_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_roboto_bold_20_fr.json b/core/embed/rust/src/translations/fonts/font_roboto_bold_20_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_roboto_bold_20_fr.json rename to core/embed/rust/src/translations/fonts/font_roboto_bold_20_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_roboto_regular_20_cs.json b/core/embed/rust/src/translations/fonts/font_roboto_regular_20_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_roboto_regular_20_cs.json rename to core/embed/rust/src/translations/fonts/font_roboto_regular_20_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_roboto_regular_20_fr.json b/core/embed/rust/src/translations/fonts/font_roboto_regular_20_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_roboto_regular_20_fr.json rename to core/embed/rust/src/translations/fonts/font_roboto_regular_20_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_robotomono_medium_20_cs.json b/core/embed/rust/src/translations/fonts/font_robotomono_medium_20_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_robotomono_medium_20_cs.json rename to core/embed/rust/src/translations/fonts/font_robotomono_medium_20_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_robotomono_medium_20_fr.json b/core/embed/rust/src/translations/fonts/font_robotomono_medium_20_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_robotomono_medium_20_fr.json rename to core/embed/rust/src/translations/fonts/font_robotomono_medium_20_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_tthoves_bold_17_cs.json b/core/embed/rust/src/translations/fonts/font_tthoves_bold_17_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_tthoves_bold_17_cs.json rename to core/embed/rust/src/translations/fonts/font_tthoves_bold_17_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_tthoves_bold_17_fr.json b/core/embed/rust/src/translations/fonts/font_tthoves_bold_17_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_tthoves_bold_17_fr.json rename to core/embed/rust/src/translations/fonts/font_tthoves_bold_17_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_tthoves_demibold_21_cs.json b/core/embed/rust/src/translations/fonts/font_tthoves_demibold_21_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_tthoves_demibold_21_cs.json rename to core/embed/rust/src/translations/fonts/font_tthoves_demibold_21_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_tthoves_demibold_21_fr.json b/core/embed/rust/src/translations/fonts/font_tthoves_demibold_21_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_tthoves_demibold_21_fr.json rename to core/embed/rust/src/translations/fonts/font_tthoves_demibold_21_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_tthoves_regular_21_cs.json b/core/embed/rust/src/translations/fonts/font_tthoves_regular_21_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_tthoves_regular_21_cs.json rename to core/embed/rust/src/translations/fonts/font_tthoves_regular_21_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_tthoves_regular_21_fr.json b/core/embed/rust/src/translations/fonts/font_tthoves_regular_21_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_tthoves_regular_21_fr.json rename to core/embed/rust/src/translations/fonts/font_tthoves_regular_21_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_unifont_bold_16_cs.json b/core/embed/rust/src/translations/fonts/font_unifont_bold_16_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_unifont_bold_16_cs.json rename to core/embed/rust/src/translations/fonts/font_unifont_bold_16_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_unifont_bold_16_fr.json b/core/embed/rust/src/translations/fonts/font_unifont_bold_16_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_unifont_bold_16_fr.json rename to core/embed/rust/src/translations/fonts/font_unifont_bold_16_fr.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_unifont_regular_16_cs.json b/core/embed/rust/src/translations/fonts/font_unifont_regular_16_cs.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_unifont_regular_16_cs.json rename to core/embed/rust/src/translations/fonts/font_unifont_regular_16_cs.json diff --git a/core/embed/rust/src/ui/translations/fonts/font_unifont_regular_16_fr.json b/core/embed/rust/src/translations/fonts/font_unifont_regular_16_fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fonts/font_unifont_regular_16_fr.json rename to core/embed/rust/src/translations/fonts/font_unifont_regular_16_fr.json diff --git a/core/embed/rust/src/ui/translations/fr.json b/core/embed/rust/src/translations/fr.json similarity index 100% rename from core/embed/rust/src/ui/translations/fr.json rename to core/embed/rust/src/translations/fr.json diff --git a/core/embed/rust/src/ui/translations/generated/mod.rs b/core/embed/rust/src/translations/generated/mod.rs similarity index 100% rename from core/embed/rust/src/ui/translations/generated/mod.rs rename to core/embed/rust/src/translations/generated/mod.rs diff --git a/core/embed/rust/src/ui/translations/generated/translated_string.rs b/core/embed/rust/src/translations/generated/translated_string.rs similarity index 100% rename from core/embed/rust/src/ui/translations/generated/translated_string.rs rename to core/embed/rust/src/translations/generated/translated_string.rs diff --git a/core/embed/rust/src/ui/translations/generated/translated_string.rs.mako b/core/embed/rust/src/translations/generated/translated_string.rs.mako similarity index 100% rename from core/embed/rust/src/ui/translations/generated/translated_string.rs.mako rename to core/embed/rust/src/translations/generated/translated_string.rs.mako diff --git a/core/embed/rust/src/ui/translations/micropython.rs b/core/embed/rust/src/translations/micropython.rs similarity index 97% rename from core/embed/rust/src/ui/translations/micropython.rs rename to core/embed/rust/src/translations/micropython.rs index 2132bf51e8..893becbc15 100644 --- a/core/embed/rust/src/ui/translations/micropython.rs +++ b/core/embed/rust/src/translations/micropython.rs @@ -1,7 +1,7 @@ use crate::{ error::Error, micropython::{ - buffer::get_buffer, + buffer::{get_buffer, StrBuffer}, ffi, gc::Gc, map::Map, @@ -13,7 +13,13 @@ use crate::{ }, }; -use super::TranslatedString; +use super::translated_string::TranslatedString; + +pub fn tr(item: TranslatedString) -> StrBuffer { + // SAFETY: + let stored_translations = item.translate(unsafe { super::flash::get() }); + StrBuffer::alloc(stored_translations) +} #[repr(C)] pub struct TrObj { diff --git a/core/embed/rust/src/ui/translations/mod.rs b/core/embed/rust/src/translations/mod.rs similarity index 98% rename from core/embed/rust/src/ui/translations/mod.rs rename to core/embed/rust/src/translations/mod.rs index 97e1d30669..26e4996ca7 100644 --- a/core/embed/rust/src/ui/translations/mod.rs +++ b/core/embed/rust/src/translations/mod.rs @@ -4,7 +4,9 @@ mod generated; mod micropython; mod translated_string; -pub use translated_string::TranslatedString; +pub use translated_string::TranslatedString as TR; +#[cfg(feature = "micropython")] +pub use micropython::tr; use crate::{error::Error, io::InputStream}; use core::{ptr::null, str}; diff --git a/core/embed/rust/src/ui/translations/order.json b/core/embed/rust/src/translations/order.json similarity index 100% rename from core/embed/rust/src/ui/translations/order.json rename to core/embed/rust/src/translations/order.json diff --git a/core/embed/rust/src/ui/translations/order.py b/core/embed/rust/src/translations/order.py similarity index 100% rename from core/embed/rust/src/ui/translations/order.py rename to core/embed/rust/src/translations/order.py diff --git a/core/embed/rust/src/ui/translations/translated_string.rs b/core/embed/rust/src/translations/translated_string.rs similarity index 100% rename from core/embed/rust/src/ui/translations/translated_string.rs rename to core/embed/rust/src/translations/translated_string.rs diff --git a/core/embed/rust/src/ui/mod.rs b/core/embed/rust/src/ui/mod.rs index 4277fd05dc..0b57e03061 100644 --- a/core/embed/rust/src/ui/mod.rs +++ b/core/embed/rust/src/ui/mod.rs @@ -9,8 +9,6 @@ pub mod event; pub mod geometry; pub mod lerp; pub mod screens; -#[cfg(feature = "translations")] -pub mod translations; #[macro_use] pub mod util;