From e5598038fa655b90fc2c386e145e10b65ecae0a2 Mon Sep 17 00:00:00 2001
From: Dave Page <dpage@pgadmin.org>
Date: Wed, 20 Feb 2019 16:39:38 +0000
Subject: [PATCH] Ensure size stats are prettified on the statistics tab when
 the UI language != English. Fixes #3096

---
 docs/en_US/release_notes_4_3.rst                     |  1 +
 .../static/js/exclusion_constraint.js                |  2 +-
 .../index_constraint/static/js/primary_key.js        |  2 +-
 .../index_constraint/static/js/unique_constraint.js  |  2 +-
 .../schemas/tables/indexes/static/js/index.js        |  4 ++--
 .../schemas/tables/partitions/static/js/partition.js |  6 +++---
 .../databases/schemas/tables/static/js/table.js      | 12 ++++++------
 .../servers/databases/static/js/database.js          |  4 ++--
 .../servers/tablespaces/static/js/tablespace.js      |  4 ++--
 9 files changed, 19 insertions(+), 18 deletions(-)

#diff --git a/docs/en_US/release_notes_4_3.rst b/docs/en_US/release_notes_4_3.rst
#index 35e7cfc142..bc99f42e18 100644
#--- a/docs/en_US/release_notes_4_3.rst
#+++ b/docs/en_US/release_notes_4_3.rst
#@@ -19,6 +19,7 @@ Features
# Bug fixes
# *********
# 
#+| `Bug #3096 <https://redmine.postgresql.org/issues/3096>`_ - Ensure size stats are prettified on the statistics tab when the UI language is not English.
# | `Bug #3544 <https://redmine.postgresql.org/issues/3544>`_ - Make the Query Tool tab titles more concise and useful.
# | `Bug #3673 <https://redmine.postgresql.org/issues/3673>`_ - Modify the Download as CSV option to use the same connection as the Query Tool its running in so temporary tables etc. can be used.
# | `Bug #3873 <https://redmine.postgresql.org/issues/3873>`_ - Fix context sub-menu alignment on Safari.
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js
index f719e971a0..7ac17fb6b5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js
@@ -628,7 +628,7 @@ define('pgadmin.node.exclusion_constraint', [
       canDropCascade: true,
       hasDepends: true,
       hasStatistics: true,
-      statsPrettifyFields: ['Index size'],
+      statsPrettifyFields: [gettext('Index size')],
       Init: function() {
         /* Avoid multiple registration of menus */
         if (this.initialized)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js
index 86cec31e1c..93702224a8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js
@@ -25,7 +25,7 @@ define('pgadmin.node.primary_key', [
       hasSQL: true,
       hasDepends: true,
       hasStatistics: true,
-      statsPrettifyFields: ['Index size'],
+      statsPrettifyFields: [gettext('Index size')],
       parent_type: ['table','partition'],
       canDrop: true,
       canDropCascade: true,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js
index 93998d353c..022d16d176 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js
@@ -25,7 +25,7 @@ define('pgadmin.node.unique_constraint', [
       hasSQL: true,
       hasDepends: true,
       hasStatistics: true,
-      statsPrettifyFields: ['Index size'],
+      statsPrettifyFields: [gettext('Index size')],
       parent_type: ['table','partition'],
       canDrop: true,
       canDropCascade: true,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js
index 903ec9e459..bb36ff2768 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js
@@ -29,7 +29,7 @@ define('pgadmin.node.index', [
         dialogHelp: url_for('help.static', {'filename': 'index_dialog.html'}),
         columns: ['name', 'description'],
         hasStatistics: true,
-        statsPrettifyFields: ['Size', 'Index size'],
+        statsPrettifyFields: [gettext('Size'), gettext('Index size')],
         canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
         canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
       });
@@ -232,7 +232,7 @@ define('pgadmin.node.index', [
       hasSQL:  true,
       hasDepends: true,
       hasStatistics: true,
-      statsPrettifyFields: ['Size', 'Index size'],
+      statsPrettifyFields: [gettext('Size'), gettext('Index size')],
       Init: function() {
         /* Avoid mulitple registration of menus */
         if (this.initialized)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
index 5d1400317e..fb9bab7bb3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
@@ -42,9 +42,9 @@ function(
       hasSQL: true,
       hasDepends: true,
       hasStatistics: true,
-      statsPrettifyFields: ['Size', 'Indexes size', 'Table size',
-        'Toast table size', 'Tuple length',
-        'Dead tuple length', 'Free space'],
+      statsPrettifyFields: [gettext('Size'), gettext('Indexes size'), gettext('Table size'),
+        gettext('Toast table size'), gettext('Tuple length'),
+        gettext('Dead tuple length'), gettext('Free space')],
       sqlAlterHelp: 'sql-altertable.html',
       sqlCreateHelp: 'sql-createtable.html',
       dialogHelp: url_for('help.static', {'filename': 'table_dialog.html'}),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
index fe9de891e6..f564c466d5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
@@ -30,9 +30,9 @@ define('pgadmin.node.table', [
         type: 'coll-table',
         columns: ['name', 'relowner', 'is_partitioned', 'description'],
         hasStatistics: true,
-        statsPrettifyFields: ['Size', 'Indexes size', 'Table size',
-          'Toast table size', 'Tuple length',
-          'Dead tuple length', 'Free space'],
+        statsPrettifyFields: [gettext('Size'), gettext('Indexes size'), gettext('Table size'),
+          gettext('Toast table size'), gettext('Tuple length'),
+          gettext('Dead tuple length'), gettext('Free space')],
         canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
         canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
       });
@@ -46,9 +46,9 @@ define('pgadmin.node.table', [
       hasSQL: true,
       hasDepends: true,
       hasStatistics: true,
-      statsPrettifyFields: ['Size', 'Indexes size', 'Table size',
-        'Toast table size', 'Tuple length',
-        'Dead tuple length', 'Free space'],
+      statsPrettifyFields: [gettext('Size'), gettext('Indexes size'), gettext('Table size'),
+        gettext('Toast table size'), gettext('Tuple length'),
+        gettext('Dead tuple length'), gettext('Free space')],
       sqlAlterHelp: 'sql-altertable.html',
       sqlCreateHelp: 'sql-createtable.html',
       dialogHelp: url_for('help.static', {'filename': 'table_dialog.html'}),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
index a57ec66ae9..43fc95463f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
@@ -24,7 +24,7 @@ define('pgadmin.node.database', [
         hasStatistics: true,
         canDrop: true,
         canDropCascade: false,
-        statsPrettifyFields: ['Size', 'Size of temporary files'],
+        statsPrettifyFields: [gettext('Size'), gettext('Size of temporary files')],
       });
   }
 
@@ -38,7 +38,7 @@ define('pgadmin.node.database', [
       hasSQL: true,
       hasDepends: true,
       hasStatistics: true,
-      statsPrettifyFields: ['Size', 'Size of temporary files'],
+      statsPrettifyFields: [gettext('Size'), gettext('Size of temporary files')],
       canDrop: function(node) {
         return node.canDrop;
       },
diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js b/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js
index 457ad282a6..2215c0e67a 100644
--- a/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js
+++ b/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js
@@ -24,7 +24,7 @@ define('pgadmin.node.tablespace', [
         type: 'coll-tablespace',
         columns: ['name', 'spcuser', 'description'],
         hasStatistics: true,
-        statsPrettifyFields: ['Size'],
+        statsPrettifyFields: [gettext('Size')],
         canDrop: true,
         canDropCascade: false,
       });
@@ -42,7 +42,7 @@ define('pgadmin.node.tablespace', [
       canDrop: true,
       hasDepends: true,
       hasStatistics: true,
-      statsPrettifyFields: ['Size'],
+      statsPrettifyFields: [gettext('Size')],
       Init: function() {
         /* Avoid mulitple registration of menus */
         if (this.initialized)
