diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-10-31 22:19:18 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-10-31 22:19:18 +0100 |
commit | 9b01180ec981d6d0ffd7b0e84a3ddbb0a2cf1ecc (patch) | |
tree | 66ec7089fca89fcaa4f769cc74cf12e783968ea9 /src/hydrilla/proxy/state_impl | |
parent | f1638c63de7c27c2fdccb55f4b540c8fb79d3762 (diff) | |
download | haketilo-hydrilla-9b01180ec981d6d0ffd7b0e84a3ddbb0a2cf1ecc.tar.gz haketilo-hydrilla-9b01180ec981d6d0ffd7b0e84a3ddbb0a2cf1ecc.zip |
[builder][server][proxy] complete internationalization and add polish translation
Diffstat (limited to 'src/hydrilla/proxy/state_impl')
-rw-r--r-- | src/hydrilla/proxy/state_impl/concrete_state.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/hydrilla/proxy/state_impl/concrete_state.py b/src/hydrilla/proxy/state_impl/concrete_state.py index a5c547f..e97514a 100644 --- a/src/hydrilla/proxy/state_impl/concrete_state.py +++ b/src/hydrilla/proxy/state_impl/concrete_state.py @@ -71,6 +71,14 @@ def _add_popup_settings_columns(cursor: sqlite3.Cursor) -> None: ''' ) +def _add_locale_column(cursor: sqlite3.Cursor) -> None: + cursor.execute( + ''' + ALTER TABLE general ADD COLUMN + locale VARCHAR NOT NULL DEFAULT 'unknown'; + ''' + ) + def _prepare_database(connection: sqlite3.Connection) -> None: cursor = connection.cursor() @@ -111,6 +119,7 @@ def _prepare_database(connection: sqlite3.Connection) -> None: raise HaketiloException(_('err.proxy.unknown_db_schema')) popup_settings_columns_present = False + locale_column_present = False cursor.execute("PRAGMA TABLE_INFO('general')") for __cid, name, __type, __notnull, __dflt_value, __pk \ @@ -118,16 +127,20 @@ def _prepare_database(connection: sqlite3.Connection) -> None: if name == 'default_popup_jsallowed_onkeyboard': popup_settings_columns_present = True + if name == 'locale': + locale_column_present = True + if not popup_settings_columns_present: _add_popup_settings_columns(cursor) + if not locale_column_present: + _add_locale_column(cursor) + cursor.execute('COMMIT TRANSACTION;') except: cursor.execute('ROLLBACK TRANSACTION;') raise - - cursor.execute('PRAGMA FOREIGN_KEYS;') if cursor.fetchall() == []: raise HaketiloException(_('err.proxy.no_sqlite_foreign_keys')) @@ -144,14 +157,15 @@ def load_settings(cursor: sqlite3.Cursor) -> st.HaketiloGlobalSettings: default_allow_scripts, advanced_user, repo_refresh_seconds, - mapping_use_mode + mapping_use_mode, + locale FROM general; ''' ) (default_allow_scripts, advanced_user, repo_refresh_seconds, - mapping_use_mode), = cursor.fetchall() + mapping_use_mode, locale), = cursor.fetchall() popup_settings_dict = {} @@ -181,6 +195,7 @@ def load_settings(cursor: sqlite3.Cursor) -> st.HaketiloGlobalSettings: advanced_user = advanced_user, repo_refresh_seconds = repo_refresh_seconds, mapping_use_mode = st.MappingUseMode(mapping_use_mode), + locale = locale, **popup_settings_dict ) @@ -422,6 +437,7 @@ class ConcreteHaketiloState(base.HaketiloStateWithFields): default_allow_scripts: t.Optional[bool] = None, advanced_user: t.Optional[bool] = None, repo_refresh_seconds: t.Optional[int] = None, + locale: t.Optional[str] = None, default_popup_settings: t.Mapping[str, st.PopupSettings] = {} ) -> None: with self.cursor(transaction=True) as cursor: @@ -436,6 +452,8 @@ class ConcreteHaketiloState(base.HaketiloStateWithFields): set_opt('advanced_user', advanced_user) if repo_refresh_seconds is not None: set_opt('repo_refresh_seconds', repo_refresh_seconds) + if locale is not None: + set_opt('locale', locale) for page_type in ('jsallowed', 'jsblocked', 'payloadon'): popup_settings = default_popup_settings.get(page_type) |