From aee45c06bda41757e97ecec179641e25618d0d09 Mon Sep 17 00:00:00 2001
From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
Date: Fri, 4 Jun 2021 17:29:02 -0700
Subject: [PATCH] Add setting to change locale
---
data/interfaces/default/settings.html | 18 +++++++++++++++++-
plexpy/common.py | 5 +++++
plexpy/config.py | 1 +
plexpy/webserve.py | 11 ++++++++++-
4 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html
index 618acc6a..fe0992d3 100644
--- a/data/interfaces/default/settings.html
+++ b/data/interfaces/default/settings.html
@@ -98,6 +98,19 @@
Display Settings
+
@@ -2311,7 +2324,7 @@ $(document).ready(function() {
}
// Alert the user that their changes require a restart.
- function postSaveChecks() {
+ function postSaveChecks(data) {
if (authChanged || httpChanged || directoryChanged) {
$('#restart-modal').modal('show');
}
@@ -2325,6 +2338,9 @@ $(document).ready(function() {
setBaseURLSuffix();
toggleRevealTokens();
settingsChanged = false;
+ if (data.responseJSON.refresh) {
+ location.reload();
+ }
}
var configForm = $("#configUpdate");
diff --git a/plexpy/common.py b/plexpy/common.py
index 7572c7c2..bb7922a6 100644
--- a/plexpy/common.py
+++ b/plexpy/common.py
@@ -258,6 +258,11 @@ SCHEDULER_LIST = [
]
SCHEDULER_LIST = OrderedDict(SCHEDULER_LIST)
+LOCALES = {
+ 'en': 'English',
+ 'fr': 'French'
+}
+
DATE_TIME_FORMATS = [
{
'category': 'Year',
diff --git a/plexpy/config.py b/plexpy/config.py
index f17a9829..c0f98a11 100644
--- a/plexpy/config.py
+++ b/plexpy/config.py
@@ -143,6 +143,7 @@ _CONFIG_DEFINITIONS = {
'JOURNAL_MODE': (str, 'Advanced', 'WAL'),
'LAUNCH_BROWSER': (int, 'General', 1),
'LAUNCH_STARTUP': (int, 'General', 1),
+ 'LOCALE': (str, 'General', 'en'),
'LOG_BLACKLIST': (int, 'General', 1),
'LOG_DIR': (str, 'General', ''),
'LOGGING_IGNORE_INTERVAL': (int, 'Monitoring', 120),
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index aa0502da..fc58ca7f 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -3185,6 +3185,7 @@ class WebInterface(object):
"pms_web_url": plexpy.CONFIG.PMS_WEB_URL,
"pms_name": plexpy.CONFIG.PMS_NAME,
"pms_update_check_interval": plexpy.CONFIG.PMS_UPDATE_CHECK_INTERVAL,
+ "locale": plexpy.CONFIG.LOCALE,
"date_format": plexpy.CONFIG.DATE_FORMAT,
"time_format": plexpy.CONFIG.TIME_FORMAT,
"week_start_monday": checked(plexpy.CONFIG.WEEK_START_MONDAY),
@@ -3259,6 +3260,7 @@ class WebInterface(object):
https_changed = False
refresh_libraries = False
refresh_users = False
+ refresh_page = False
# First run from the setup wizard
if kwargs.pop('first_run', None):
@@ -3321,6 +3323,10 @@ class WebInterface(object):
kwargs.get('launch_browser') != plexpy.CONFIG.LAUNCH_BROWSER:
startup_changed = True
+ # Refresh the page if locale changed
+ if kwargs.get('locale') != plexpy.CONFIG.LOCALE:
+ refresh_page = True
+
# If we change any monitoring settings, make sure we reschedule tasks.
if kwargs.get('check_github') != plexpy.CONFIG.CHECK_GITHUB or \
kwargs.get('check_github_interval') != str(plexpy.CONFIG.CHECK_GITHUB_INTERVAL) or \
@@ -3421,7 +3427,10 @@ class WebInterface(object):
if refresh_users:
threading.Thread(target=users.refresh_users).start()
- return {'result': 'success', 'message': 'Settings saved.'}
+ result = {'result': 'success', 'message': 'Settings saved.'}
+ if refresh_page:
+ result['refresh'] = refresh_page
+ return result
@cherrypy.expose
@cherrypy.tools.json_out()