Обсуждение: Textdomains

Поиск
Список
Период
Сортировка

Textdomains

От
Magnus Hagander
Дата:
I've extracted this patch from Hiroshi Inoues patch about bug #4186. Per
his comment, "It also includes the changes to mbutils.c and elog.c which
fix recently introduced bug by the domain name change from "postgres" to
"postgres-8.4"."


Can somebody who actually knows how that works comment on it, please :-)

//Magnus
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 89163d6..a33c94e 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -308,7 +308,7 @@ errstart(int elevel, const char *filename, int lineno,
     edata->lineno = lineno;
     edata->funcname = funcname;
     /* the default text domain is the backend's */
-    edata->domain = domain ? domain : "postgres";
+    edata->domain = domain ? domain : PG_TEXTDOMAIN("postgres");
     /* Select default errcode based on elevel */
     if (elevel >= ERROR)
         edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c
index 3467c31..7725df4 100644
--- a/src/backend/utils/mb/mbutils.c
+++ b/src/backend/utils/mb/mbutils.c
@@ -873,7 +873,7 @@ SetDatabaseEncoding(int encoding)
      */
 #ifdef ENABLE_NLS
     if (encoding == PG_UTF8)
-        if (bind_textdomain_codeset("postgres", "UTF-8") == NULL)
+        if (bind_textdomain_codeset(textdomain(NULL), "UTF-8") == NULL)
             elog(LOG, "bind_textdomain_codeset failed");
 #endif
 }

Re: Textdomains

От
Peter Eisentraut
Дата:
Magnus Hagander wrote:
> I've extracted this patch from Hiroshi Inoues patch about bug #4186. Per
> his comment, "It also includes the changes to mbutils.c and elog.c which
> fix recently introduced bug by the domain name change from "postgres" to
> "postgres-8.4"."
> 
> 
> Can somebody who actually knows how that works comment on it, please :-)

It looks correct.

Note, however, that we now support translation of loaded modules, so you 
would really need to go around and call bind_textdomain_codeset() for 
all catalogs that pop up dynamically.  So that part might need some more 
work.


Re: Textdomains

От
Magnus Hagander
Дата:
Peter Eisentraut wrote:
> Magnus Hagander wrote:
>> I've extracted this patch from Hiroshi Inoues patch about bug #4186. Per
>> his comment, "It also includes the changes to mbutils.c and elog.c which
>> fix recently introduced bug by the domain name change from "postgres" to
>> "postgres-8.4"."
>>
>>
>> Can somebody who actually knows how that works comment on it, please :-)
> 
> It looks correct.

Ok, will apply.


> Note, however, that we now support translation of loaded modules, so you
> would really need to go around and call bind_textdomain_codeset() for
> all catalogs that pop up dynamically.  So that part might need some more
> work.

Well, this is a bugfix for existing stuff... Adding new stuff I'll
happily leave to someone who understands it better.. :-P

//Magnus