From 612924c08757e2598756c84f9ea75fa2731070a0 Mon Sep 17 00:00:00 2001 From: Jochen Saalfeld Date: Sat, 20 Jan 2018 18:02:07 +0100 Subject: [PATCH] save language selection to session storage and adding @FinnStutzenstein remarks adding changelog entry --- AUTHORS | 1 + CHANGELOG | 1 + openslides/core/static/js/core/base.js | 19 ++++++++++++------- .../static/js/motions/motion-services.js | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index ea3a51221..3f19bdaf1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -27,3 +27,4 @@ Authors of OpenSlides in chronological order of first contribution: Meinert Leinigen Andreas Engler (Russian translation) Raimund Renkert + Jochen Saalfeld diff --git a/CHANGELOG b/CHANGELOG index 8029b6e5c..359658230 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -103,6 +103,7 @@ Core: - Added caching for the index views [#3419, #3424]. - Added projector prioritization [#3425]. - Use native twisted mode for daphne [#3487]. +- Save language selection to session storage [#3543] Mediafiles: - Fixed reloading of PDF on page change [#3274]. diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index dad5966d6..5145fe11f 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -190,15 +190,16 @@ angular.module('OpenSlidesApp.core', [ // gets all in OpenSlides available languages .factory('Languages', [ + '$sessionStorage', + '$ngBootbox', 'gettext', 'gettextCatalog', 'OpenSlidesPlugins', - '$ngBootbox', - function (gettext, gettextCatalog, OpenSlidesPlugins, $ngBootbox) { + function ($sessionStorage, $ngBootbox, gettext, gettextCatalog, OpenSlidesPlugins) { return { // get all available languages getLanguages: function () { - var current = gettextCatalog.getCurrentLanguage(); + var current = $sessionStorage.language; // Define here new languages... var languages = [ { code: 'en', name: 'English' }, @@ -236,7 +237,7 @@ angular.module('OpenSlidesApp.core', [ language.selected = false; if (language.code == lang) { language.selected = true; - gettextCatalog.setCurrentLanguage(lang); + $sessionStorage.language = lang; // Plugins if (lang != 'en') { gettextCatalog.loadRemote("static/i18n/" + lang + ".json").then(function (success) { @@ -311,12 +312,16 @@ angular.module('OpenSlidesApp.core', [ // set browser language as default language for OpenSlides .run([ + '$sessionStorage', 'gettextCatalog', 'Languages', - function(gettextCatalog, Languages) { + function($sessionStorage, gettextCatalog, Languages) { // set detected browser language as default language (fallback: 'en') - Languages.setCurrentLanguage(Languages.getBrowserLanguage()); - + if ($sessionStorage.language) { + Languages.setCurrentLanguage($sessionStorage.language); + } else { + Languages.setCurrentLanguage(Languages.getBrowserLanguage()); + } // Set this to true for debug. Helps to find untranslated strings by // adding "[MISSING]:". gettextCatalog.debug = false; diff --git a/openslides/motions/static/js/motions/motion-services.js b/openslides/motions/static/js/motions/motion-services.js index 4d8b3b40d..648ab2977 100644 --- a/openslides/motions/static/js/motions/motion-services.js +++ b/openslides/motions/static/js/motions/motion-services.js @@ -39,7 +39,7 @@ angular.module('OpenSlidesApp.motions.motionservices', ['OpenSlidesApp.motions', obj.enable = function () { obj.active = true; obj.isEditable = true; - ckeditorOptions.language = gettextCatalog.getCurrentLanguage(); + ckeditorOptions.language = localStorage.getItem('language'); obj.editor = CKEDITOR.inline(selector, ckeditorOptions); obj.editor.on('change', function () { $timeout(function() {