Re: [PATCH v2 03/23] archive-zip.c: mark more strings for translation

2018-07-19 Thread Junio C Hamano
Duy Nguyen  writes:

> It turns out gettext is smart! I got this in git.pot
>
> msgid "timestamp too large for this system: %"

OK.


Re: [PATCH v2 03/23] archive-zip.c: mark more strings for translation

2018-07-19 Thread Duy Nguyen
On Thu, Jul 19, 2018 at 8:26 PM Junio C Hamano  wrote:
> > @@ -601,7 +601,7 @@ static void dos_time(timestamp_t *timestamp, int 
> > *dos_date, int *dos_time)
> >   struct tm *t;
> >
> >   if (date_overflows(*timestamp))
> > - die("timestamp too large for this system: %"PRItime,
> > + die(_("timestamp too large for this system: %"PRItime),
> >   *timestamp);
>
> I suspect that this won't do the right "cross-platform" thing.  For
> built-in PRItype formats gettext tool knows about, *.po files let
> translators translate original with "%" into localized text
> with the same "%" left, and the runtime does the right
> thing, but for a custom format like PRItime there is no such
> support.
>

It turns out gettext is smart! I got this in git.pot

msgid "timestamp too large for this system: %"

Your second half about the runtime does cause cross platform problems,
luckily PRItime is always defined as PRIuMAX for all platforms, so
gettext should be able to do the right thing.

Besides, PRItime has already been wrapped in _() and Q_() in many
places. If people have not screamed now, they probably don't care
about l10n on that platform.
-- 
Duy


Re: [PATCH v2 03/23] archive-zip.c: mark more strings for translation

2018-07-19 Thread Junio C Hamano
Nguyễn Thái Ngọc Duy   writes:

> - return error("path too long (%d chars, SHA1: %s): %s",
> + return error(_("path too long (%d chars, SHA1: %s): %s"),
> - return error("unsupported file mode: 0%o (SHA1: %s)", mode,
> + return error(_("unsupported file mode: 0%o (SHA1: %s)"), mode,

The same #leftoverbits comment as 02/23 applies here.

> @@ -601,7 +601,7 @@ static void dos_time(timestamp_t *timestamp, int 
> *dos_date, int *dos_time)
>   struct tm *t;
>  
>   if (date_overflows(*timestamp))
> - die("timestamp too large for this system: %"PRItime,
> + die(_("timestamp too large for this system: %"PRItime),
>   *timestamp);

I suspect that this won't do the right "cross-platform" thing.  For
built-in PRItype formats gettext tool knows about, *.po files let
translators translate original with "%" into localized text
with the same "%" left, and the runtime does the right
thing, but for a custom format like PRItime there is no such
support.



[PATCH v2 03/23] archive-zip.c: mark more strings for translation

2018-07-18 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 archive-zip.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/archive-zip.c b/archive-zip.c
index 48d843489c..7ad46d8854 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -309,11 +309,11 @@ static int write_zip_entry(struct archiver_args *args,
if (is_utf8(path))
flags |= ZIP_UTF8;
else
-   warning("path is not valid UTF-8: %s", path);
+   warning(_("path is not valid UTF-8: %s"), path);
}
 
if (pathlen > 0x) {
-   return error("path too long (%d chars, SHA1: %s): %s",
+   return error(_("path too long (%d chars, SHA1: %s): %s"),
(int)pathlen, oid_to_hex(oid), path);
}
 
@@ -340,7 +340,7 @@ static int write_zip_entry(struct archiver_args *args,
size > big_file_threshold) {
stream = open_istream(oid, , , NULL);
if (!stream)
-   return error("cannot stream blob %s",
+   return error(_("cannot stream blob %s"),
 oid_to_hex(oid));
flags |= ZIP_STREAM;
out = buffer = NULL;
@@ -348,7 +348,7 @@ static int write_zip_entry(struct archiver_args *args,
buffer = object_file_to_archive(args, path, oid, mode,
, );
if (!buffer)
-   return error("cannot read %s",
+   return error(_("cannot read %s"),
 oid_to_hex(oid));
crc = crc32(crc, buffer, size);
is_binary = entry_is_binary(path_without_prefix,
@@ -357,7 +357,7 @@ static int write_zip_entry(struct archiver_args *args,
}
compressed_size = (method == 0) ? size : 0;
} else {
-   return error("unsupported file mode: 0%o (SHA1: %s)", mode,
+   return error(_("unsupported file mode: 0%o (SHA1: %s)"), mode,
oid_to_hex(oid));
}
 
@@ -466,7 +466,7 @@ static int write_zip_entry(struct archiver_args *args,
zstream.avail_in = readlen;
result = git_deflate(, 0);
if (result != Z_OK)
-   die("deflate error (%d)", result);
+   die(_("deflate error (%d)"), result);
out_len = zstream.next_out - compressed;
 
if (out_len > 0) {
@@ -601,7 +601,7 @@ static void dos_time(timestamp_t *timestamp, int *dos_date, 
int *dos_time)
struct tm *t;
 
if (date_overflows(*timestamp))
-   die("timestamp too large for this system: %"PRItime,
+   die(_("timestamp too large for this system: %"PRItime),
*timestamp);
time = (time_t)*timestamp;
t = localtime();
-- 
2.18.0.rc2.476.g39500d3211



[PATCH v2 03/23] archive-zip.c: mark more strings for translation

2018-06-03 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 archive-zip.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/archive-zip.c b/archive-zip.c
index 48d843489c..7ad46d8854 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -309,11 +309,11 @@ static int write_zip_entry(struct archiver_args *args,
if (is_utf8(path))
flags |= ZIP_UTF8;
else
-   warning("path is not valid UTF-8: %s", path);
+   warning(_("path is not valid UTF-8: %s"), path);
}
 
if (pathlen > 0x) {
-   return error("path too long (%d chars, SHA1: %s): %s",
+   return error(_("path too long (%d chars, SHA1: %s): %s"),
(int)pathlen, oid_to_hex(oid), path);
}
 
@@ -340,7 +340,7 @@ static int write_zip_entry(struct archiver_args *args,
size > big_file_threshold) {
stream = open_istream(oid, , , NULL);
if (!stream)
-   return error("cannot stream blob %s",
+   return error(_("cannot stream blob %s"),
 oid_to_hex(oid));
flags |= ZIP_STREAM;
out = buffer = NULL;
@@ -348,7 +348,7 @@ static int write_zip_entry(struct archiver_args *args,
buffer = object_file_to_archive(args, path, oid, mode,
, );
if (!buffer)
-   return error("cannot read %s",
+   return error(_("cannot read %s"),
 oid_to_hex(oid));
crc = crc32(crc, buffer, size);
is_binary = entry_is_binary(path_without_prefix,
@@ -357,7 +357,7 @@ static int write_zip_entry(struct archiver_args *args,
}
compressed_size = (method == 0) ? size : 0;
} else {
-   return error("unsupported file mode: 0%o (SHA1: %s)", mode,
+   return error(_("unsupported file mode: 0%o (SHA1: %s)"), mode,
oid_to_hex(oid));
}
 
@@ -466,7 +466,7 @@ static int write_zip_entry(struct archiver_args *args,
zstream.avail_in = readlen;
result = git_deflate(, 0);
if (result != Z_OK)
-   die("deflate error (%d)", result);
+   die(_("deflate error (%d)"), result);
out_len = zstream.next_out - compressed;
 
if (out_len > 0) {
@@ -601,7 +601,7 @@ static void dos_time(timestamp_t *timestamp, int *dos_date, 
int *dos_time)
struct tm *t;
 
if (date_overflows(*timestamp))
-   die("timestamp too large for this system: %"PRItime,
+   die(_("timestamp too large for this system: %"PRItime),
*timestamp);
time = (time_t)*timestamp;
t = localtime();
-- 
2.18.0.rc0.333.g22e6ee6cdf