diff --git a/package.serve.json b/package.serve.json
index 9743376ef..ceb0f1f7a 100644
--- a/package.serve.json
+++ b/package.serve.json
@@ -47,13 +47,13 @@
"angular-sanitize": "1.6.7",
"angular-simple-logger": "^0.1.7",
"angular-translate": "^2.18.1",
- "angular-translate-interpolation-messageformat": "^2.18.1",
"angular-translate-loader-static-files": "^2.18.1",
"angular-ui-router": "0.2.13",
"animate.css": "^3.5.2",
"bottleneck": "^2.19.5",
"core-js": "^2.5.7",
"fs-extra": "^9.0.1",
+ "i18next": "^22.5.0",
"install": "^0.13.0",
"ionic-datepicker": "1.2.1",
"ionic-toast": "^0.4.1",
@@ -63,8 +63,10 @@
"leaflet": "^0.7.7",
"leaflet-plugins": "^3.0.0",
"leaflet.awesome-markers": "^2.0.5",
+ "messageformat": "^2.3.0",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
+ "ng-i18next": "^1.0.7",
"npm": "^9.6.3",
"nvd3": "^1.8.6",
"prop-types": "^15.8.1",
diff --git a/www/i18n/en.json b/www/i18n/en.json
index b368f61c5..79eb3b277 100644
--- a/www/i18n/en.json
+++ b/www/i18n/en.json
@@ -243,7 +243,6 @@
"average": "Average for group:",
"avoided": "CO₂ avoided (vs. all 'taxi'):",
"label-to-squish": "Label trips to collapse the range into a single number",
- "equals-phone-charges": "Saved {charges, plural, =0{at least 0 smartphone charges} one {at least 1 smartphone charge} other {at least # smartphone charges}} vs. all 'taxi'",
"lastweek": "My last week value:",
"us-2030-goal": "US 2030 Goal Estimate:",
"us-2050-goal": "US 2050 Goal Estimate:",
@@ -251,9 +250,12 @@
"calibrate": "Calibrate",
"no-summary-data": "No summary data",
"mean-speed": "My Average Speed",
- "equals-cookies": "Equals {cookies, plural, =0{at least 0 homemade chocolate chip cookies} one {at least 1 homemade chocolate chip cookie} other {at least # homemade chocolate chip cookies}}",
- "equals-icecream": "Equals {icecream, plural, =0{at least 0 half cups vanilla ice cream} one {at least 1 half cup vanilla ice cream} other {at least # half cups vanilla ice cream}}",
- "equals-bananas": "Equals {bananas, plural, =0{at least 0 bananas} one {at least 1 banana} other {at least # bananas}}"
+ "equals-cookies_one": "Equals at least {{count}} homemade chocolate chip cookie",
+ "equals-cookies_other": "Equals at least {{count}} homemade chocolate chip cookies",
+ "equals-icecream_one": "Equals at least {{count}} half cup vanilla ice cream",
+ "equals-icecream_other": "Equals at least {{count}} half cups vanilla ice cream",
+ "equals-bananas_one": "Equals at least {{count}} banana",
+ "equals-bananas_other": "Equals at least {{count}} bananas"
},
"main-diary" : "Diary",
diff --git a/www/js/app.js b/www/js/app.js
index 4cf2f6003..b9d305bfb 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -18,6 +18,8 @@ import 'angular-translate-loader-static-files';
import 'moment';
import 'moment-timezone';
+import i18next from 'i18next';
+
import 'ionic-toast';
import 'ionic-datepicker';
import 'angular-simple-logger';
@@ -25,7 +27,52 @@ import 'angular-simple-logger';
import '../manual_lib/ionic/js/ionic.js';
import '../manual_lib/ionic/js/ionic-angular.js';
-angular.module('emission', ['ionic',
+
+import en from '../i18n/en.json';
+import es from '../../locales/es/i18n/es.json';
+import fr from '../../locales/fr/i18n/fr.json';
+import it from '../../locales/it/i18n/it.json';
+const langs = { en, es, fr, it };
+
+let resources = {};
+for (const [lang, json] of Object.entries(langs)) {
+ resources[lang] = { translation: json }
+}
+
+const locales = !navigator?.length ? [navigator.language] : navigator.languages;
+
+let detectedLang;
+locales.forEach(locale => {
+ const lang = locale.trim().split(/-|_/)[0];
+ if (Object.keys(langs).includes(lang)) {
+ detectedLang = lang;
+ }
+});
+console.debug(`Detected language: ${detectedLang}`);
+console.debug('Resources:', resources);
+i18next.init({
+ debug: true,
+ resources,
+ lng: detectedLang,
+ fallbackLng: 'en'
+});
+
+console.debug('currlang:', i18next.resolvedLanguage);
+
+i18next.changeLanguage(detectedLang, (err, t) => {
+ if (err) {
+ console.error(err);
+ } else {
+ console.debug('i18next language changed to:', i18next.resolvedLanguage);
+ console.debug('t diary.draft:', t('diary.draft'));
+ console.debug('i18next.t diary.draft:', i18next.t('diary.draft'));
+ }
+});
+
+window.i18next = i18next;
+import 'ng-i18next';
+
+angular.module('emission', ['ionic', 'jm.i18next',
'emission.controllers','emission.services', 'emission.plugin.logger',
'emission.splash.customURLScheme', 'emission.splash.referral',
'emission.services.email',
@@ -75,7 +122,7 @@ angular.module('emission', ['ionic',
console.log("Ending run");
})
-.config(function($stateProvider, $urlRouterProvider, $translateProvider, $compileProvider) {
+.config(function($stateProvider, $urlRouterProvider, $compileProvider) {
console.log("Starting config");
// alert("config");
@@ -119,27 +166,6 @@ angular.module('emission', ['ionic',
// alert("about to fall back to otherwise");
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/splash');
-
- // Allow the use of MessageForm interpolation for Gender and Plural.
- // $translateProvider.addInterpolation('$translateMessageFormatInterpolation')
- // .useSanitizeValueStrategy('escape');
-
-
- // Define where we can find the .json and the fallback language
- $translateProvider
- .fallbackLanguage('en')
- .registerAvailableLanguageKeys(['en', 'fr', 'it', 'es'], {
- 'en_*': 'en',
- 'fr_*': 'fr',
- 'it_*': 'it',
- 'es_*': 'es',
- '*': 'en'
- })
- .determinePreferredLanguage()
- .useStaticFilesLoader({
- prefix: 'i18n/',
- suffix: '.json'
- });
console.log("Ending config");
});
diff --git a/www/js/appstatus/permissioncheck.js b/www/js/appstatus/permissioncheck.js
index c7fe88271..0e1c81a64 100644
--- a/www/js/appstatus/permissioncheck.js
+++ b/www/js/appstatus/permissioncheck.js
@@ -16,7 +16,7 @@ angular.module('emission.appstatus.permissioncheck',
};
}).
controller("PermissionCheckControl", function($scope, $element, $attrs,
- $ionicPlatform, $ionicPopup, $window, $translate) {
+ $ionicPlatform, $ionicPopup, $window) {
console.log("PermissionCheckControl initialized with status "+$scope.overallstatus);
$scope.setupLocChecks = function(platform, version) {
@@ -197,15 +197,15 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
console.log("description tags are "+androidSettingsDescTag+" "+androidPermDescTag);
// location settings
let locSettingsCheck = {
- name: $translate.instant("intro.appstatus.locsettings.name"),
- desc: $translate.instant(androidSettingsDescTag),
+ name: i18next.t("intro.appstatus.locsettings.name"),
+ desc: i18next.t(androidSettingsDescTag),
statusState: false,
fix: fixSettings,
refresh: checkSettings
}
let locPermissionsCheck = {
- name: $translate.instant("intro.appstatus.locperms.name"),
- desc: $translate.instant(androidPermDescTag),
+ name: i18next.t("intro.appstatus.locperms.name"),
+ desc: i18next.t(androidPermDescTag),
statusState: false,
fix: fixPerms,
refresh: checkPerms
@@ -243,15 +243,15 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
console.log("description tags are "+iOSSettingsDescTag+" "+iOSPermDescTag);
// location settings
let locSettingsCheck = {
- name: $translate.instant("intro.appstatus.locsettings.name"),
- desc: $translate.instant(iOSSettingsDescTag),
+ name: i18next.t("intro.appstatus.locsettings.name"),
+ desc: i18next.t(iOSSettingsDescTag),
statusState: false,
fix: fixSettings,
refresh: checkSettings
}
let locPermissionsCheck = {
- name: $translate.instant("intro.appstatus.locperms.name"),
- desc: $translate.instant(iOSPermDescTag),
+ name: i18next.t("intro.appstatus.locperms.name"),
+ desc: i18next.t(iOSPermDescTag),
statusState: false,
fix: fixPerms,
refresh: checkPerms
@@ -275,12 +275,12 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
};
let fitnessPermissionsCheck = {
- name: $translate.instant("intro.appstatus.fitnessperms.name"),
- desc: $translate.instant("intro.appstatus.fitnessperms.description.android"),
+ name: i18next.t("intro.appstatus.fitnessperms.name"),
+ desc: i18next.t("intro.appstatus.fitnessperms.description.android"),
fix: fixPerms,
refresh: checkPerms
}
- $scope.overallFitnessName = $translate.instant("intro.appstatus.overall-fitness-name-android");
+ $scope.overallFitnessName = i18next.t("intro.appstatus.overall-fitness-name-android");
$scope.fitnessChecks = [fitnessPermissionsCheck];
refreshChecks($scope.fitnessChecks, $scope.recomputeFitnessStatus);
}
@@ -300,12 +300,12 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
};
let fitnessPermissionsCheck = {
- name: $translate.instant("intro.appstatus.fitnessperms.name"),
- desc: $translate.instant("intro.appstatus.fitnessperms.description.ios"),
+ name: i18next.t("intro.appstatus.fitnessperms.name"),
+ desc: i18next.t("intro.appstatus.fitnessperms.description.ios"),
fix: fixPerms,
refresh: checkPerms
}
- $scope.overallFitnessName = $translate.instant("intro.appstatus.overall-fitness-name-ios");
+ $scope.overallFitnessName = i18next.t("intro.appstatus.overall-fitness-name-ios");
$scope.fitnessChecks = [fitnessPermissionsCheck];
refreshChecks($scope.fitnessChecks, $scope.recomputeFitnessStatus);
}
@@ -322,8 +322,8 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
$scope.recomputeNotificationStatus, false);
};
let appAndChannelNotificationsCheck = {
- name: $translate.instant("intro.appstatus.notificationperms.app-enabled-name"),
- desc: $translate.instant("intro.appstatus.notificationperms.description.android-enable"),
+ name: i18next.t("intro.appstatus.notificationperms.app-enabled-name"),
+ desc: i18next.t("intro.appstatus.notificationperms.description.android-enable"),
fix: fixPerms,
refresh: checkPerms
}
@@ -357,14 +357,14 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
androidUnusedDescTag= "intro.appstatus.unusedapprestrict.description.android-disable-lt-12";
}
let unusedAppsUnrestrictedCheck = {
- name: $translate.instant("intro.appstatus.unusedapprestrict.name"),
- desc: $translate.instant(androidUnusedDescTag),
+ name: i18next.t("intro.appstatus.unusedapprestrict.name"),
+ desc: i18next.t(androidUnusedDescTag),
fix: fixPerms,
refresh: checkPerms
}
let ignoreBatteryOptCheck = {
- name: $translate.instant("intro.appstatus.ignorebatteryopt.name"),
- desc: $translate.instant("intro.appstatus.ignorebatteryopt.description.android-disable"),
+ name: i18next.t("intro.appstatus.ignorebatteryopt.name"),
+ desc: i18next.t("intro.appstatus.ignorebatteryopt.description.android-disable"),
fix: fixBatteryOpt,
refresh: checkBatteryOpt
}
@@ -375,16 +375,16 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
$scope.setupPermissionText = function() {
if($scope.platform.toLowerCase() == "ios") {
if($scope.osver < 13) {
- $scope.locationPermExplanation = $translate.instant("intro.permissions.locationPermExplanation-ios-lt-13");
+ $scope.locationPermExplanation = i18next.t("intro.permissions.locationPermExplanation-ios-lt-13");
} else {
- $scope.locationPermExplanation = $translate.instant("intro.permissions.locationPermExplanation-ios-gte-13");
+ $scope.locationPermExplanation = i18next.t("intro.permissions.locationPermExplanation-ios-gte-13");
}
}
$scope.backgroundRestricted = false;
if($window.device.manufacturer.toLowerCase() == "samsung") {
$scope.backgroundRestricted = true;
- $scope.allowBackgroundInstructions = $translate.instant("intro.allow_background.samsung");
+ $scope.allowBackgroundInstructions = i18next.t("intro.allow_background.samsung");
}
console.log("Explanation = "+$scope.locationPermExplanation);
diff --git a/www/js/config/dynamic_config.js b/www/js/config/dynamic_config.js
index ba470f9bb..e8bb63895 100644
--- a/www/js/config/dynamic_config.js
+++ b/www/js/config/dynamic_config.js
@@ -4,7 +4,7 @@ import angular from 'angular';
angular.module('emission.config.dynamic', ['emission.plugin.logger'])
.factory('DynamicConfig', function($http, $ionicPlatform,
- $window, $state, $rootScope, $timeout, Logger, $translate) {
+ $window, $state, $rootScope, $timeout, Logger) {
// also used in the startprefs class
// but without importing this
const CONFIG_PHONE_UI="config/app_ui_config";
@@ -73,7 +73,7 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
return savedConfig;
}
})
- .catch((err) => Logger.displayError($translate.instant('config.unable-read-saved-config'), err));
+ .catch((err) => Logger.displayError(i18next.t('config.unable-read-saved-config'), err));
}
/**
@@ -107,7 +107,7 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
if (thenGoToIntro) $state.go("root.intro")
})
.then(() => true)
- .catch((storeError) => Logger.displayError($translate.instant('config.unable-to-store-config'), storeError));
+ .catch((storeError) => Logger.displayError(i18next.t('config.unable-to-store-config'), storeError));
});
}
@@ -181,10 +181,10 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
const tokenParts = token.split("_");
if (tokenParts.length < 3) {
// all tokens must have at least nrelop_[study name]_...
- throw new Error($translate.instant('config.not-enough-parts-old-style', {"token": token}));
+ throw new Error(i18next.t('config.not-enough-parts-old-style', {"token": token}));
}
if (tokenParts[0] != "nrelop") {
- throw new Error($translate.instant('config.no-nrelop-start', {token: token}));
+ throw new Error(i18next.t('config.no-nrelop-start', {token: token}));
}
return tokenParts[1];
}
@@ -194,12 +194,12 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
// new style study, expects token with sub-group
const tokenParts = token.split("_");
if (tokenParts.length <= 3) { // no subpart defined
- throw new Error($translate.instant('config.not-enough-parts', {token: token}));
+ throw new Error(i18next.t('config.not-enough-parts', {token: token}));
}
if (config.opcode.subgroups) {
if (config.opcode.subgroups.indexOf(tokenParts[2]) == -1) {
// subpart not in config list
- throw new Error($translate.instant('config.invalid-subgroup', {token: token, subgroup: tokenParts[2], config_subgroups: config.opcode.subgroups}));
+ throw new Error(i18next.t('config.invalid-subgroup', {token: token, subgroup: tokenParts[2], config_subgroups: config.opcode.subgroups}));
} else {
console.log("subgroup "+tokenParts[2]+" found in list "+config.opcode.subgroups);
return tokenParts[2];
@@ -207,7 +207,7 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
} else {
if (tokenParts[2] != "default") {
// subpart not in config list
- throw new Error($translate.instant('config.invalid-subgroup', {token: token}));
+ throw new Error(i18next.t('config.invalid-subgroup', {token: token}));
} else {
console.log("no subgroups in config, 'default' subgroup found in token ");
return tokenParts[2];
@@ -246,10 +246,10 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
// on successful download, cache the token in the rootScope
.then((wasUpdated) => {$rootScope.scannedToken = dc.scannedToken})
.catch((fetchErr) => {
- Logger.displayError($translate.instant('config.unable-download-config'), fetchErr);
+ Logger.displayError(i18next.t('config.unable-download-config'), fetchErr);
});
} catch (error) {
- Logger.displayError($translate.instant('config.invalid-opcode-format'), error);
+ Logger.displayError(i18next.t('config.invalid-opcode-format'), error);
return Promise.reject(error);
}
});
@@ -277,7 +277,7 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
$rootScope.$apply(() => dc.saveAndNotifyConfigReady(existingConfig));
}
}).catch((err) => {
- Logger.displayError($translate('config.error-loading-config-app-start'), err)
+ Logger.displayError('Error loading config on app start', err)
});
};
$ionicPlatform.ready().then(function() {
diff --git a/www/js/control/emailService.js b/www/js/control/emailService.js
index ade76dc6f..0374adf5a 100644
--- a/www/js/control/emailService.js
+++ b/www/js/control/emailService.js
@@ -4,7 +4,7 @@ import angular from 'angular';
angular.module('emission.services.email', ['emission.plugin.logger'])
- .service('EmailHelper', function ($window, $translate, $http, Logger) {
+ .service('EmailHelper', function ($window, $http, Logger) {
const getEmailConfig = function () {
return new Promise(function (resolve, reject) {
@@ -55,7 +55,7 @@ angular.module('emission.services.email', ['emission.plugin.logger'])
// generate a reasonably relevant error message
if (ionic.Platform.isIOS() && !hasAct) {
- alert($translate.instant('email-service.email-account-not-configured'));
+ alert(i18next.t('email-service.email-account-not-configured'));
return;
}
@@ -63,7 +63,7 @@ angular.module('emission.services.email', ['emission.plugin.logger'])
parentDir = "app://databases";
}
if (ionic.Platform.isIOS()) {
- alert($translate.instant('email-service.email-account-mail-app'));
+ alert(i18next.t('email-service.email-account-mail-app'));
parentDir = cordova.file.dataDirectory + "../LocalDatabase";
}
@@ -77,19 +77,19 @@ angular.module('emission.services.email', ['emission.plugin.logger'])
window.Logger.log(window.Logger.LEVEL_INFO,
"Going to export logs to "+parentDir);
*/
- alert($translate.instant('email-service.going-to-email', { parentDir: parentDir }));
+ alert(i18next.t('email-service.going-to-email', { parentDir: parentDir }));
var email = {
to: address,
attachments: [
parentDir
],
- subject: $translate.instant('email-service.email-log.subject-logs'),
- body: $translate.instant('email-service.email-log.body-please-fill-in-what-is-wrong')
+ subject: i18next.t('email-service.email-log.subject-logs'),
+ body: i18next.t('email-service.email-log.body-please-fill-in-what-is-wrong')
}
$window.cordova.plugins.email.open(email, function () {
Logger.log("email app closed while sending, "+JSON.stringify(email)+" not sure if we should do anything");
- // alert($translate.instant('email-service.no-email-address-configured') + err);
+ // alert(i18next.t('email-service.no-email-address-configured') + err);
return;
});
});
diff --git a/www/js/control/general-settings.js b/www/js/control/general-settings.js
index b58f74484..6bdc13c1c 100644
--- a/www/js/control/general-settings.js
+++ b/www/js/control/general-settings.js
@@ -27,18 +27,17 @@ angular.module('emission.main.control',['emission.services',
ControlCollectionHelper, ControlSyncHelper,
CarbonDatasetHelper, NotificationScheduler, LocalNotify,
i18nUtils,
- CalorieCal, ClientStats, CommHelper, Logger, DynamicConfig,
- $translate) {
+ CalorieCal, ClientStats, CommHelper, Logger, DynamicConfig) {
console.log("controller ControlCtrl called without params");
var datepickerObject = {
- todayLabel: $translate.instant('list-datepicker-today'), //Optional
- closeLabel: $translate.instant('list-datepicker-close'), //Optional
- setLabel: $translate.instant('list-datepicker-set'), //Optional
+ todayLabel: i18next.t('list-datepicker-today'), //Optional
+ closeLabel: i18next.t('list-datepicker-close'), //Optional
+ setLabel: i18next.t('list-datepicker-set'), //Optional
monthsList: moment.monthsShort(),
weeksList: moment.weekdaysMin(),
- titleLabel: $translate.instant('general-settings.choose-date'),
+ titleLabel: i18next.t('general-settings.choose-date'),
setButtonType : 'button-positive', //Optional
todayButtonType : 'button-stable', //Optional
closeButtonType : 'button-stable', //Optional
@@ -71,7 +70,7 @@ angular.module('emission.main.control',['emission.services',
ionicDatePicker.openDatePicker(datepickerObject);
};
- $scope.carbonDatasetString = $translate.instant('general-settings.carbon-dataset') + ": " + CarbonDatasetHelper.getCurrentCarbonDatasetCode();
+ $scope.carbonDatasetString = i18next.t('general-settings.carbon-dataset') + ": " + CarbonDatasetHelper.getCurrentCarbonDatasetCode();
$scope.uploadLog = function () {
UploadHelper.uploadFile("loggerDB")
@@ -155,7 +154,7 @@ angular.module('emission.main.control',['emission.services',
age: userDataFromStorage.age,
height: height + (userDataFromStorage.heightUnit == 1? ' cm' : ' ft'),
weight: weight + (userDataFromStorage.weightUnit == 1? ' kg' : ' lb'),
- gender: userDataFromStorage.gender == 1? $translate.instant('gender-male') : $translate.instant('gender-female')
+ gender: userDataFromStorage.gender == 1? i18next.t('gender-male') : i18next.t('gender-female')
}
for (var i in temp) {
$scope.userData.push({key: i, value: temp[i]});
@@ -270,16 +269,16 @@ angular.module('emission.main.control',['emission.services',
}
$scope.nukeUserCache = function() {
- var nukeChoiceActions = [{text: $translate.instant('general-settings.nuke-ui-state-only'),
+ var nukeChoiceActions = [{text: i18next.t('general-settings.nuke-ui-state-only'),
action: KVStore.clearOnlyLocal},
- {text: $translate.instant('general-settings.nuke-native-cache-only'),
+ {text: i18next.t('general-settings.nuke-native-cache-only'),
action: KVStore.clearOnlyNative},
- {text: $translate.instant('general-settings.nuke-everything'),
+ {text: i18next.t('general-settings.nuke-everything'),
action: KVStore.clearAll}];
$ionicActionSheet.show({
- titleText: $translate.instant('general-settings.clear-data'),
- cancelText: $translate.instant('general-settings.cancel'),
+ titleText: i18next.t('general-settings.clear-data'),
+ cancelText: i18next.t('general-settings.cancel'),
buttons: nukeChoiceActions,
buttonClicked: function(index, button) {
button.action();
@@ -520,7 +519,7 @@ angular.module('emission.main.control',['emission.services',
}
$scope.eraseUserData = function() {
CalorieCal.delete().then(function() {
- $ionicPopup.alert({template: $translate.instant('general-settings.user-data-erased')});
+ $ionicPopup.alert({template: i18next.t('general-settings.user-data-erased')});
});
}
$scope.parseState = function(state) {
@@ -535,12 +534,12 @@ angular.module('emission.main.control',['emission.services',
$scope.changeCarbonDataset = function() {
$ionicActionSheet.show({
buttons: CarbonDatasetHelper.getCarbonDatasetOptions(),
- titleText: $translate.instant('general-settings.choose-dataset'),
- cancelText: $translate.instant('general-settings.cancel'),
+ titleText: i18next.t('general-settings.choose-dataset'),
+ cancelText: i18next.t('general-settings.cancel'),
buttonClicked: function(index, button) {
console.log("changeCarbonDataset(): chose locale " + button.value);
CarbonDatasetHelper.saveCurrentCarbonDatasetLocale(button.value);
- $scope.carbonDatasetString = $translate.instant('general-settings.carbon-dataset') + ": " + CarbonDatasetHelper.getCurrentCarbonDatasetCode();
+ $scope.carbonDatasetString = i18next.t('general-settings.carbon-dataset') + ": " + CarbonDatasetHelper.getCurrentCarbonDatasetCode();
return true;
}
});
@@ -572,13 +571,13 @@ angular.module('emission.main.control',['emission.services',
}
var handleNoConsent = function(resultDoc) {
- $ionicPopup.confirm({template: $translate.instant('general-settings.consent-not-found')})
+ $ionicPopup.confirm({template: i18next.t('general-settings.consent-not-found')})
.then(function(res){
if (res) {
$state.go("root.reconsent");
} else {
$ionicPopup.alert({
- template: $translate.instant('general-settings.no-consent-message')});
+ template: i18next.t('general-settings.no-consent-message')});
}
});
}
@@ -586,13 +585,13 @@ angular.module('emission.main.control',['emission.services',
var handleConsent = function(resultDoc) {
$scope.consentDoc = resultDoc;
$ionicPopup.confirm({
- template: $translate.instant('general-settings.consented-to',{protocol_id: $scope.consentDoc.protocol_id,approval_date: $scope.consentDoc.approval_date}),
+ template: i18next.t('general-settings.consented-to',{protocol_id: $scope.consentDoc.protocol_id,approval_date: $scope.consentDoc.approval_date}),
scope: $scope,
- title: $translate.instant('general-settings.consent-found'),
+ title: i18next.t('general-settings.consent-found'),
buttons: [
// {text: "View",
// type: 'button-calm'},
- {text: ""+ $translate.instant('general-settings.consented-ok') +"",
+ {text: ""+ i18next.t('general-settings.consented-ok') +"",
type: 'button-positive'} ]
}).finally(function(res) {
$scope.consentDoc = null;
@@ -612,9 +611,9 @@ angular.module('emission.main.control',['emission.services',
}
var prepopulateMessage = {
- message: $translate.instant('general-settings.share-message'), // not supported on some apps (Facebook, Instagram)
- subject: $translate.instant('general-settings.share-subject'), // fi. for email
- url: $translate.instant('general-settings.share-url')
+ message: i18next.t('general-settings.share-message'), // not supported on some apps (Facebook, Instagram)
+ subject: i18next.t('general-settings.share-subject'), // fi. for email
+ url: i18next.t('general-settings.share-url')
}
$scope.share = function() {
diff --git a/www/js/control/uploadService.js b/www/js/control/uploadService.js
index 5d8b0b204..6f95503c1 100644
--- a/www/js/control/uploadService.js
+++ b/www/js/control/uploadService.js
@@ -4,7 +4,7 @@ import angular from 'angular';
angular.module('emission.services.upload', ['emission.plugin.logger'])
- .service('UploadHelper', function ($window, $translate, $http, $rootScope, $ionicPopup, Logger) {
+ .service('UploadHelper', function ($window, $http, $rootScope, $ionicPopup, Logger) {
const getUploadConfig = function () {
return new Promise(function (resolve, reject) {
Logger.log(Logger.LEVEL_INFO, "About to get email config");
@@ -93,13 +93,13 @@ angular.module('emission.services.upload', ['emission.plugin.logger'])
const newScope = $rootScope.$new();
newScope.data = {};
- newScope.fromDirText = $translate.instant('upload-service.upload-from-dir', {parentDir: parentDir});
- newScope.toServerText = $translate.instant('upload-service.upload-to-server', {serverURL: uploadConfig});
+ newScope.fromDirText = i18next.t('upload-service.upload-from-dir', {parentDir: parentDir});
+ newScope.toServerText = i18next.t('upload-service.upload-to-server', {serverURL: uploadConfig});
var didCancel = true;
const detailsPopup = $ionicPopup.show({
- title: $translate.instant("upload-service.upload-database", { db: database }),
+ title: i18next.t("upload-service.upload-database", { db: database }),
template: newScope.toServerText
+ '',
@@ -142,9 +142,9 @@ angular.module('emission.services.upload', ['emission.plugin.logger'])
}
uploadConfig.forEach((url) => {
const progressPopup = $ionicPopup.show({
- title: $translate.instant("upload-service.upload-database",
+ title: i18next.t("upload-service.upload-database",
{db: database}),
- template: $translate.instant("upload-service.upload-progress",
+ template: i18next.t("upload-service.upload-progress",
{filesizemb: binString.byteLength / (1000 * 1000),
serverURL: uploadConfig})
+ '
',
@@ -157,8 +157,8 @@ angular.module('emission.services.upload', ['emission.plugin.logger'])
console.log(response);
progressPopup.close();
const successPopup = $ionicPopup.alert({
- title: $translate.instant("upload-service.upload-success"),
- template: $translate.instant("upload-service.upload-details",
+ title: i18next.t("upload-service.upload-success"),
+ template: i18next.t("upload-service.upload-details",
{filesizemb: binString.byteLength / (1000 * 1000),
serverURL: uploadConfig})
});
diff --git a/www/js/diary/infinite_scroll_detail.js b/www/js/diary/infinite_scroll_detail.js
index aa4ce39e0..8aa01fbbf 100644
--- a/www/js/diary/infinite_scroll_detail.js
+++ b/www/js/diary/infinite_scroll_detail.js
@@ -14,7 +14,7 @@ angular.module('emission.main.diary.infscrolldetail', [
.controller("InfiniteDiaryDetailCtrl", function($scope, $rootScope, $injector, $window, $ionicPlatform,
$state, $stateParams, ClientStats, $ionicActionSheet, KVStore,
Logger, Timeline, DiaryHelper, SurveyOptions, Config, ImperialConfig,
- DynamicConfig, CommHelper, $translate) {
+ DynamicConfig, CommHelper) {
console.log("controller InfiniteDiaryDetailCtrl called with params = "+
JSON.stringify($stateParams));
@@ -41,7 +41,7 @@ angular.module('emission.main.diary.infscrolldetail', [
});
var dataset = {
values: data,
- key: $translate.instant('details.speed'),
+ key: i18next.t('details.speed'),
color: '#7777ff',
}
var chart = nv.models.lineChart()
@@ -53,10 +53,10 @@ angular.module('emission.main.diary.infscrolldetail', [
.showXAxis(true); //Show the x-axis
chart.xAxis
.tickFormat(d3.format(".1f"))
- .axisLabel($translate.instant('details.time') + ' (mins)');
+ .axisLabel(i18next.t('details.time') + ' (mins)');
chart.yAxis //Chart y-axis settings
- .axisLabel($translate.instant('details.speed') + ' (m/s)')
+ .axisLabel(i18next.t('details.speed') + ' (m/s)')
.tickFormat(d3.format('.1f'));
d3.selectAll('#chart svg') //Select the