Add download-translations.bash script

The script can be used to download the translations from Crowdin.

Change-Id: I295b34ef26d361a493e6fd82501bc70405e04ac1
diff --git a/tools/i18n/.gitignore b/tools/i18n/.gitignore
new file mode 100644
index 0000000..68f35d8
--- /dev/null
+++ b/tools/i18n/.gitignore
@@ -0,0 +1 @@
+crowdin.yml
diff --git a/tools/i18n/crowdin.template.yml b/tools/i18n/crowdin.template.yml
new file mode 100644
index 0000000..3589ec3
--- /dev/null
+++ b/tools/i18n/crowdin.template.yml
@@ -0,0 +1,39 @@
+# Your Crowdin credentials
+"project_id" : "191707"
+"api_token" : "{{API_TOKEN}}"
+"base_path" : "../../."
+"base_url" : "https://api.crowdin.com"
+
+# Choose file structure in Crowdin
+"preserve_hierarchy": true
+
+# Files configuration
+files: [
+ {
+  # Source files filter
+  "source" : "src/_locales/en/messages.json",
+
+  # Where translations will be placed
+  "translation" : "src/_locales/%osx_locale%/%original_file_name%",
+
+  # Files or directories for ignore
+  "ignore" : ["OWNERS"],
+
+  # The dest allows you to specify a file name in Crowdin
+  # e.g. "/messages.json"
+  "dest" : "/messages.json",
+  "type" : "chrome",
+
+  "skip_untranslated_strings" : true,
+  "export_only_approved" : true,
+
+  "languages_mapping" : {
+    "osx_locale" : {
+      "es-AR" : "es_419",
+      "pt-PT" : "pt_PT",
+      "zh-CN" : "zh_CN",
+      "zh-TW" : "zh_TW",
+    }
+  },
+ }
+]
diff --git a/tools/i18n/download-translations.bash b/tools/i18n/download-translations.bash
new file mode 100644
index 0000000..075aee0
--- /dev/null
+++ b/tools/i18n/download-translations.bash
@@ -0,0 +1,18 @@
+#!/bin/bash
+emptyTranslationFile="{}"
+
+# Download new translations
+if [ ! -f "crowdin.yml" ]; then
+  echo "Copy crowdin.template.yml to crowdin.yml and fill in the API token."
+fi
+
+crowdin download -c crowdin.yml
+
+cd ../../src/_locales
+
+for lang in *; do
+  if [ "x$emptyTranslationFile" = "x$(cat $lang/messages.json)" ]; then
+    echo "$lang has an empty translation. Deleting folder..."
+    rm -rf $lang
+  fi
+done