diff --git a/l10n-db/i18n/SaveSettings.toml b/l10n-db/i18n/SaveSettings.toml index 3f8d37d..384705e 100644 --- a/l10n-db/i18n/SaveSettings.toml +++ b/l10n-db/i18n/SaveSettings.toml @@ -1,22 +1,22 @@ key = "SaveSettings" description = "This is a label on a button which will save the settings when clicked" -[variants.en] -locale = "en" -content = "Save Settings" -modified = "2025-02-22T23:44:18.874218939Z" - [variants.eo] locale = "eo" content = "Konservi Agordojn" modified = "2025-02-24T19:32:11.246639077Z" -[variants.de] -locale = "de" -content = "Einstellungen Speichern" -modified = "2025-02-24T19:33:19.516005843Z" - [variants.es] locale = "es" content = "Guardar Configuraciones" modified = "2025-02-24T19:33:23.861329923Z" + +[variants.en] +locale = "en" +content = "Save Settings" +modified = "2025-02-22T23:44:18.874218939Z" + +[variants.de] +locale = "de" +content = "Einstellungen Speichern" +modified = "2025-02-24T19:33:19.516005843Z" diff --git a/l10n-db/i18n/TimeDistance.toml b/l10n-db/i18n/TimeDistance.toml index 3525af3..aa6ffb2 100644 --- a/l10n-db/i18n/TimeDistance.toml +++ b/l10n-db/i18n/TimeDistance.toml @@ -1,22 +1,22 @@ key = "TimeDistance" description = "A summary of a workout or many workouts that involve a time and a distance" -[variants.en] -locale = "en" -content = "{distance} of {activity} in {hours, plural, =1 {{hours} hour} other {{hours} hours}} and {minutes, plural, =1 {{minutes} minute} other {{minutes} minutes}}" -modified = "2025-02-24T14:09:17.361641899Z" +[variants.es] +locale = "es" +content = "{distance} de {activity} en {hours, plural, one {}=1 {{hours} hora} other {{hours} horas}} y {minutes, plural, one {}=1 {{minutes} minuto} other {{minutes} minutos}}" +modified = "2025-02-24T19:33:23.861604738Z" [variants.eo] locale = "eo" content = "{distance} de {activity} en {hours, plural, =1 {{hours} horo} other {{hours} horoj}} {minutes, plural, =1 {{minutes} minuto} other {{minutes} minutoj}}" modified = "2025-02-24T19:32:11.246943602Z" +[variants.en] +locale = "en" +content = "{distance} of {activity} in {hours, plural, =1 {{hours} hour} other {{hours} hours}} and {minutes, plural, =1 {{minutes} minute} other {{minutes} minutes}}" +modified = "2025-02-24T14:09:17.361641899Z" + [variants.de] locale = "de" content = "{distance} von {activity} in {hours, plural, one {}=1 {{hours} Stunde} other {{hours} Stunden}} und {minutes, plural, one {}=1 {{minutes} Minute} other {{minutes} Minuten}}" modified = "2025-02-24T19:33:19.516210807Z" - -[variants.es] -locale = "es" -content = "{distance} de {activity} en {hours, plural, one {}=1 {{hours} hora} other {{hours} horas}} y {minutes, plural, one {}=1 {{minutes} minuto} other {{minutes} minutos}}" -modified = "2025-02-24T19:33:23.861604738Z" diff --git a/l10n-db/i18n/Welcome.toml b/l10n-db/i18n/Welcome.toml index 47cc700..db36ae3 100644 --- a/l10n-db/i18n/Welcome.toml +++ b/l10n-db/i18n/Welcome.toml @@ -1,16 +1,16 @@ key = "Welcome" description = "This is a welcome content that will be shown on first app opening, before configuration." +[variants.en] +locale = "en" +content = "Welcome to FitnessTrax, the privacy-centered fitness tracker" +modified = "2025-02-25T02:12:25.757240004Z" + [variants.eo] locale = "eo" content = "Bonvenon al FitnessTrax" modified = "2025-02-24T19:32:11.246407627Z" -[variants.en] -locale = "en" -content = "Welcome to FitnessTrax" -modified = "2025-02-22T23:43:24.786544124Z" - [variants.es] locale = "es" content = "Bienvenido a FitnessTrax" diff --git a/l10n-db/src/bin/main.rs b/l10n-db/src/bin/main.rs index f7cbd54..56a8f0a 100644 --- a/l10n-db/src/bin/main.rs +++ b/l10n-db/src/bin/main.rs @@ -7,7 +7,11 @@ use std::{ use clap::{Parser, Subcommand}; use icu_locid::{langid, LanguageIdentifier}; -use l10n_db::{self, js, read_file, xliff::{self, import_file}, Bundle, Editor, ReadError}; +use l10n_db::{ + self, js, read_file, + xliff::{self, import_file}, + Bundle, Editor, ReadError, +}; use serde::Deserialize; #[derive(Parser)] @@ -41,6 +45,7 @@ enum Commands { #[arg(short, long)] locale: Option, }, + Report, } #[derive(Debug, Deserialize)] @@ -56,6 +61,44 @@ fn edit_key(bundle: &mut Bundle, key: String, locale: LanguageIdentifier, editor bundle.save(); } +#[derive(Clone, Debug, Default)] +struct Report { + keys: Vec, + source_deleted: Vec, + out_of_date: Vec, +} + +fn generate_report( + bundle: &Bundle, + base_locale: &LanguageIdentifier, + locales: Vec, +) -> Report { + let mut report: Report = Default::default(); + let locales: Vec = + locales.into_iter().filter(|a| a != base_locale).collect(); + for (key, message) in bundle.message_iter() { + match message.variant(base_locale) { + Some(ref base_variant) => { + for locale in locales.iter() { + match message.variant(locale) { + Some(v) if v.modified() < base_variant.modified() => { + report.out_of_date.push(key.to_owned()) + } + Some(_) => {} + None => report.out_of_date.push(key.to_owned()), + } + } + } + None => { + report.source_deleted.push(key.clone()); + } + } + let base_variant = message.variant(base_locale).clone(); + } + + report +} + fn main() { let editor = std::env::var("EDITOR").expect("Set EDITOR to the path to your favorite editor"); @@ -83,14 +126,23 @@ fn main() { bundle.save(); } Some(Commands::Export { format, locale }) => { - let locale = locale.as_ref().map(|l| l.clone().parse::().unwrap()).unwrap_or(langid!("en")); + let locale = locale + .as_ref() + .map(|l| l.clone().parse::().unwrap()) + .unwrap_or(langid!("en")); match format.as_ref() { "js" => js::export_file(&bundle, locale, &PathBuf::from("output.json")).unwrap(), - "xliff" => xliff::export_file(&bundle, locale, &PathBuf::from("output.xliff")).unwrap(), + "xliff" => { + xliff::export_file(&bundle, locale, &PathBuf::from("output.xliff")).unwrap() + } _ => todo!(), } - }, + } + Some(Commands::Report) => { + let report = generate_report(&bundle, &config.base_locale, config.locales); + println!("{:?}", report); + } None => {} } } diff --git a/l10n-db/src/types.rs b/l10n-db/src/types.rs index ad5caa0..5b8c9ee 100644 --- a/l10n-db/src/types.rs +++ b/l10n-db/src/types.rs @@ -65,6 +65,10 @@ impl Variant { self.content = content; self.modified = Utc::now(); } + + pub fn modified(&self) -> DateTime { + self.modified + } } /*