Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
edulix committed Feb 8, 2024
1 parent 9cd7981 commit 83d10f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
5 changes: 2 additions & 3 deletions avUi/change-lang-directive/change-lang-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ angular.module('avUi')
$rootScope,
ConfigService,
$window,
I18nOverride,
Authmethod
) {
function link(scope, element, attrs)
Expand Down Expand Up @@ -61,13 +60,13 @@ angular.module('avUi')
// remembering it, and updating all the translations instantly.
//
// Triggered when the user clicks and selects a language.
scope.changeLang = function(lang)
$window.i18next.changeAppLang = scope.changeLang = function(lang)
{
$window.i18next
.changeLanguage(lang)
.then(function () {
console.log("changeLang: broadcast i18nextLanguageChange");
$rootScope.$broadcast('i18nextLanguageChange', $i18next.options.lng);
$rootScope.$broadcast('i18nextLanguageChange', $window.i18next.resolvedLanguage);

});

Expand Down
12 changes: 9 additions & 3 deletions avUi/i18n-override-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ angular
}
console.log("calling $window.i18next.reloadResources()..");
$window.i18next
.reloadResources()
.reloadResources($i18next.options.preload)
.then(function () {
console.log("reloadResources: successful. broadcast i18nextLanguageChange signal");
$rootScope.$broadcast('i18nextLanguageChange', $i18next.options.lng);
if (languagesConf.force_default_language && $window.i18next.changeAppLang)
{
console.log("reloadResources: successful. force-changing default lang to=" + languagesConf.default_language);
$window.i18next.changeAppLang(languagesConf.default_language);
} else {
console.log("reloadResources: successful. broadcast i18nextLanguageChange signal");
$rootScope.$broadcast('i18nextLanguageChange', $i18next.options.lng);
}
});
};
}
Expand Down
13 changes: 7 additions & 6 deletions dist/appCommon-v10.1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,12 +1127,13 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
languagesConf && ($i18next.options.lng = languagesConf.force_default_language ? languagesConf.default_language : $window.i18next.resolvedLanguage,
$i18next.options.lngWhitelist = languagesConf.available_languages, $i18next.options.preload = languagesConf.available_languages,
$i18next.options.fallbackLng = [ languagesConf.default_language, "en" ]), console.log("calling $window.i18next.reloadResources().."),
$window.i18next.reloadResources().then(function() {
console.log("reloadResources: successful. broadcast i18nextLanguageChange signal"),
$rootScope.$broadcast("i18nextLanguageChange", $i18next.options.lng);
$window.i18next.reloadResources($i18next.options.preload).then(function() {
languagesConf.force_default_language && $window.i18next.changeAppLang ? (console.log("reloadResources: successful. force-changing default lang to=" + languagesConf.default_language),
$window.i18next.changeAppLang(languagesConf.default_language)) : (console.log("reloadResources: successful. broadcast i18nextLanguageChange signal"),
$rootScope.$broadcast("i18nextLanguageChange", $i18next.options.lng));
});
};
} ]), angular.module("avUi").directive("avChangeLang", [ "$i18next", "ipCookie", "angularLoad", "amMoment", "$rootScope", "ConfigService", "$window", "I18nOverride", "Authmethod", function($i18next, ipCookie, angularLoad, amMoment, $rootScope, ConfigService, $window, I18nOverride, Authmethod) {
} ]), angular.module("avUi").directive("avChangeLang", [ "$i18next", "ipCookie", "angularLoad", "amMoment", "$rootScope", "ConfigService", "$window", "Authmethod", function($i18next, ipCookie, angularLoad, amMoment, $rootScope, ConfigService, $window, Authmethod) {
return {
restrict: "AE",
scope: {},
Expand All @@ -1146,9 +1147,9 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
}, 0);
}), $rootScope.$on("i18nextLanguageChange", function(event, languageCode) {
scope.deflang = languageCode, scope.langs = $i18next.options.lngWhitelist, scope.$apply();
}), scope.changeLang = function(lang) {
}), $window.i18next.changeAppLang = scope.changeLang = function(lang) {
$window.i18next.changeLanguage(lang).then(function() {
console.log("changeLang: broadcast i18nextLanguageChange"), $rootScope.$broadcast("i18nextLanguageChange", $i18next.options.lng);
console.log("changeLang: broadcast i18nextLanguageChange"), $rootScope.$broadcast("i18nextLanguageChange", $window.i18next.resolvedLanguage);
}), console.log("setting cookie");
ipCookie("lang", lang, _.extend({
expires: 360,
Expand Down

0 comments on commit 83d10f9

Please sign in to comment.