From 4c344c0bba6fba1eb00a4b044aa231e7e15a8d75 Mon Sep 17 00:00:00 2001 From: hamza zia Date: Sat, 31 Oct 2015 10:58:25 +0800 Subject: [PATCH] use english for incomplete translations --- js/init.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/js/init.js b/js/init.js index 32117f8..2cb79fe 100755 --- a/js/init.js +++ b/js/init.js @@ -13,12 +13,26 @@ var webui = angular.module('webui', [ 'pascalprecht.translate' ]); +function mergeTranslation(translation, base) { + for (var i in base) { + if (!base.hasOwnProperty(i)) { + continue; + } + + if (!translation[i] || !translation[i].length) { + translation[i] = base[i]; + } + } + + return translation; +} + webui.config(['$translateProvider', function ($translateProvider) { $translateProvider - .translations('nl_NL', translations.nl_NL) .translations('en_US', translations.en_US) - .translations('th_TH', translations.th_TH) - .translations('zh_CN', translations.zh_CN) + .translations('nl_NL', mergeTranslation(translations.nl_NL, translations.en_US)) + .translations('th_TH', mergeTranslation(translations.th_TH, translations.en_US)) + .translations('zh_CN', mergeTranslation(translations.zh_CN, translations.en_US)) .determinePreferredLanguage(); }]);