pgAdmin 4 commit: Update message catalogs.

2017-10-27 Thread Dave Page
Update message catalogs.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=61e809b6369be6163b0ea3e62ef7c5b8e3e25fe7

Modified Files
--
web/pgadmin/messages.pot   | 640 
.../translations/de/LC_MESSAGES/messages.mo| Bin 126937 -> 127474 bytes
.../translations/de/LC_MESSAGES/messages.po| 795 +---
.../translations/pl/LC_MESSAGES/messages.mo| Bin 126007 -> 126553 bytes
.../translations/pl/LC_MESSAGES/messages.po| 813 +
.../translations/zh/LC_MESSAGES/messages.mo| Bin 101468 -> 102042 bytes
.../translations/zh/LC_MESSAGES/messages.po| 769 +--
7 files changed, 1413 insertions(+), 1604 deletions(-)



pgAdmin 4 commit: Add a Japanese translation created by:

2017-10-27 Thread Dave Page
Add a Japanese translation created by:

Junichi Tado
Nozomi Amzai
Kouske Kida

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=bc0320d21eb20019719cd7ce96137d1b9111201f

Modified Files
--
web/config.py  |3 +-
.../translations/ja/LC_MESSAGES/messages.mo|  Bin 0 -> 137860 bytes
.../translations/ja/LC_MESSAGES/messages.po| 9964 
3 files changed, 9966 insertions(+), 1 deletion(-)



Jenkins build is back to normal : pgadmin4-master-python27 #361

2017-10-27 Thread pgAdmin 4 Jenkins
See 





Re: pgadmin4 l10n issues

2017-10-27 Thread Alexander Lakhin

25.10.2017 14:52, Ashesh Vashi wrote:
On Tue, Oct 24, 2017 at 9:11 PM, Alexander Lakhin > wrote:


24.10.2017 18:11, Ashesh Vashi wrote:

Looks like - I missed to logout, and test.

Please find the updated patch.

Now the error is gone but I get no right locale.
The issue is with Desktop mode (see "if config.SERVER_MODE is
False:" in web/pgadmin/__init__.py).

Did you restart the pgAdmin4/reload after changing the language?

Yes, I restarted it.
The issue is with the current_user.
To reproduce it you can perform rm ~/.pgadmin/sessions/* and then 
restart pgAdmin4/reload the web interface.
As I understand, the modules are registered (and get_locales() first 
called) before user_login is performed in before_request.

So on very first call to get_locale() you can't use the current_user object.
Please look at v4 of the patch.

Best regards,
--
Alexander Lakhin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py
index 975659a4..e5e19ec5 100644
--- a/web/pgadmin/__init__.py
+++ b/web/pgadmin/__init__.py
@@ -17,7 +17,7 @@ from importlib import import_module
 from flask import Flask, abort, request, current_app, session, url_for
 from flask_babel import Babel, gettext
 from flask_login import user_logged_in, user_logged_out
-from flask_security import Security, SQLAlchemyUserDatastore
+from flask_security import Security, SQLAlchemyUserDatastore, current_user
 from flask_mail import Mail
 from flask_security.utils import login_user
 from werkzeug.datastructures import ImmutableDict
@@ -242,13 +242,17 @@ def create_app(app_name=None):
 language = 'en'
 if config.SERVER_MODE is False:
 # Get the user language preference from the miscellaneous module
-misc_preference = Preferences.module('miscellaneous', False)
-if misc_preference:
-user_languages = misc_preference.preference(
-'user_language'
-)
-if user_languages:
-language = user_languages.get() or language
+if current_user.is_authenticated:
+user_id = current_user.id
+else:
+user = user_datastore.get_user(config.DESKTOP_USER)
+if user is not None:
+user_id = user.id
+user_language = Preferences.raw_value(
+'miscellaneous', 'user_language', None, user_id
+)
+if user_language is not None:
+language = user_language
 else:
 # If language is available in get request then return the same
 # otherwise check the session or cookie
diff --git a/web/pgadmin/utils/preferences.py b/web/pgadmin/utils/preferences.py
index c7127c95..4a6c01b6 100644
--- a/web/pgadmin/utils/preferences.py
+++ b/web/pgadmin/utils/preferences.py
@@ -473,6 +473,41 @@ class Preferences(object):
 options, help_str, category_label
 )
 
+@staticmethod
+def raw_value(_module, _preference, _category=None, _user_id=None):
+# Find the entry for this module in the configuration database.
+module = ModulePrefTable.query.filter_by(name=_module).first()
+
+if module is None:
+return None
+
+if _category is None:
+_category = _module
+
+if _user_id is None:
+_user_id = getattr(current_user, 'id', None)
+if _user_id is None:
+return None
+
+cat = PrefCategoryTbl.query.filter_by(mid=module.id).filter_by(name=_category).first()
+
+if cat is None:
+return None
+
+pref = PrefTable.query.filter_by(name=_preference).filter_by(cid=cat.id).first()
+
+if pref is None:
+return None
+
+user_pref  = UserPrefTable.query.filter_by(
+pid=pref.id
+).filter_by(uid=_user_id).first()
+
+if user_pref is not None:
+return user_pref.value
+
+return None
+
 @classmethod
 def module(cls, name, create=True):
 """