summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2021-03-24 12:01:38 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2021-03-24 14:54:31 +0000
commitb21bba8a4b3c20eacce14887269b893eab3b3a42 (patch)
tree52241e2863655c394cb80e254660519b5142adaa /android
parent5fe56babfe8e3a9265a41aa09a1959354170d724 (diff)
downloadmullvadvpn-b21bba8a4b3c20eacce14887269b893eab3b3a42.tar.xz
mullvadvpn-b21bba8a4b3c20eacce14887269b893eab3b3a42.zip
Ensure the last message entry is correctly loaded
Diffstat (limited to 'android')
-rw-r--r--android/translations-converter/src/gettext.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/android/translations-converter/src/gettext.rs b/android/translations-converter/src/gettext.rs
index 818ca6c7eb..f42462f4bd 100644
--- a/android/translations-converter/src/gettext.rs
+++ b/android/translations-converter/src/gettext.rs
@@ -100,13 +100,17 @@ impl Translation {
let mut current_plural_id = None;
let mut plural_form = None;
let mut variants = BTreeMap::new();
- let file = BufReader::new(File::open(file_path).expect("Failed to open gettext file"));
- for line in file.lines() {
- let line = line.expect("Failed to read from gettext file");
- let line = line.trim();
+ let file = BufReader::new(File::open(file_path).expect("Failed to open gettext file"));
+ // Ensure there's an empty line at the end so that the "else" part of the string matching
+ // code will run for the last message in the file.
+ let lines = file
+ .lines()
+ .map(|line_result| line_result.expect("Failed to read from gettext file"))
+ .chain(Some(String::new()));
- match_str! { (line)
+ for line in lines {
+ match_str! { (line.trim())
["msgid \"", msg_id, "\""] => {
current_id = Some(normalize(msg_id));
}