threads / patch / 10527

patch, 3 partspo2msg fixes

Subject: [GIT-GUI PATCH 0/3] po2msg fixes

## tl;dr

7 messages between Oct 30, 2007 and Oct 31, 2007. Diffs are folded; open one to read it.

replies: 6people: 3as markdown or json

Johannes Schindelin· Oct 30, 2007, 11:24 UTC · re: Johannes Schindelin · lore

[GIT-GUI PATCH 1/3] po2msg: ignore entries marked with "fuzzy"

As Christian Stimming pointed out, entries which are "fuzzy" need to be checked by human translators, and cannot be used.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 po/po2msg.sh |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
Show changes to po/po2msg.sh +11 −2
diff --git a/po/po2msg.sh b/po/po2msg.sh
index da0765d..48a2669 100644
--- a/po/po2msg.sh
+++ b/po/po2msg.sh
@@ -48,12 +48,16 @@ for {set i 1} {$i < $argc} {incr i} {
 }
 
 proc flush_msg {} {
-	global msgid msgstr mode lang out
+	global msgid msgstr mode lang out fuzzy
 
 	if {![info exists msgid] || $mode == ""} {
 		return
 	}
 	set mode ""
+	if {$fuzzy == 1} {
+		set fuzzy 0
+		return
+	}
 
 	if {$msgid == ""} {
 		set prefix "set ::msgcat::header"
@@ -64,6 +68,7 @@ proc flush_msg {} {
 	puts $out "$prefix \"[u2a $msgstr]\""
 }
 
+set fuzzy 0
 foreach file $files {
 	regsub "^.*/\(\[^/\]*\)\.po$" $file "$output_directory\\1.msg" outfile
 	set in [open $file "r"]
@@ -73,7 +78,11 @@ foreach file $files {
 	set mode ""
 	while {[gets $in line] >= 0} {
 		if {[regexp "^#" $line]} {
-			flush_msg
+			if {[regexp ", fuzzy" $line]} {
+				set fuzzy 1
+			} else {
+				flush_msg
+			}
 			continue
 		} elseif {[regexp "^msgid \"(.*)\"$" $line dummy match]} {
 			flush_msg
-- 
1.5.3.4.1423.g7c7a7
Johannes Schindelin· Oct 30, 2007, 11:24 UTC · re: Johannes Schindelin · lore

[GIT-GUI PATCH 2/3] po2msg: ignore untranslated messages

Do not generate translations when the translated message is empty.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 po/po2msg.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Show changes to po/po2msg.sh +3 −0
diff --git a/po/po2msg.sh b/po/po2msg.sh
index 48a2669..91d420b 100644
--- a/po/po2msg.sh
+++ b/po/po2msg.sh
@@ -62,6 +62,9 @@ proc flush_msg {} {
 	if {$msgid == ""} {
 		set prefix "set ::msgcat::header"
 	} else {
+		if {$msgstr == ""} {
+			return
+		}
 		set prefix "::msgcat::mcset $lang \"[u2a $msgid]\""
 	}
 
-- 
1.5.3.4.1423.g7c7a7
Junio C Hamano· Oct 30, 2007, 19:27 UTC · re: Johannes Schindelin · lore

Re: [GIT-GUI PATCH 2/3] po2msg: ignore untranslated messages

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 20 quoted lines
> Do not generate translations when the translated message is empty.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  po/po2msg.sh |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/po/po2msg.sh b/po/po2msg.sh
> index 48a2669..91d420b 100644
> --- a/po/po2msg.sh
> +++ b/po/po2msg.sh
> @@ -62,6 +62,9 @@ proc flush_msg {} {
>  	if {$msgid == ""} {
>  		set prefix "set ::msgcat::header"
>  	} else {
> +		if {$msgstr == ""} {
> +			return
> +		}
>  		set prefix "::msgcat::mcset $lang \"[u2a $msgid]\""
>  	}
Is this change to fix some real issues?

Sometimes it is handy to be able to translate a non-empty string into an empty one in one target language.

Christian Stimming· Oct 30, 2007, 20:44 UTC · re: Junio C Hamano · lore

Re: [GIT-GUI PATCH 2/3] po2msg: ignore untranslated messages

Am Dienstag, 30. Oktober 2007 20:27 schrieb Junio C Hamano:
Show 22 quoted lines
> > Do not generate translations when the translated message is empty.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> >  po/po2msg.sh |    3 +++
> >  1 files changed, 3 insertions(+), 0 deletions(-)
> >
> > diff --git a/po/po2msg.sh b/po/po2msg.sh
> > index 48a2669..91d420b 100644
> > --- a/po/po2msg.sh
> > +++ b/po/po2msg.sh
> > @@ -62,6 +62,9 @@ proc flush_msg {} {
> >  	if {$msgid == ""} {
> >  		set prefix "set ::msgcat::header"
> >  	} else {
> > +		if {$msgstr == ""} {
> > +			return
> > +		}
> >  		set prefix "::msgcat::mcset $lang \"[u2a $msgid]\""
> >  	}
>
> Is this change to fix some real issues?
I don't think to - it just makes the resulting foo.msg file smaller.
> Sometimes it is handy to be able to translate a non-empty string
> into an empty one in one target language.

Err... no, this is not the case. The semantics of an msgstr == "" is identical to saying "No translation exists to this source string". Nothing more, nothing less. You can't specify a translation that should map a given string to an empty string. (If you make up a case when that would make some sense, usually the source string is rather weirdly chosen and should be reworded.)

Christian
Johannes Schindelin· Oct 31, 2007, 02:23 UTC · re: Junio C Hamano · lore

Re: [GIT-GUI PATCH 2/3] po2msg: ignore untranslated messages

Hi,
On Tue, 30 Oct 2007, Junio C Hamano wrote:
Show 24 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Do not generate translations when the translated message is empty.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> >  po/po2msg.sh |    3 +++
> >  1 files changed, 3 insertions(+), 0 deletions(-)
> >
> > diff --git a/po/po2msg.sh b/po/po2msg.sh
> > index 48a2669..91d420b 100644
> > --- a/po/po2msg.sh
> > +++ b/po/po2msg.sh
> > @@ -62,6 +62,9 @@ proc flush_msg {} {
> >  	if {$msgid == ""} {
> >  		set prefix "set ::msgcat::header"
> >  	} else {
> > +		if {$msgstr == ""} {
> > +			return
> > +		}
> >  		set prefix "::msgcat::mcset $lang \"[u2a $msgid]\""
> >  	}
> 
> Is this change to fix some real issues?

Yes. I compared the output of po2msg.sh with that of msgfmt, and only with this change (and 1/3) they came up identical.

Ciao, Dscho

Johannes Schindelin· Oct 30, 2007, 11:25 UTC · re: Johannes Schindelin · lore

[GIT-GUI PATCH 3/3] po2msg: actually output statistics

The "--statistics" option was ignored so far; no longer. Now we have a message similar to that of msgfmt. (Untranslated, though ;-)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 po/po2msg.sh |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)
Show changes to po/po2msg.sh +21 −2
diff --git a/po/po2msg.sh b/po/po2msg.sh
index 91d420b..78e49cc 100644
--- a/po/po2msg.sh
+++ b/po/po2msg.sh
@@ -26,11 +26,17 @@ proc u2a {s} {
 set output_directory "."
 set lang "dummy"
 set files [list]
+set show_statistics 0
 
 # parse options
-for {set i 1} {$i < $argc} {incr i} {
+for {set i 0} {$i < $argc} {incr i} {
 	set arg [lindex $argv $i]
-	if {$arg == "--statistics" || $arg == "--tcl"} {
+	if {$arg == "--statistics"} {
+		incr show_statistics
+		continue
+	}
+	if {$arg == "--tcl"} {
+		# we know
 		continue
 	}
 	if {$arg == "-l"} {
@@ -49,12 +55,14 @@ for {set i 1} {$i < $argc} {incr i} {
 
 proc flush_msg {} {
 	global msgid msgstr mode lang out fuzzy
+	global translated_count fuzzy_count not_translated_count
 
 	if {![info exists msgid] || $mode == ""} {
 		return
 	}
 	set mode ""
 	if {$fuzzy == 1} {
+		incr fuzzy_count
 		set fuzzy 0
 		return
 	}
@@ -63,15 +71,20 @@ proc flush_msg {} {
 		set prefix "set ::msgcat::header"
 	} else {
 		if {$msgstr == ""} {
+			incr not_translated_count
 			return
 		}
 		set prefix "::msgcat::mcset $lang \"[u2a $msgid]\""
+		incr translated_count
 	}
 
 	puts $out "$prefix \"[u2a $msgstr]\""
 }
 
 set fuzzy 0
+set translated_count 0
+set fuzzy_count 0
+set not_translated_count 0
 foreach file $files {
 	regsub "^.*/\(\[^/\]*\)\.po$" $file "$output_directory\\1.msg" outfile
 	set in [open $file "r"]
@@ -113,3 +126,9 @@ foreach file $files {
 	close $out
 }
 
+puts $show_statistics
+if {$show_statistics} {
+	puts [concat "$translated_count translated messages, " \
+		"$fuzzy_count fuzzy ones, " \
+		"$not_translated_count untranslated ones."]
+}
-- 
1.5.3.4.1423.g7c7a7

← back to recent threads