diff --git a/.gitignore b/.gitignore index c9d8f269e2..ee84209a83 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ venv lib bin dist + +# Secrets +.lokalise_token diff --git a/gulp/tasks/translations.js b/gulp/tasks/translations.js index e6ea318ab7..deefdfc5d0 100755 --- a/gulp/tasks/translations.js +++ b/gulp/tasks/translations.js @@ -63,6 +63,13 @@ gulp.task(taskName, function () { .pipe(merge({ fileName: tr + '.json', })) + .pipe(transform(function(data, file) { + // For now, language strings are only used for the native names list. We're deleting + // them from the rolled up translation files for now until we have a more robust + // system for splitting translation strings into multiple resource files. + delete data['language']; + return data; + })) .pipe(transform(function(data, file) { // Polymer.AppLocalizeBehavior requires flattened json return flatten(data); @@ -102,6 +109,20 @@ gulp.task(taskName, ['build-translation-fingerprints', 'build-translation-native 'build-temp/translationNativeNames.json', ]) .pipe(merge({})) + .pipe(transform(function(data, file) { + return Object.keys(data) + .filter(key => { + if (!data[key]['nativeName']) { + console.warn(`Skipping language ${key}. Native name was not translated.`); + return false; + } + return true; + }) + .reduce((obj, key) => { + obj[key] = data[key]; + return obj; + }, {}); + })) .pipe(insert.wrap('')) .pipe(rename('translationMetadata.html')) .pipe(gulp.dest('build-temp')); diff --git a/script/build_frontend b/script/build_frontend index 0880e58bd2..3e7f1b1edf 100755 --- a/script/build_frontend +++ b/script/build_frontend @@ -11,6 +11,10 @@ OUTPUT_DIR=hass_frontend rm -rf $OUTPUT_DIR cp -r public $OUTPUT_DIR +# Download latest translations +echo "Downloading translations from Lokalise" +script/translations_download + # Build frontend BUILD_DEV=0 ./node_modules/.bin/gulp diff --git a/script/translations_download b/script/translations_download new file mode 100755 index 0000000000..be28687620 --- /dev/null +++ b/script/translations_download @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Safe bash settings +# -e Exit on command fail +# -u Exit on unset variable +# -o pipefail Exit if piped command has error code +set -eu -o pipefail + +cd "$(dirname "$0")/.." + +if [ ! -f .lokalise_token ] ; then + echo "Lokalise API token is required to download the latest set of" \ + "translations. Please create an account by using the following link:" \ + "https://lokalise.co/signup/3420425759f6d6d241f598.13594006/all/" + exit 1 +fi + +API_TOKEN="$(<.lokalise_token)" +PROJECT_ID="3420425759f6d6d241f598.13594006" +LOCAL_DIR="$(pwd)/translations" +DOWNLOAD_FILE="${LOCAL_DIR}/Home_Assistant_-_Polymer_frontend-locale.zip" +FILE_FORMAT=json + +rm -rf ${LOCAL_DIR} +mkdir -p ${LOCAL_DIR} + +docker run \ + -v ${LOCAL_DIR}:/opt/dest \ + lokalise/lokalise-cli lokalise \ + --token ${API_TOKEN} \ + export ${PROJECT_ID} \ + --type json \ + --dest /opt/dest + +# Extract and delete downloaded zip bundle +unzip -j "${DOWNLOAD_FILE}" locale/* -d "${LOCAL_DIR}" +rm -f "${DOWNLOAD_FILE}" diff --git a/script/translations_upload_base b/script/translations_upload_base new file mode 100755 index 0000000000..71dcc6011a --- /dev/null +++ b/script/translations_upload_base @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Safe bash settings +# -e Exit on command fail +# -u Exit on unset variable +# -o pipefail Exit if piped command has error code +set -eu -o pipefail + +cd "$(dirname "$0")/.." + +if [ ! -f .lokalise_token ] ; then + echo "Lokalise API token is required to download the latest set of" \ + "translations. Please create an account by using the following link:" \ + "https://lokalise.co/signup/3420425759f6d6d241f598.13594006/all/" + exit 1 +fi + +API_TOKEN="$(<.lokalise_token)" +PROJECT_ID="3420425759f6d6d241f598.13594006" +LOCAL_FILE="$(pwd)/src/translations/en.json" +LANG_ISO=en + +docker run \ + -v ${LOCAL_FILE}:/opt/src/${LOCAL_FILE} \ + lokalise/lokalise-cli lokalise \ + --token ${API_TOKEN} \ + import ${PROJECT_ID} \ + --file /opt/src/${LOCAL_FILE} \ + --lang_iso ${LANG_ISO} diff --git a/src/translations/en.json b/src/translations/en.json new file mode 100644 index 0000000000..a4cc531d54 --- /dev/null +++ b/src/translations/en.json @@ -0,0 +1,38 @@ +{ + "language": { + "bg": "Bulgarian", + "cs": "Czech", + "da": "Danish", + "de": "German", + "el": "Greek", + "en": "English", + "fa": "Persian", + "fi": "Finnish", + "fr": "French", + "hu": "Hungarian", + "it": "Italian", + "ja": "Japanese", + "lt": "Lithuanian", + "nl": "Dutch", + "no": "Norwegian", + "pl": "Polish", + "pt": "Portuguese", + "ru": "Russian", + "sv": "Swedish", + "th": "Thai", + "tr": "Turkish", + "vi": "Vietnamese", + "zh-Hans": "Chinese Simplified", + "zh-Hant": "Chinese Traditional" + }, + "panel": { + "config": "Configuration", + "states": "Overview", + "map": "Map", + "logbook": "Logbook", + "history": "History", + "log_out": "Log Out", + "mailbox": "Mailbox", + "shopping_list": "Shopping List" + } +} diff --git a/translations/.gitignore b/translations/.gitignore new file mode 100644 index 0000000000..5e7d2734cf --- /dev/null +++ b/translations/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/translations/bg.json b/translations/bg.json deleted file mode 100644 index 5f7df49a05..0000000000 --- a/translations/bg.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "language": { - "bg": "Български" - }, - "panel": { - "states": "Състояние", - "map": "Карта", - "logbook": "Дневник", - "history": "История", - "log_out": "Излез" - } -} diff --git a/translations/cs.json b/translations/cs.json deleted file mode 100644 index 13414a260e..0000000000 --- a/translations/cs.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "cs": "Čeština" - }, - "panel": { - "config": "Nastavení", - "states": "Stavy", - "map": "Mapa", - "logbook": "Deník", - "history": "Historie", - "log_out": "Odhlásit se" - } -} diff --git a/translations/da.json b/translations/da.json deleted file mode 100644 index c429651bfb..0000000000 --- a/translations/da.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "da": "Dansk" - }, - "panel": { - "states": "Oversigt", - "map": "Kort", - "logbook": "Logbog", - "history": "Historik", - "log_out": "Log af", - "config": "Indstillinger" - } -} diff --git a/translations/de.json b/translations/de.json deleted file mode 100644 index 11d1242d7d..0000000000 --- a/translations/de.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "language": { - "de": "Deutsch" - }, - "panel": { - "config": "Konfiguration", - "states": "Übersicht", - "map": "Karte", - "logbook": "Logbuch", - "history": "Verlauf", - "log_out": "Abmelden", - "mailbox": "Posteingang", - "shopping_list": "Einkaufsliste" - } -} diff --git a/translations/el.json b/translations/el.json deleted file mode 100644 index 37f91f1a52..0000000000 --- a/translations/el.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "el": "Ελληνικά" - }, - "panel": { - "config": "Ρυθμίσεις", - "states": "Επισκόπηση", - "map": "Χάρτης", - "logbook": "Αρχείο Συμβάντων", - "history": "Ιστορικό", - "log_out": "Αποσύνδεση" - } -} diff --git a/translations/en.json b/translations/en.json deleted file mode 100644 index d28ae78f68..0000000000 --- a/translations/en.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "language": { - "en": "English" - }, - "panel": { - "config": "Configuration", - "states": "Overview", - "map": "Map", - "logbook": "Logbook", - "history": "History", - "log_out": "Log Out", - "mailbox": "Mailbox", - "shopping_list": "Shopping List" - } -} diff --git a/translations/fa.json b/translations/fa.json deleted file mode 100644 index bca3a71db0..0000000000 --- a/translations/fa.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "language": { - "fa": "فارسی" - }, - "panel": { - "states": "وضعیت", - "map": "نقشه", - "logbook": "گزارش روزانه", - "history": "تاریخچه", - "log_out": "خروج" - } -} diff --git a/translations/fi.json b/translations/fi.json deleted file mode 100644 index 3808916616..0000000000 --- a/translations/fi.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "fi": "Suomi" - }, - "panel": { - "config": "Asetukset", - "states": "Yleisnäkymä", - "map": "Kartta", - "logbook": "Lokikirja", - "history": "Historia", - "log_out": "Kirjaudu ulos" - } -} diff --git a/translations/fr.json b/translations/fr.json deleted file mode 100644 index ca1fe8e3d6..0000000000 --- a/translations/fr.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "fr": "Français" - }, - "panel": { - "config": "Configuration", - "states": "États", - "map": "Carte", - "logbook": "Journal", - "history": "Historique", - "log_out": "Déconnexion" - } -} diff --git a/translations/hu.json b/translations/hu.json deleted file mode 100644 index 1a496406dd..0000000000 --- a/translations/hu.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "hu": "Magyar" - }, - "panel": { - "config": "Konfiguráció", - "states": "Áttekintés", - "map": "Térkép", - "logbook": "Napló", - "history": "Előzmények", - "log_out": "Kilépés" - } -} diff --git a/translations/it.json b/translations/it.json deleted file mode 100644 index bf23af6c4f..0000000000 --- a/translations/it.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "language": { - "it": "Italiano" - }, - "panel": { - "states": "Stati", - "map": "Mappa", - "history": "Storico" - } -} diff --git a/translations/jp.json b/translations/jp.json deleted file mode 100644 index 33b8d7196c..0000000000 --- a/translations/jp.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "language": { - "jp": "日本語" - }, - "panel": { - "states": "状態", - "map": "地図", - "logbook": "ログブック", - "history": "履歴", - "log_out": "ログアウト" - } -} diff --git a/translations/lt.json b/translations/lt.json deleted file mode 100644 index a0202151fe..0000000000 --- a/translations/lt.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "language": { - "lt": "Lietuvių" - }, - "panel": { - "states": "Valdymas", - "map": "Žemėlapis", - "logbook": "Veiksmų žurnalas", - "history": "Istorija", - "log_out": "Atsijungti" - } -} diff --git a/translations/nl.json b/translations/nl.json deleted file mode 100644 index 82d59f038f..0000000000 --- a/translations/nl.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "nl": "Nederlands" - }, - "panel": { - "config": "Instellingen", - "states": "Overzicht", - "map": "Kaart", - "logbook": "Logboek", - "history": "Geschiedenis", - "log_out": "Uitloggen" - } -} diff --git a/translations/no.json b/translations/no.json deleted file mode 100644 index b7013b3c3a..0000000000 --- a/translations/no.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "language": { - "no": "Norsk" - }, - "panel": { - "config": "Innstillinger", - "states": "Oversikt", - "map": "Kart", - "logbook": "Loggbok", - "history": "Historie", - "log_out": "Logg av", - "mailbox": "Postboks", - "shopping_list": "Handleliste" - } -} diff --git a/translations/pl.json b/translations/pl.json deleted file mode 100644 index a647e9d1e4..0000000000 --- a/translations/pl.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "language": { - "pl": "Polski" - }, - "panel": { - "states": "Stany", - "map": "Mapa", - "logbook": "Dziennik", - "history": "Historia", - "log_out": "Wyloguj" - } -} diff --git a/translations/pt.json b/translations/pt.json deleted file mode 100644 index d0166e7fe0..0000000000 --- a/translations/pt.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "language": { - "pt": "Português" - }, - "panel": { - "states": "Estados", - "map": "Mapa", - "logbook": "Eventos", - "history": "Histórico", - "log_out": "Desconectar" - } -} diff --git a/translations/ru.json b/translations/ru.json deleted file mode 100644 index 4ae49487d0..0000000000 --- a/translations/ru.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "ru": "Русский" - }, - "panel": { - "config": "Настройки", - "states": "Обзор", - "map": "Карта", - "logbook": "Журнал", - "history": "История", - "log_out": "Выход" - } -} diff --git a/translations/sv.json b/translations/sv.json deleted file mode 100644 index e8f9f50007..0000000000 --- a/translations/sv.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "language": { - "sv": "Svenska" - }, - "panel": { - "states": "Översikt", - "map": "Karta", - "logbook": "Loggbok", - "history": "Historik", - "log_out": "Logga Ut" - } -} diff --git a/translations/th.json b/translations/th.json deleted file mode 100644 index 1e7a3a0578..0000000000 --- a/translations/th.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "language": { - "th": "ภาษาไทย" - }, - "panel": { - "states": "ภาพรวม", - "map": "แผนที่", - "logbook": "สมุดบันทึก", - "history": "ประวัติ", - "log_out": "ลงชื่อออก" - } -} diff --git a/translations/tr.json b/translations/tr.json deleted file mode 100644 index 1db312b36a..0000000000 --- a/translations/tr.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "tr": "Türkçe" - }, - "panel": { - "config": "Ayarlar", - "states": "Durum", - "map": "Harita", - "logbook": "Kayıt Defteri", - "history": "Geçmiş", - "log_out": "Çıkış Yap" - } -} diff --git a/translations/vi.json b/translations/vi.json deleted file mode 100644 index 34bccb627a..0000000000 --- a/translations/vi.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "vi": "Tiếng Việt" - }, - "panel": { - "config": "Cấu hình", - "states": "Tổng quan", - "map": "Bản đồ", - "logbook": "Nhật ký", - "history": "Lịch sử", - "log_out": "Đăng xuất" - } -} diff --git a/translations/zh-Hans.json b/translations/zh-Hans.json deleted file mode 100644 index df4300103e..0000000000 --- a/translations/zh-Hans.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "zh-Hans": "简体中文" - }, - "panel": { - "config": "配置", - "states": "概览", - "map": "地图", - "logbook": "日志", - "history": "历史", - "log_out": "退出" - } -} diff --git a/translations/zh-Hant.json b/translations/zh-Hant.json deleted file mode 100644 index 0efcc93f6a..0000000000 --- a/translations/zh-Hant.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "language": { - "zh-Hant": "繁體中文" - }, - "panel": { - "config": "設定", - "states": "概覽", - "map": "地圖", - "logbook": "日誌", - "history": "歷史", - "log_out": "登出" - } -}