diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-03-27 13:40:27 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-03-27 15:27:17 +0000 |
| commit | be8134386f208b301ea15376d1fb1c871091d1dc (patch) | |
| tree | 70f336a589f3045dce43def48ee558771bb9ef14 /android | |
| parent | ed30ee3a7931567546efe09163be0197e06d5cb4 (diff) | |
| download | mullvadvpn-be8134386f208b301ea15376d1fb1c871091d1dc.tar.xz mullvadvpn-be8134386f208b301ea15376d1fb1c871091d1dc.zip | |
Use `MsgString` for `MsgEntry.id`
Diffstat (limited to 'android')
| -rw-r--r-- | android/translations-converter/src/gettext.rs | 6 | ||||
| -rw-r--r-- | android/translations-converter/src/main.rs | 17 |
2 files changed, 14 insertions, 9 deletions
diff --git a/android/translations-converter/src/gettext.rs b/android/translations-converter/src/gettext.rs index 2d7917a556..70d96a5160 100644 --- a/android/translations-converter/src/gettext.rs +++ b/android/translations-converter/src/gettext.rs @@ -36,7 +36,7 @@ pub enum PluralForm { /// A message entry in a gettext translation file. #[derive(Clone, Debug)] pub struct MsgEntry { - pub id: String, + pub id: MsgString, pub value: MsgValue, } @@ -119,7 +119,7 @@ impl Translation { for line in lines { match_str! { (line.trim()) ["msgid \"", msg_id, "\""] => { - current_id = Some(normalize(msg_id)); + current_id = Some(MsgString(normalize(msg_id))); } ["msgstr \"", translation, "\""] => { if let Some(id) = current_id.take() { @@ -274,7 +274,7 @@ pub fn append_to_template( for entry in sorted_entries { writeln!(writer)?; - writeln!(writer, "msgid {:?}", entry.id)?; + writeln!(writer, r#"msgid "{}""#, entry.id)?; match entry.value { MsgValue::Invariant(value) => writeln!(writer, r#"msgstr "{}""#, value)?, diff --git a/android/translations-converter/src/main.rs b/android/translations-converter/src/main.rs index 09042b133f..c452a1742b 100644 --- a/android/translations-converter/src/main.rs +++ b/android/translations-converter/src/main.rs @@ -133,8 +133,8 @@ fn main() { for message in template { match message.value { - gettext::MsgValue::Invariant(_) => missing_translations.remove(&message.id), - gettext::MsgValue::Plural { .. } => missing_plurals.remove(&message.id), + gettext::MsgValue::Invariant(_) => missing_translations.remove(&*message.id), + gettext::MsgValue::Plural { .. } => missing_plurals.remove(&*message.id), }; } @@ -147,7 +147,7 @@ fn main() { .into_iter() .inspect(|(missing_translation, id)| println!(" {}: {}", id, missing_translation)) .map(|(id, _)| gettext::MsgEntry { - id, + id: id.into(), value: String::new().into(), }), ) @@ -179,7 +179,12 @@ fn main() { .iter() .position(|plural| plural.quantity == android::PluralQuantity::One) .expect("Missing singular variant to use as msgid"); - let id = plural.items.remove(singular_position).string.to_string(); + let id = plural + .items + .remove(singular_position) + .string + .to_string() + .into(); let other_position = plural .items @@ -253,7 +258,7 @@ fn generate_translations( for translation in translations { match translation.value { gettext::MsgValue::Invariant(translation_value) => { - if let Some(android_key) = known_strings.remove(&translation.id) { + if let Some(android_key) = known_strings.remove(&*translation.id) { localized_strings.push(android::StringResource::new( android_key, &translation_value, @@ -261,7 +266,7 @@ fn generate_translations( } } gettext::MsgValue::Plural { values, .. } => { - if let Some(android_key) = known_plurals.remove(&translation.id) { + if let Some(android_key) = known_plurals.remove(&*translation.id) { let values = values.into_iter().map(|message| message.to_string()); localized_plurals.push(android::PluralResource::new( |
