Fix set of NLS translation issues
authorMichael Paquier
Tue, 21 Aug 2018 06:18:00 +0000 (15:18 +0900)
committerMichael Paquier
Tue, 21 Aug 2018 06:18:00 +0000 (15:18 +0900)
While monitoring the code, a couple of issues related to string
translation has showed up:
- Some routines for auto-updatable views return an error string, which
sometimes missed the shot.  A comment regarding string translation is
added for each routine to help with future features.
- GSSAPI authentication missed two translations.
- vacuumdb handles non-translated strings.

Reported-by: Kyotaro Horiguchi
Author: Kyotaro Horiguchi
Reviewed-by: Michael Paquier, Tom Lane
Discussion: https://postgr.es/m/20180810.152131.31921918[email protected]
Backpatch-through: 9.3

src/backend/commands/tablecmds.c
src/backend/commands/view.c
src/backend/libpq/auth.c
src/backend/rewrite/rewriteHandler.c
src/bin/scripts/vacuumdb.c

index 1f7c732c02cbd53ff5d7875e964c9e95265909c7..9a82313e2f4a6fa5641fdb8640f7e4bd0c577569 100644 (file)
@@ -9553,7 +9553,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
                ereport(ERROR,
                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                         errmsg("WITH CHECK OPTION is supported only on automatically updatable views"),
-                        errhint("%s", view_updatable_error)));
+                        errhint("%s", _(view_updatable_error))));
        }
    }
 
index d582ecd79213189f47c2b57dc9cf33aee599f59c..7395eeea33f1f33254b2679932d21be735acb65d 100644 (file)
@@ -496,7 +496,7 @@ DefineView(ViewStmt *stmt, const char *queryString)
            ereport(ERROR,
                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                     errmsg("WITH CHECK OPTION is supported only on automatically updatable views"),
-                    errhint("%s", view_updatable_error)));
+                    errhint("%s", _(view_updatable_error))));
    }
 
    /*
index 9c77701785f32fff5d44a7d5394c9c3f01459b35..52b379c7f08fb0456250061895ce7f6345bf57a4 100644 (file)
@@ -771,6 +771,10 @@ static GSS_DLLIMP gss_OID GSS_C_NT_USER_NAME = &GSS_C_NT_USER_NAME_desc;
 #endif
 
 
+/*
+ * Generate an error for GSSAPI authentication.  The caller should apply
+ * _() to errmsg to make it translatable.
+ */
 static void
 pg_GSS_error(int severity, char *errmsg, OM_uint32 maj_stat, OM_uint32 min_stat)
 {
@@ -960,7 +964,7 @@ pg_GSS_recvauth(Port *port)
        {
            gss_delete_sec_context(&lmin_s, &port->gss->ctx, GSS_C_NO_BUFFER);
            pg_GSS_error(ERROR,
-                      gettext_noop("accepting GSS security context failed"),
+                        _("accepting GSS security context failed"),
                         maj_stat, min_stat);
        }
 
@@ -986,7 +990,7 @@ pg_GSS_recvauth(Port *port)
    maj_stat = gss_display_name(&min_stat, port->gss->name, &gbuf, NULL);
    if (maj_stat != GSS_S_COMPLETE)
        pg_GSS_error(ERROR,
-                    gettext_noop("retrieving GSS user name failed"),
+                    _("retrieving GSS user name failed"),
                     maj_stat, min_stat);
 
    /*
@@ -1050,6 +1054,11 @@ pg_GSS_recvauth(Port *port)
  *----------------------------------------------------------------
  */
 #ifdef ENABLE_SSPI
+
+/*
+ * Generate an error for SSPI authentication.  The caller should apply
+ * _() to errmsg to make it translatable.
+ */
 static void
 pg_SSPI_error(int severity, const char *errmsg, SECURITY_STATUS r)
 {
index b481ac50b60a1b56052a8792f3e98bd0c6a7d60a..677c4a4b84b04a883b71828e9e38260aea9bddd5 100644 (file)
@@ -2154,6 +2154,9 @@ view_has_instead_trigger(Relation view, CmdType event)
  * is auto-updatable. Returns NULL (if the column can be updated) or a message
  * string giving the reason that it cannot be.
  *
+ * The returned string has not been translated; if it is shown as an error
+ * message, the caller should apply _() to translate it.
+ *
  * Note that the checks performed here are local to this view. We do not check
  * whether the referenced column of the underlying base relation is updatable.
  */
@@ -2193,6 +2196,9 @@ view_col_is_auto_updatable(RangeTblRef *rtr, TargetEntry *tle)
  * view_query_is_auto_updatable - test whether the specified view definition
  * represents an auto-updatable view. Returns NULL (if the view can be updated)
  * or a message string giving the reason that it cannot be.
+
+ * The returned string has not been translated; if it is shown as an error
+ * message, the caller should apply _() to translate it.
  *
  * If check_cols is true, the view is required to have at least one updatable
  * column (necessary for INSERT/UPDATE). Otherwise the view's columns are not
@@ -2332,6 +2338,9 @@ view_query_is_auto_updatable(Query *viewquery, bool check_cols)
  * required columns can be updated) or a message string giving the reason that
  * they cannot be.
  *
+ * The returned string has not been translated; if it is shown as an error
+ * message, the caller should apply _() to translate it.
+ *
  * This should be used for INSERT/UPDATE to ensure that we don't attempt to
  * assign to any non-updatable columns.
  *
index 6ee773fbf215210e51856601567fd61576790525..20dd1d2e6017c66a50fbe5188f450df4ef922e37 100644 (file)
@@ -369,7 +369,7 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
    {
        if (stage != ANALYZE_NO_STAGE)
            printf(_("%s: processing database \"%s\": %s\n"),
-                  progname, PQdb(conn), stage_messages[stage]);
+                  progname, PQdb(conn), _(stage_messages[stage]));
        else
            printf(_("%s: vacuuming database \"%s\"\n"),
                   progname, PQdb(conn));