commit bae70595b2e5955ad23778b2068c19f11c5c5aec parent d9c8875497732c06ecc1f25d84ec760c742d266d Author: Marcel <mtrnord1@gmail.com> Date: Sat, 6 Jun 2020 20:25:42 +0200 Allow translations of the login page Took 15 minutes Diffstat:
24 files changed, 228 insertions(+), 27 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml @@ -34,7 +34,8 @@ pulldown-cmark = "0.7.1" # Translations tr = { version = "0.1.3", default-features = false, features = ["gettext"]} -i18n-embed = { version = "0.4", features = ["web-sys-requester"]} +i18n-embed = { version = "0.4", features = ["web-sys-requester"] } +rust-embed = "5" [dev-dependencies] wasm-bindgen-test = "0.3" diff --git a/i18n.toml b/i18n.toml @@ -1,6 +1,6 @@ # (Required) The locale/language identifier of the language used in the source # code. -src_locale = "en" +src_locale = "en-US" # (Required) The locales that the software will be translated into. target_locales = ["de"] diff --git a/i18n/po/de/daydream.po b/i18n/po/de/daydream.po @@ -0,0 +1,19 @@ +#. The URL Field of the Login page +#: src/app/views/login.rs:78 src/app/views/login.rs:91 +msgid "Homeserver URL" +msgstr "" + +#. The Matrix ID Field of the Login page +#: src/app/views/login.rs:104 src/app/views/login.rs:116 +msgid "MXID" +msgstr "" + +#. The Password Field of the Login page +#: src/app/views/login.rs:129 src/app/views/login.rs:142 +msgid "Password" +msgstr "" + +#. The Login Button of the Login page +#: src/app/views/login.rs:157 +msgid "Login" +msgstr "" diff --git a/i18n/pot/daydream.pot b/i18n/pot/daydream.pot @@ -0,0 +1,38 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE daydream'S COPYRIGHT HOLDER +# This file is distributed under the same license as the daydream package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: daydream 0.1.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. The URL Field of the Login page +#: src/app/views/login.rs:78 src/app/views/login.rs:91 +msgid "Homeserver URL" +msgstr "" + +#. The Matrix ID Field of the Login page +#: src/app/views/login.rs:104 src/app/views/login.rs:116 +msgid "MXID" +msgstr "" + +#. The Password Field of the Login page +#: src/app/views/login.rs:129 src/app/views/login.rs:142 +msgid "Password" +msgstr "" + +#. The Login Button of the Login page +#: src/app/views/login.rs:157 +msgid "Login" +msgstr "" diff --git a/i18n/pot/src/app/components/event_list.pot b/i18n/pot/src/app/components/event_list.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/components/events/image.pot b/i18n/pot/src/app/components/events/image.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/components/events/mod.pot b/i18n/pot/src/app/components/events/mod.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/components/events/notice.pot b/i18n/pot/src/app/components/events/notice.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/components/events/text.pot b/i18n/pot/src/app/components/events/text.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/components/events/video.pot b/i18n/pot/src/app/components/events/video.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/components/mod.pot b/i18n/pot/src/app/components/mod.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/components/room_list.pot b/i18n/pot/src/app/components/room_list.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/matrix/mod.pot b/i18n/pot/src/app/matrix/mod.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/matrix/sync.pot b/i18n/pot/src/app/matrix/sync.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/matrix/types.pot b/i18n/pot/src/app/matrix/types.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/mod.pot b/i18n/pot/src/app/mod.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -16,3 +16,23 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" + +#. The URL Field of the Login page +#: ./src/app/views/login.rs:78 ./src/app/views/login.rs:91 +msgid "Homeserver URL" +msgstr "" + +#. The Matrix ID Field of the Login page +#: ./src/app/views/login.rs:104 ./src/app/views/login.rs:116 +msgid "MXID" +msgstr "" + +#. The Password Field of the Login page +#: ./src/app/views/login.rs:129 ./src/app/views/login.rs:142 +msgid "Password" +msgstr "" + +#. The Login Button of the Login page +#: ./src/app/views/login.rs:157 +msgid "Login" +msgstr "" diff --git a/i18n/pot/src/app/views/login.pot b/i18n/pot/src/app/views/login.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -16,3 +16,23 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" + +#. The URL Field of the Login page +#: ./src/app/views/login.rs:78 ./src/app/views/login.rs:91 +msgid "Homeserver URL" +msgstr "" + +#. The Matrix ID Field of the Login page +#: ./src/app/views/login.rs:104 ./src/app/views/login.rs:116 +msgid "MXID" +msgstr "" + +#. The Password Field of the Login page +#: ./src/app/views/login.rs:129 ./src/app/views/login.rs:142 +msgid "Password" +msgstr "" + +#. The Login Button of the Login page +#: ./src/app/views/login.rs:157 +msgid "Login" +msgstr "" diff --git a/i18n/pot/src/app/views/main_view.pot b/i18n/pot/src/app/views/main_view.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/app/views/mod.pot b/i18n/pot/src/app/views/mod.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -16,3 +16,23 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" + +#. The URL Field of the Login page +#: ./src/app/views/login.rs:78 ./src/app/views/login.rs:91 +msgid "Homeserver URL" +msgstr "" + +#. The Matrix ID Field of the Login page +#: ./src/app/views/login.rs:104 ./src/app/views/login.rs:116 +msgid "MXID" +msgstr "" + +#. The Password Field of the Login page +#: ./src/app/views/login.rs:129 ./src/app/views/login.rs:142 +msgid "Password" +msgstr "" + +#. The Login Button of the Login page +#: ./src/app/views/login.rs:157 +msgid "Login" +msgstr "" diff --git a/i18n/pot/src/constants.pot b/i18n/pot/src/constants.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/errors.pot b/i18n/pot/src/errors.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/i18n/pot/src/lib.pot b/i18n/pot/src/lib.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: daydream 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-06 17:49+0000\n" +"POT-Creation-Date: 2020-06-06 18:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -16,3 +16,23 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" + +#. The URL Field of the Login page +#: ./src/app/views/login.rs:78 ./src/app/views/login.rs:91 +msgid "Homeserver URL" +msgstr "" + +#. The Matrix ID Field of the Login page +#: ./src/app/views/login.rs:104 ./src/app/views/login.rs:116 +msgid "MXID" +msgstr "" + +#. The Password Field of the Login page +#: ./src/app/views/login.rs:129 ./src/app/views/login.rs:142 +msgid "Password" +msgstr "" + +#. The Login Button of the Login page +#: ./src/app/views/login.rs:157 +msgid "Login" +msgstr "" diff --git a/src/app/views/login.rs b/src/app/views/login.rs @@ -1,6 +1,8 @@ use yew::agent::{Dispatched, Dispatcher}; use yew::prelude::*; +use tr::tr; + use crate::app::matrix::{MatrixAgent, Request}; pub struct Login { @@ -69,38 +71,77 @@ impl Component for Login { <h1 class="title">{"Login"}</h1> <form class="uk-form-stacked uk-margin" onsubmit=self.link.callback(|e: FocusEvent| {e.prevent_default(); Msg::Login})> <div class="uk-margin"> - <label class="uk-form-label">{"Homeserver URL"}</label> + <label class="uk-form-label"> + { + tr!( + // The URL Field of the Login page + "Homeserver URL" + ) + } + </label> <div class="uk-form-controls"> <input class="uk-input" type="url" id="homeserver" - placeholder="Homeserver URL" + placeholder= + { + tr!( + // The URL Field of the Login page + "Homeserver URL" + ) + } value=&self.homeserver oninput=self.link.callback(|e: InputData| Msg::SetHomeserver(e.value)) /> </div> </div> <div class="uk-margin"> - <label class="uk-form-label">{"MXID/Username"}</label> + <label class="uk-form-label"> + { + tr!( + // The Matrix ID Field of the Login page + "MXID" + ) + } + </label> <div class="uk-form-controls"> <input class="uk-input" id="username" - placeholder="MXID/Username" + placeholder= + { + tr!( + // The Matrix ID Field of the Login page + "MXID" + ) + } value=&self.username oninput=self.link.callback(|e: InputData| Msg::SetUsername(e.value)) /> </div> </div> <div class="uk-margin"> - <label class="uk-form-label">{"Password"}</label> + <label class="uk-form-label"> + { + tr!( + // The Password Field of the Login page + "Password" + ) + } + </label> <div class="uk-form-controls"> <input class="uk-input" type="password" id="password" - placeholder="Password" + placeholder= + { + tr!( + // The Password Field of the Login page + "Password" + ) + } value=&self.password oninput=self.link.callback(|e: InputData| Msg::SetPassword(e.value)) /> @@ -109,7 +150,14 @@ impl Component for Login { <div class="uk-margin"> <div class="uk-form-controls"> - <button class="uk-button uk-button-primary">{ "Login" }</button> + <button class="uk-button uk-button-primary"> + { + tr!( + // The Login Button of the Login page + "Login" + ) + } + </button> </div> </div> </form> diff --git a/src/lib.rs b/src/lib.rs @@ -3,12 +3,20 @@ extern crate console_error_panic_hook; extern crate wee_alloc; use console_error_panic_hook::set_once as set_panic_hook; +use i18n_embed::{language_loader, I18nEmbed, WebLanguageRequester}; +use rust_embed::RustEmbed; use wasm_bindgen::prelude::*; mod app; mod constants; mod errors; +#[derive(RustEmbed, I18nEmbed)] +#[folder = "i18n/mo"] // path to the compiled localization resources +struct Translations; + +language_loader!(DaydreamLanguageLoader); + #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; @@ -19,6 +27,13 @@ pub fn run_app() -> Result<(), JsValue> { // it will do nothing. set_panic_hook(); wasm_logger::init(wasm_logger::Config::default()); + + let translations = Translations {}; + let language_loader = DaydreamLanguageLoader::new(); + let requested_languages = WebLanguageRequester::requested_languages(); + + i18n_embed::select(&language_loader, &translations, &requested_languages); + yew::start_app::<app::App>(); Ok(()) }