Add translation for Javascript strings (#72)

* Add translation function to translatable strings

* Fix missing translation string
master
e-alfred 2019-05-05 18:41:07 +02:00 committed by Loïc Blot
parent 1e97aa0fc0
commit b46edbb78f
1 changed files with 21 additions and 21 deletions

View File

@ -11,7 +11,7 @@
var app = angular.module('Weather', []); var app = angular.module('Weather', []);
var g_error500 = 'Fatal Error: please check your owncloud.log and send a bug report here: https://github.com/nextcloud/weather/issues'; var g_error500 = t('weather', 'Fatal Error: please check your nextcloud.log and send a bug report here: https://github.com/nextcloud/weather/issues');
function undef (obj) { function undef (obj) {
return typeof obj === undefined || obj === undefined; return typeof obj === undefined || obj === undefined;
@ -87,12 +87,12 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil
$scope.loadCity($scope.domCity); $scope.loadCity($scope.domCity);
} }
else { else {
$scope.settingError = 'Failed to set metric. Please contact your administrator'; $scope.settingError = t('weather', 'Failed to set metric. Please contact your administrator');
} }
}, },
function (r) { function (r) {
if (r.status == 404) { if (r.status == 404) {
$scope.settingError = "This metric is not known."; $scope.settingError = t('weather', 'This metric is not known.');
} }
else { else {
$scope.settingError = g_error500; $scope.settingError = g_error500;
@ -163,43 +163,43 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil
$scope.currentCity.wind.desc = ""; $scope.currentCity.wind.desc = "";
if ($scope.currentCity.wind.deg > 0 && $scope.currentCity.wind.deg < 23 || if ($scope.currentCity.wind.deg > 0 && $scope.currentCity.wind.deg < 23 ||
$scope.currentCity.wind.deg > 333) { $scope.currentCity.wind.deg > 333) {
$scope.currentCity.wind.desc = "North"; $scope.currentCity.wind.desc = t('weather', 'North');
} }
else if ($scope.currentCity.wind.deg > 22 && $scope.currentCity.wind.deg < 67) { else if ($scope.currentCity.wind.deg > 22 && $scope.currentCity.wind.deg < 67) {
$scope.currentCity.wind.desc = "North-East"; $scope.currentCity.wind.desc = t('weather', 'North-East');
} }
else if ($scope.currentCity.wind.deg > 66 && $scope.currentCity.wind.deg < 113) { else if ($scope.currentCity.wind.deg > 66 && $scope.currentCity.wind.deg < 113) {
$scope.currentCity.wind.desc = "East"; $scope.currentCity.wind.desc = t('weather', 'East');
} }
else if ($scope.currentCity.wind.deg > 112 && $scope.currentCity.wind.deg < 157) { else if ($scope.currentCity.wind.deg > 112 && $scope.currentCity.wind.deg < 157) {
$scope.currentCity.wind.desc = "South-East"; $scope.currentCity.wind.desc = t('weather', 'South-East');
} }
else if ($scope.currentCity.wind.deg > 156 && $scope.currentCity.wind.deg < 201) { else if ($scope.currentCity.wind.deg > 156 && $scope.currentCity.wind.deg < 201) {
$scope.currentCity.wind.desc = "South"; $scope.currentCity.wind.desc = t('weather', 'South');
} }
else if ($scope.currentCity.wind.deg > 200 && $scope.currentCity.wind.deg < 245) { else if ($scope.currentCity.wind.deg > 200 && $scope.currentCity.wind.deg < 245) {
$scope.currentCity.wind.desc = "South-West"; $scope.currentCity.wind.desc = t('weather', 'South-West');
} }
else if ($scope.currentCity.wind.deg > 244 && $scope.currentCity.wind.deg < 289) { else if ($scope.currentCity.wind.deg > 244 && $scope.currentCity.wind.deg < 289) {
$scope.currentCity.wind.desc = "West"; $scope.currentCity.wind.desc = t('weather', 'West');
} }
else if ($scope.currentCity.wind.deg > 288 && $scope.currentCity.wind.deg < 334) { else if ($scope.currentCity.wind.deg > 288 && $scope.currentCity.wind.deg < 334) {
$scope.currentCity.wind.desc = "North-West"; $scope.currentCity.wind.desc = t('weather', 'North-West');
} }
$scope.cityLoadError = ''; $scope.cityLoadError = '';
} }
else { else {
$scope.cityLoadError = 'Failed to get city weather informations. Please contact your administrator'; $scope.cityLoadError = t('weather', 'Failed to get city weather informations. Please contact your administrator');
} }
$scope.cityLoadNeedsAPIKey = false; $scope.cityLoadNeedsAPIKey = false;
}, },
function (r) { function (r) {
if (r.status == 404) { if (r.status == 404) {
$scope.cityLoadError = "No city with this name found."; $scope.cityLoadError = t('weather','No city with this name found.');
$scope.cityLoadNeedsAPIKey = false; $scope.cityLoadNeedsAPIKey = false;
} }
else if (r.status == 401) { else if (r.status == 401) {
$scope.cityLoadError = "Your OpenWeatherMap API key is invalid. Contact your administrator to configure a valid API key in Additional Settings of the Administration"; $scope.cityLoadError = t('weather', 'Your OpenWeatherMap API key is invalid. Contact your administrator to configure a valid API key in Additional Settings of the Administration');
$scope.cityLoadNeedsAPIKey = true; $scope.cityLoadNeedsAPIKey = true;
} }
else { else {
@ -211,7 +211,7 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil
$scope.addCity = function(city) { $scope.addCity = function(city) {
if (undef(city) || emptyStr(city.name)) { if (undef(city) || emptyStr(city.name)) {
$scope.addCityError = 'Empty city name !'; $scope.addCityError = t('weather', 'Empty city name !');
return; return;
} }
@ -229,18 +229,18 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil
city.name = ""; city.name = "";
} }
else { else {
$scope.addCityError = 'Failed to add city. Please contact your administrator'; $scope.addCityError = t('weather', 'Failed to add city. Please contact your administrator');
} }
}, },
function (r) { function (r) {
if (r.status == 401) { if (r.status == 401) {
$scope.addCityError = "Your OpenWeatherMap API key is invalid. Contact your administrator to configure a valid API key in Additional Settings of the Administration"; $scope.addCityError = t('weather', 'Your OpenWeatherMap API key is invalid. Contact your administrator to configure a valid API key in Additional Settings of the Administration');
} }
else if (r.status == 404) { else if (r.status == 404) {
$scope.addCityError = "No city with this name found."; $scope.addCityError = t('weather', 'No city with this name found.');
} }
else if (r.status == 409) { else if (r.status == 409) {
$scope.addCityError = "This city is already registered for your account."; $scope.addCityError = t('weather', 'This city is already registered for your account.');
} }
else { else {
$scope.addCityError = g_error500; $scope.addCityError = g_error500;
@ -270,7 +270,7 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil
} }
} }
else { else {
alert('Failed to remove city. Please contact your administrator'); alert(t('weather', 'Failed to remove city. Please contact your administrator'));
} }
}, },
function (r) { function (r) {
@ -290,7 +290,7 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil
$scope.homeCity = cityId; $scope.homeCity = cityId;
} }
else { else {
alert('Failed to set home. Please contact your administrator'); alert(t('weather', 'Failed to set home. Please contact your administrator'));
} }
}, },
function (r) { function (r) {