From: | Ildus Kurbangaliev <i(dot)kurbangaliev(at)postgrespro(dot)ru> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Translatable strings with formatting of 64bit values |
Date: | 2018-04-25 11:13:24 |
Message-ID: | 20180425141324.111ec08e@wp.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
apparently gettext can't properly identify strings when 64bit values
formatted with macros like INT64_FORMAT and UINT64_FORMAT. I did
some research and found out that gettext can work with PRId64 and
PRIu64. My suggestion is to use these macro for such strings.
The problem is here that PRIu64 is not accessible on all platforms but
this is easy solvable if it will be specified using INT64_MODIFIER in
c.h.
I attached a sample patch that adds PRIu64, PRId64 and makes few strings
translatable.
Using PRId64 will simplify the code like this:
char bufv[100],
bufm[100],
bufx[100];
snprintf(bufv, sizeof(bufv), INT64_FORMAT, next);
snprintf(bufm, sizeof(bufm), INT64_FORMAT, minv);
snprintf(bufx, sizeof(bufx), INT64_FORMAT, maxv);
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("setval: value %s is out of
bounds for sequence \"%s\" (%s..%s)", bufv,
RelationGetRelationName(seqrel), bufm, bufx)));
To:
if ((next < minv) || (next > maxv))
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("setval: value %s is out of
bounds for sequence \"%" PRId64 "\" (%" PRId64 "..%" PRId64
")", next, RelationGetRelationName(seqrel), minv, maxv)));
In result:
#: commands/sequence.c:944
#, fuzzy, c-format
#| msgid "setval: value %s is out of bounds for sequence
\"%s\" (%s..%s)"
msgid "setval: value %s is out of bounds for sequence
\"%<PRId64>\" (%<PRId64>..%<PRId64>)"
msgstr "setval передано значение %s вне пределов последовательности
\"%s\" (%s..%s)"
And still this string will be translatable. I found a bunch of places
when PRIx64 macros can simplify the code.
--
---
Ildus Kurbangaliev
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
Attachment | Content-Type | Size |
---|---|---|
prix64.patch | text/x-patch | 1.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2018-04-25 11:35:24 | Re: lazy detoasting |
Previous Message | Stas Kelvich | 2018-04-25 10:22:41 | unused_oids script is broken with bsd sed |