unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#46044] [PATCH] Improvements to handling po files
@ 2021-01-22 20:34 Julien Lepiller
  2021-01-28 14:58 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Lepiller @ 2021-01-22 20:34 UTC (permalink / raw)
  To: 46044

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

Hi Guix,

here are two patches to improve our handling of po files. Yesterday I
pushed again new po files that were broken, and I didn't notice. The
first patch ensure po files are normalized. The TP automatically
normalized po, but weblate doesn't, using the indent method instead.
This creates huge patches like yesterday. Instead, normalizing ensures
we only see relevant changes.

The second patch adds a check-po target to the Makefile that runs
msgfmt on every po file we have, to make sure they are at least
correct. That's not enough for manual translations, but that can be
spotted easily when running "make". This would have spotted the issues
I introduced yesterday.

[-- Attachment #2: 0001-Makefile.am-Normalize-downloaded-po-files.patch --]
[-- Type: text/x-patch, Size: 1091 bytes --]

From 42aa42512dba281f3d33e7883c922c0f5704bee4 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Fri, 22 Jan 2021 21:28:28 +0100
Subject: [PATCH 1/2] Makefile.am: Normalize downloaded po files.

* Makefile.am (make-download-po-rule): Normalize po files.
---
 Makefile.am | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 8a8133d669..d479032f83 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -990,7 +990,10 @@ download-po.$(1):
 	  if wget -nv -O "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp"		\
 	     "https://translate.fedoraproject.org/api/translations/guix/$(1)/$$$$lang/file/" ; \
 	  then									\
-	    mv "$(top_srcdir)/$(2)/$(3)$$$$lang.po"{.tmp,} ;			\
+	    msgfilter --no-wrap -i "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp"	\
+	      cat > "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp2" ;			\
+	    rm "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" ;			\
+	    mv "$(top_srcdir)/$(2)/$(3)$$$$lang.po"{.tmp2,} ;			\
 	  else									\
 	    rm "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" ;			\
 	  fi ;									\
-- 
2.30.0


[-- Attachment #3: 0002-Makefile.am-Add-check-po-rule.patch --]
[-- Type: text/x-patch, Size: 2154 bytes --]

From 8be36b2d651be108bc1e7fe7790f889dd19c679d Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Fri, 22 Jan 2021 21:24:23 +0100
Subject: [PATCH 2/2] Makefile.am: Add check-po rule.

* Makefile.am (make-check-po-rule): New definition.
Add top-level 'eval' and calls to 'make-check-po-rule' to generate
'check-po.DOMAIN' rules.
(check-po): New rule.
---
 Makefile.am | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index d479032f83..371fc42394 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1003,14 +1003,46 @@ download-po.$(1):
 
 endef
 
+# make-check-po-rule DOMAIN DIRECTORY [FILE-NAME-PREFIX]
+define make-check-po-rule
+
+check-po.$(1):
+	if [ -f "$(top_srcdir)/$(2)/LINGUAS" ]; then				\
+	  LINGUAS="`grep -v '^[[:blank:]]*#' < $(top_srcdir)/$(2)/LINGUAS`" ;	\
+	else									\
+	  LINGUAS="`(cd $(top_srcdir)/$(2);					\
+	    for i in *.po; do echo $$$$i; done) | cut -d . -f 2`" ;		\
+	fi ;									\
+	for lang in $$$$LINGUAS; do						\
+	  if [ -f "$(top_srcdir)/$(2)/$(3)$$$$lang.po" ]; \
+	  then									\
+	    if ! msgfmt -c "$(top_srcdir)/$(2)/$(3)$$$$lang.po" ; \
+		then \
+		  exit 1 ; \
+	    fi ; \
+	  fi ;									\
+	done
+
+.PHONY: check-po.$(1)
+
+endef
+
 $(eval $(call make-download-po-rule,documentation-cookbook,po/doc,guix-cookbook.))
 $(eval $(call make-download-po-rule,documentation-manual,po/doc,guix-manual.))
 $(eval $(call make-download-po-rule,guix,po/guix))
 $(eval $(call make-download-po-rule,packages,po/packages))
 
+$(eval $(call make-check-po-rule,documentation-cookbook,po/doc,guix-cookbook.))
+$(eval $(call make-check-po-rule,documentation-manual,po/doc,guix-manual.))
+$(eval $(call make-check-po-rule,guix,po/guix))
+$(eval $(call make-check-po-rule,packages,po/packages))
+
 download-po: $(foreach domain,guix packages documentation-manual documentation-cookbook,download-po.$(domain))
 .PHONY: download-po
 
+check-po: $(foreach domain,guix packages documentation-manual documentation-cookbook,check-po.$(domain))
+.PHONY: check-po
+
 ## -------------- ##
 ## Silent rules.  ##
 ## -------------- ##
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#46044] [PATCH] Improvements to handling po files
  2021-01-22 20:34 [bug#46044] [PATCH] Improvements to handling po files Julien Lepiller
@ 2021-01-28 14:58 ` Ludovic Courtès
  2021-01-28 16:23   ` bug#46044: " Julien Lepiller
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2021-01-28 14:58 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: 46044

Hi!

Julien Lepiller <julien@lepiller.eu> skribis:

> here are two patches to improve our handling of po files. Yesterday I
> pushed again new po files that were broken, and I didn't notice. The
> first patch ensure po files are normalized. The TP automatically
> normalized po, but weblate doesn't, using the indent method instead.
> This creates huge patches like yesterday. Instead, normalizing ensures
> we only see relevant changes.

Makes sense.

> The second patch adds a check-po target to the Makefile that runs
> msgfmt on every po file we have, to make sure they are at least
> correct. That's not enough for manual translations, but that can be
> spotted easily when running "make". This would have spotted the issues
> I introduced yesterday.

Yes, or running “make as-derivation” (sometimes just “make” isn’t enough
to catch issues it seems, not sure why.)

>>From 42aa42512dba281f3d33e7883c922c0f5704bee4 Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> Date: Fri, 22 Jan 2021 21:28:28 +0100
> Subject: [PATCH 1/2] Makefile.am: Normalize downloaded po files.
>
> * Makefile.am (make-download-po-rule): Normalize po files.

OK!

>>From 8be36b2d651be108bc1e7fe7790f889dd19c679d Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> Date: Fri, 22 Jan 2021 21:24:23 +0100
> Subject: [PATCH 2/2] Makefile.am: Add check-po rule.
>
> * Makefile.am (make-check-po-rule): New definition.
> Add top-level 'eval' and calls to 'make-check-po-rule' to generate
> 'check-po.DOMAIN' rules.
> (check-po): New rule.

[...]

> +# make-check-po-rule DOMAIN DIRECTORY [FILE-NAME-PREFIX]
> +define make-check-po-rule

Could you add a line or two above the definition explaining what it
does?

> +check-po.$(1):
> +	if [ -f "$(top_srcdir)/$(2)/LINGUAS" ]; then				\
> +	  LINGUAS="`grep -v '^[[:blank:]]*#' < $(top_srcdir)/$(2)/LINGUAS`" ;	\
> +	else									\
> +	  LINGUAS="`(cd $(top_srcdir)/$(2);					\
> +	    for i in *.po; do echo $$$$i; done) | cut -d . -f 2`" ;		\
> +	fi ;									\
> +	for lang in $$$$LINGUAS; do						\
> +	  if [ -f "$(top_srcdir)/$(2)/$(3)$$$$lang.po" ]; \
> +	  then									\
> +	    if ! msgfmt -c "$(top_srcdir)/$(2)/$(3)$$$$lang.po" ; \
> +		then \
> +		  exit 1 ; \
> +	    fi ; \
> +	  fi ;									\

Would be great if you could align backslashes.  :-)

Otherwise LGTM, thanks!

Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#46044: [PATCH] Improvements to handling po files
  2021-01-28 14:58 ` Ludovic Courtès
@ 2021-01-28 16:23   ` Julien Lepiller
  0 siblings, 0 replies; 3+ messages in thread
From: Julien Lepiller @ 2021-01-28 16:23 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 46044-done

Pushed as c891e7c828d21530f110c04dabe70515447c7d67 and
b91165460e71f427c30f22ace02a5d775ecea23d, thank you!




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-28 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 20:34 [bug#46044] [PATCH] Improvements to handling po files Julien Lepiller
2021-01-28 14:58 ` Ludovic Courtès
2021-01-28 16:23   ` bug#46044: " Julien Lepiller

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).