diff --git a/Cargo.lock b/Cargo.lock index b97c1aec5..dafecc03d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1035,10 +1035,12 @@ version = "0.1.0" dependencies = [ "gam", "graphics-server", + "locales", "log", "log-server", "num-derive", "num-traits", + "tts-frontend", "xous", "xous-ipc 0.9.7", "xous-names", diff --git a/apps/hello/Cargo.toml b/apps/hello/Cargo.toml index 2e25ee12f..961a133ea 100644 --- a/apps/hello/Cargo.toml +++ b/apps/hello/Cargo.toml @@ -13,3 +13,9 @@ log-server = { path = "../../services/log-server" } xous-names = { path = "../../services/xous-names" } gam = {path = "../../services/gam" } graphics-server = {path = "../../services/graphics-server" } +locales = {path = "../../locales"} +tts-frontend = {path="../../services/tts"} + +[features] +tts = [] +default = [] diff --git a/apps/hello/locales/i18n.json b/apps/hello/locales/i18n.json new file mode 100644 index 000000000..19f8bf49e --- /dev/null +++ b/apps/hello/locales/i18n.json @@ -0,0 +1,8 @@ +{ + "helloworld.hello": { + "en": "Hello World!", + "ja": "Hello World!", + "zh": "大家好!", + "en-tts": "Hello World!" + } +} \ No newline at end of file diff --git a/apps/hello/src/main.rs b/apps/hello/src/main.rs index d126d1054..20d9efa82 100644 --- a/apps/hello/src/main.rs +++ b/apps/hello/src/main.rs @@ -5,6 +5,9 @@ use core::fmt::Write; use graphics_server::api::GlyphStyle; use graphics_server::{DrawStyle, Gid, PixelColor, Point, Rectangle, TextBounds, TextView}; use num_traits::*; +use locales::t; +#[cfg(feature = "tts")] +use tts_frontend::*; /// Basic 'Hello World!' application that draws a simple /// TextView to the screen. @@ -26,6 +29,8 @@ struct Hello { gam: gam::Gam, _gam_token: [u32; 4], screensize: Point, + #[cfg(feature = "tts")] + tts: TtsFrontend, } impl Hello { @@ -57,6 +62,8 @@ impl Hello { _gam_token: gam_token, content, screensize, + #[cfg(feature = "tts")] + tts: TtsFrontend::new(xns).unwrap(), } } @@ -98,7 +105,9 @@ impl Hello { text_view.clear_area = true; text_view.rounded_border = Some(3); text_view.style = GlyphStyle::Regular; - write!(text_view.text, "{}", "Hello world!").expect("Could not write to text view"); + write!(text_view.text, "{}", t!("helloworld.hello", xous::LANG)).expect("Could not write to text view"); + #[cfg(feature="tts")] + self.tts.tts_simple(t!("helloworld.hello", xous::LANG)).unwrap(); self.gam .post_textview(&mut text_view)