summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-07-28 03:13:56 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-08-11 22:59:38 +0000
commit8a76c5e7a83b0d91e039c636d4b2837f8f95f323 (patch)
treebb6b5d20c80d07cb922101e2aa92cc6856c49a0b /android
parentaab7ad0b59f6b25c36bbf5b1668b4ed72970ad87 (diff)
downloadmullvadvpn-8a76c5e7a83b0d91e039c636d4b2837f8f95f323.tar.xz
mullvadvpn-8a76c5e7a83b0d91e039c636d4b2837f8f95f323.zip
Collect missing translation templates
Diffstat (limited to 'android')
-rw-r--r--android/translations-converter/src/main.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/android/translations-converter/src/main.rs b/android/translations-converter/src/main.rs
index 059eb99c83..51afed1b67 100644
--- a/android/translations-converter/src/main.rs
+++ b/android/translations-converter/src/main.rs
@@ -35,7 +35,6 @@ fn main() {
.expect("Failed to open string resources file");
let mut string_resources: android::StringResources =
serde_xml_rs::from_reader(strings_file).expect("Failed to read string resources file");
- let mut missing_translations = HashMap::new();
string_resources.normalize();
@@ -48,6 +47,8 @@ fn main() {
})
.partition(|(string_value, _)| string_value.starts_with("https://mullvad.net/en/"));
+ let mut missing_translations = known_strings.clone();
+
let locale_files = fs::read_dir("../../gui/locales")
.expect("Failed to open root locale directory")
.filter_map(|dir_entry_result| dir_entry_result.ok().map(|dir_entry| dir_entry.path()))
@@ -113,6 +114,10 @@ fn android_locale_directory(locale: &str) -> String {
/// URL strings are treated differently. The "translated" URLs have a locale specified in them. If
/// mapping from the translation locale to a website locale fails, the "translated" URL is not
/// generated, and the app falls back to the original URL value with the english locale.
+///
+/// The missing translations map is updated to only contain the strings that aren't present in the
+/// current locale, which means that in the end the map contains only the translations that aren't
+/// present in any locale.
fn generate_translations(
locale: &str,
known_urls: HashMap<String, String>,
@@ -146,7 +151,7 @@ fn generate_translations(
fs::write(output_path, localized_resource.to_string())
.expect("Failed to create Android locale file");
- missing_translations.extend(known_strings.into_iter());
+ missing_translations.retain(|translation, _| known_strings.contains_key(translation));
}
/// Tries to map a translation locale to a locale used on the Mullvad website.