summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-12-10 16:29:23 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-12-10 18:30:28 +0000
commitadaa2dc44740782dbc9c49eb3a1942a110cef3c3 (patch)
treedb7b50b3743679e1b42e5585b1f3abb43bdb4ffa /android
parent2408ae8692cab6910bba5a3124e2a7869ee25ca4 (diff)
downloadmullvadvpn-adaa2dc44740782dbc9c49eb3a1942a110cef3c3.tar.xz
mullvadvpn-adaa2dc44740782dbc9c49eb3a1942a110cef3c3.zip
Create a `match_str!` helper macro
Allows matching a string to different prefix and suffix combinations.
Diffstat (limited to 'android')
-rw-r--r--android/translations-converter/src/gettext.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/android/translations-converter/src/gettext.rs b/android/translations-converter/src/gettext.rs
index a7636eec65..f2ba43125f 100644
--- a/android/translations-converter/src/gettext.rs
+++ b/android/translations-converter/src/gettext.rs
@@ -46,6 +46,23 @@ pub enum MsgValue {
},
}
+/// A helper macro to match a string to various prefix and suffix combinations.
+macro_rules! match_str {
+ (
+ ( $string:expr )
+ $( [$start:expr, $middle:ident, $end:expr] => $body:tt )*
+ _ => $else:expr $(,)*
+ ) => {
+ $(
+ if let Some($middle) = parse_line($string, $start, $end) {
+ $body
+ } else
+ )* {
+ $else
+ }
+ };
+}
+
impl Translation {
/// Load message entries from a gettext translation file.
///