diff --git a/gulp/tasks/translations.js b/gulp/tasks/translations.js index 6cedd768e1..a4955498c0 100755 --- a/gulp/tasks/translations.js +++ b/gulp/tasks/translations.js @@ -44,13 +44,21 @@ gulp.task(taskName, function () { src.push(inDir + '/' + lang + '.json'); } return gulp.src(src) - .pipe(merge({ - fileName: tr + '.json', - })) .pipe(transform(function(data, file) { // Polymer.AppLocalizeBehavior requires flattened json return flatten(data); })) + .pipe(transform(function(data, file) { + const new_data = {}; + Object.entries(data).forEach(([key, value]) => { + // Filter out empty strings or other falsey values before merging + if (data[key]) new_data[key] = value; + }); + return new_data; + })) + .pipe(merge({ + fileName: tr + '.json', + })) .pipe(minify()) .pipe(gulp.dest(outDir)); })); @@ -87,18 +95,17 @@ gulp.task(taskName, ['build-translation-fingerprints'], function() { ]) .pipe(merge({})) .pipe(transform(function(data, file) { - return Object.keys(data) - .filter(key => { - if (!data[key]['nativeName']) { + const new_data = {}; + Object.entries(data).forEach(([key, value]) => { + // Filter out empty strings or other falsey values before merging + if (data[key]['nativeName']) { + new_data[key] = data[key]; + } else { console.warn(`Skipping language ${key}. Native name was not translated.`); - return false; - } - return true; - }) - .reduce((obj, key) => { - obj[key] = data[key]; - return obj; - }, {}); + } + if (data[key]) new_data[key] = value; + }); + return new_data; })) .pipe(insert.wrap('')) .pipe(rename('translationMetadata.html')) diff --git a/script/build_frontend b/script/build_frontend index 3e7f1b1edf..0880e58bd2 100755 --- a/script/build_frontend +++ b/script/build_frontend @@ -11,10 +11,6 @@ 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 index a1aaea0b4e..969ed6aea3 100755 --- a/script/translations_download +++ b/script/translations_download @@ -11,7 +11,9 @@ 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/" + "https://lokalise.co/signup/3420425759f6d6d241f598.13594006/all/" \ + "Place your token in a new file \".lokalise_token\" in the repo" \ + "root directory." exit 1 fi @@ -29,6 +31,7 @@ docker run \ lokalise/lokalise-cli lokalise \ --token ${API_TOKEN} \ export ${PROJECT_ID} \ + --export_empty skip \ --type json \ --dest /opt/dest diff --git a/script/translations_upload_base b/script/translations_upload_base index 71dcc6011a..717edf3c65 100755 --- a/script/translations_upload_base +++ b/script/translations_upload_base @@ -11,7 +11,9 @@ 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/" + "https://lokalise.co/signup/3420425759f6d6d241f598.13594006/all/" \ + "Place your token in a new file \".lokalise_token\" in the repo" \ + "root directory." exit 1 fi diff --git a/translations/.gitignore b/translations/.gitignore deleted file mode 100644 index 5e7d2734cf..0000000000 --- a/translations/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore diff --git a/translations/README.md b/translations/README.md new file mode 100644 index 0000000000..778fbc249d --- /dev/null +++ b/translations/README.md @@ -0,0 +1,4 @@ +# Translation Resources +Translations are managed through [Lokalise](https://lokalise.co/). If you'd like to contribute, you can [join the project here](https://lokalise.co/signup/3420425759f6d6d241f598.13594006/all/). For more details, see our [translation guidelines documentation](https://home-assistant.io/developers/frontend_translation/). + +Don't make changes to these files directly. Instead, use `script/translations_download` to fetch the latest translations from Lokalise. diff --git a/translations/bg.json b/translations/bg.json new file mode 100644 index 0000000000..39d6abac82 --- /dev/null +++ b/translations/bg.json @@ -0,0 +1,9 @@ +{ + "panel": { + "states": "Състояние", + "map": "Карта", + "logbook": "Дневник", + "history": "История", + "log_out": "Излез" + } +} \ No newline at end of file diff --git a/translations/cs.json b/translations/cs.json new file mode 100644 index 0000000000..afd21787cf --- /dev/null +++ b/translations/cs.json @@ -0,0 +1,10 @@ +{ + "panel": { + "config": "Nastavení", + "states": "Stavy", + "map": "Mapa", + "logbook": "Deník", + "history": "Historie", + "log_out": "Odhlásit se" + } +} \ No newline at end of file diff --git a/translations/da.json b/translations/da.json new file mode 100644 index 0000000000..21a1abbdf1 --- /dev/null +++ b/translations/da.json @@ -0,0 +1,11 @@ +{ + "panel": { + "config": "Indstillinger", + "states": "Oversigt", + "map": "Kort", + "logbook": "Logbog", + "history": "Historik", + "log_out": "Log af", + "shopping_list": "Indkøbsliste" + } +} \ No newline at end of file diff --git a/translations/de.json b/translations/de.json new file mode 100644 index 0000000000..7dc65e673e --- /dev/null +++ b/translations/de.json @@ -0,0 +1,12 @@ +{ + "panel": { + "config": "Konfiguration", + "states": "Übersicht", + "map": "Karte", + "logbook": "Logbuch", + "history": "Verlauf", + "log_out": "Abmelden", + "mailbox": "Posteingang", + "shopping_list": "Einkaufsliste" + } +} \ No newline at end of file diff --git a/translations/el.json b/translations/el.json new file mode 100644 index 0000000000..735a350d4a --- /dev/null +++ b/translations/el.json @@ -0,0 +1,10 @@ +{ + "panel": { + "config": "Ρυθμίσεις", + "states": "Επισκόπηση", + "map": "Χάρτης", + "logbook": "Αρχείο Συμβάντων", + "history": "Ιστορικό", + "log_out": "Αποσύνδεση" + } +} \ No newline at end of file diff --git a/translations/en.json b/translations/en.json new file mode 100644 index 0000000000..f17853d1b2 --- /dev/null +++ b/translations/en.json @@ -0,0 +1,12 @@ +{ + "panel": { + "config": "Configuration", + "states": "Overview", + "map": "Map", + "logbook": "Logbook", + "history": "History", + "log_out": "Log Out", + "mailbox": "Mailbox", + "shopping_list": "Shopping List" + } +} \ No newline at end of file diff --git a/translations/fa.json b/translations/fa.json new file mode 100644 index 0000000000..365c7267fd --- /dev/null +++ b/translations/fa.json @@ -0,0 +1,9 @@ +{ + "panel": { + "states": "وضعیت", + "map": "نقشه", + "logbook": "گزارش روزانه", + "history": "تاریخچه", + "log_out": "خروج" + } +} \ No newline at end of file diff --git a/translations/fi.json b/translations/fi.json new file mode 100644 index 0000000000..fc23aaa8ec --- /dev/null +++ b/translations/fi.json @@ -0,0 +1,11 @@ +{ + "panel": { + "config": "Asetukset", + "states": "Yleisnäkymä", + "map": "Kartta", + "logbook": "Lokikirja", + "history": "Historia", + "log_out": "Kirjaudu ulos", + "shopping_list": "Ostoslista" + } +} \ No newline at end of file diff --git a/translations/fr.json b/translations/fr.json new file mode 100644 index 0000000000..97f5c2cb7c --- /dev/null +++ b/translations/fr.json @@ -0,0 +1,11 @@ +{ + "panel": { + "config": "Configuration", + "states": "États", + "map": "Carte", + "logbook": "Journal", + "history": "Historique", + "log_out": "Déconnexion", + "shopping_list": "Liste de courses" + } +} \ No newline at end of file diff --git a/translations/hu.json b/translations/hu.json new file mode 100644 index 0000000000..8dd89270b2 --- /dev/null +++ b/translations/hu.json @@ -0,0 +1,10 @@ +{ + "panel": { + "config": "Konfiguráció", + "states": "Áttekintés", + "map": "Térkép", + "logbook": "Napló", + "history": "Előzmények", + "log_out": "Kilépés" + } +} \ No newline at end of file diff --git a/translations/it.json b/translations/it.json new file mode 100644 index 0000000000..7cd96ba9c9 --- /dev/null +++ b/translations/it.json @@ -0,0 +1,12 @@ +{ + "panel": { + "config": "Configurazione", + "states": "Stati", + "map": "Mappa", + "logbook": "Registro", + "history": "Storico", + "log_out": "Esci", + "mailbox": "Messaggi", + "shopping_list": "Lista della spesa" + } +} \ No newline at end of file diff --git a/translations/ja.json b/translations/ja.json new file mode 100644 index 0000000000..259e057486 --- /dev/null +++ b/translations/ja.json @@ -0,0 +1,9 @@ +{ + "panel": { + "states": "状態", + "map": "地図", + "logbook": "ログブック", + "history": "履歴", + "log_out": "ログアウト" + } +} \ No newline at end of file diff --git a/translations/lt.json b/translations/lt.json new file mode 100644 index 0000000000..10f99a8c22 --- /dev/null +++ b/translations/lt.json @@ -0,0 +1,9 @@ +{ + "panel": { + "states": "Valdymas", + "map": "Žemėlapis", + "logbook": "Veiksmų žurnalas", + "history": "Istorija", + "log_out": "Atsijungti" + } +} \ No newline at end of file diff --git a/translations/nl.json b/translations/nl.json new file mode 100644 index 0000000000..21df671778 --- /dev/null +++ b/translations/nl.json @@ -0,0 +1,10 @@ +{ + "panel": { + "config": "Instellingen", + "states": "Overzicht", + "map": "Kaart", + "logbook": "Logboek", + "history": "Geschiedenis", + "log_out": "Uitloggen" + } +} \ No newline at end of file diff --git a/translations/no.json b/translations/no.json new file mode 100644 index 0000000000..0d986cb348 --- /dev/null +++ b/translations/no.json @@ -0,0 +1,12 @@ +{ + "panel": { + "config": "Innstillinger", + "states": "Oversikt", + "map": "Kart", + "logbook": "Loggbok", + "history": "Historie", + "log_out": "Logg av", + "mailbox": "Postboks", + "shopping_list": "Handleliste" + } +} \ No newline at end of file diff --git a/translations/pl.json b/translations/pl.json new file mode 100644 index 0000000000..2a503ee22c --- /dev/null +++ b/translations/pl.json @@ -0,0 +1,9 @@ +{ + "panel": { + "states": "Stany", + "map": "Mapa", + "logbook": "Dziennik", + "history": "Historia", + "log_out": "Wyloguj" + } +} \ No newline at end of file diff --git a/translations/pt.json b/translations/pt.json new file mode 100644 index 0000000000..d5e3f36d2f --- /dev/null +++ b/translations/pt.json @@ -0,0 +1,9 @@ +{ + "panel": { + "states": "Estados", + "map": "Mapa", + "logbook": "Eventos", + "history": "Histórico", + "log_out": "Desconectar" + } +} \ No newline at end of file diff --git a/translations/ru.json b/translations/ru.json new file mode 100644 index 0000000000..8c245347ee --- /dev/null +++ b/translations/ru.json @@ -0,0 +1,10 @@ +{ + "panel": { + "config": "Настройки", + "states": "Обзор", + "map": "Карта", + "logbook": "Журнал", + "history": "История", + "log_out": "Выход" + } +} \ No newline at end of file diff --git a/translations/sv.json b/translations/sv.json new file mode 100644 index 0000000000..c6fbbbc454 --- /dev/null +++ b/translations/sv.json @@ -0,0 +1,9 @@ +{ + "panel": { + "states": "Översikt", + "map": "Karta", + "logbook": "Loggbok", + "history": "Historik", + "log_out": "Logga Ut" + } +} \ No newline at end of file diff --git a/translations/th.json b/translations/th.json new file mode 100644 index 0000000000..e4e69ea76d --- /dev/null +++ b/translations/th.json @@ -0,0 +1,9 @@ +{ + "panel": { + "states": "ภาพรวม", + "map": "แผนที่", + "logbook": "สมุดบันทึก", + "history": "ประวัติ", + "log_out": "ลงชื่อออก" + } +} \ No newline at end of file diff --git a/translations/tr.json b/translations/tr.json new file mode 100644 index 0000000000..e2d1b8d913 --- /dev/null +++ b/translations/tr.json @@ -0,0 +1,10 @@ +{ + "panel": { + "config": "Ayarlar", + "states": "Durum", + "map": "Harita", + "logbook": "Kayıt Defteri", + "history": "Geçmiş", + "log_out": "Çıkış Yap" + } +} \ No newline at end of file diff --git a/translations/vi.json b/translations/vi.json new file mode 100644 index 0000000000..0095fa992e --- /dev/null +++ b/translations/vi.json @@ -0,0 +1,10 @@ +{ + "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" + } +} \ No newline at end of file diff --git a/translations/zh-Hans.json b/translations/zh-Hans.json new file mode 100644 index 0000000000..db325e319f --- /dev/null +++ b/translations/zh-Hans.json @@ -0,0 +1,10 @@ +{ + "panel": { + "config": "配置", + "states": "概览", + "map": "地图", + "logbook": "日志", + "history": "历史", + "log_out": "退出" + } +} \ No newline at end of file diff --git a/translations/zh-Hant.json b/translations/zh-Hant.json new file mode 100644 index 0000000000..7493a5312e --- /dev/null +++ b/translations/zh-Hant.json @@ -0,0 +1,10 @@ +{ + "panel": { + "config": "設定", + "states": "概覽", + "map": "地圖", + "logbook": "日誌", + "history": "歷史", + "log_out": "登出" + } +} \ No newline at end of file