Separate package description translations from string translations.

* po/packages/LINGUAS, po/packages/Makevars, po/packages/POTFILES.in:
  New files.
* po/guix/Makevars (DOMAIN): Change to "guix".
  (XGETTEXT_OPTIONS): Remove "--keyword=synopsis --keyword=description".
* po/guix/POTFILES.in: Remove gnu/packages/*.scm.
* configure.ac: Change to gettext 0.18.3.  Produce
  po/packages/Makefile.in.
* Makefile.am (SUBDIRS): Add po/packages.
* guix/ui.scm (%package-text-domain): New variable.
  (P_): New procedure.
  (package->recutils): Use 'P_' instead of '_'.
* guix/scripts/package.scm (find-packages-by-description): Use 'P_'
  instead of 'gettext'.
This commit is contained in:
Ludovic Courtès 2014-06-13 17:30:40 +02:00
parent ef1a9bb7d6
commit ee76417972
10 changed files with 64 additions and 15 deletions

17
.gitignore vendored
View File

@ -39,6 +39,23 @@ config.cache
/po/guix/guix.pot /po/guix/guix.pot
/po/guix/*.mo /po/guix/*.mo
/po/guix/*.gmo /po/guix/*.gmo
/po/packages/ChangeLog
/po/packages/Makefile.in.in
/po/packages/Makevars.template
/po/packages/POTFILES
/po/packages/Rules-quot
/po/packages/boldquot.sed
/po/packages/en@boldquot.*
/po/packages/en@quot.*
/po/packages/insert-header.sin
/po/packages/*.insert-header
/po/packages/quot.sed
/po/packages/remove-potcdate.sed
/po/packages/remove-potcdate.sin
/po/packages/stamp-po
/po/packages/guix-packages.pot
/po/packages/*.mo
/po/packages/*.gmo
/tests/*.trs /tests/*.trs
/INSTALL /INSTALL
/m4/* /m4/*

View File

@ -246,7 +246,7 @@ SUFFIXES = .go
guix_install_go_files = install-nobase_nodist_guilemoduleDATA guix_install_go_files = install-nobase_nodist_guilemoduleDATA
$(guix_install_go_files): install-nobase_dist_guilemoduleDATA $(guix_install_go_files): install-nobase_dist_guilemoduleDATA
SUBDIRS = po/guix SUBDIRS = po/guix po/packages
include doc.am include doc.am

View File

@ -16,7 +16,7 @@ dnl For the C++ code. This must be used early.
AC_USE_SYSTEM_EXTENSIONS AC_USE_SYSTEM_EXTENSIONS
AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.18.1]) AM_GNU_GETTEXT_VERSION([0.18.3])
guilemoduledir="${datarootdir}/guile/site/2.0" guilemoduledir="${datarootdir}/guile/site/2.0"
AC_SUBST([guilemoduledir]) AC_SUBST([guilemoduledir])
@ -167,6 +167,7 @@ AM_MISSING_PROG([DOT], [dot])
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
po/guix/Makefile.in po/guix/Makefile.in
po/packages/Makefile.in
guix/config.scm]) guix/config.scm])
AC_CONFIG_FILES([scripts/guix], [chmod +x scripts/guix]) AC_CONFIG_FILES([scripts/guix], [chmod +x scripts/guix])

View File

@ -228,11 +228,11 @@ RX."
(define matches? (define matches?
(cut regexp-exec rx <>)) (cut regexp-exec rx <>))
(if (or (matches? (gettext (package-name package))) (if (or (matches? (package-name package))
(and=> (package-synopsis package) (and=> (package-synopsis package)
(compose matches? gettext)) (compose matches? P_))
(and=> (package-description package) (and=> (package-description package)
(compose matches? gettext))) (compose matches? P_)))
(cons package result) (cons package result)
result)) result))
'()) '())

View File

@ -39,6 +39,7 @@
#:use-module (ice-9 regex) #:use-module (ice-9 regex)
#:export (_ #:export (_
N_ N_
P_
leave leave
show-version-and-exit show-version-and-exit
show-bug-report-information show-bug-report-information
@ -72,10 +73,16 @@
;;; Code: ;;; Code:
(define %gettext-domain (define %gettext-domain
;; Text domain for strings used in the tools.
"guix") "guix")
(define %package-text-domain
;; Text domain for package synopses and descriptions.
"guix-packages")
(define _ (cut gettext <> %gettext-domain)) (define _ (cut gettext <> %gettext-domain))
(define N_ (cut ngettext <> <> <> %gettext-domain)) (define N_ (cut ngettext <> <> <> %gettext-domain))
(define P_ (cut gettext <> %package-text-domain))
(define-syntax-rule (define-diagnostic name prefix) (define-syntax-rule (define-diagnostic name prefix)
"Create a diagnostic macro (i.e., NAME), which will prepend PREFIX to all "Create a diagnostic macro (i.e., NAME), which will prepend PREFIX to all
@ -431,7 +438,7 @@ followed by \"+ \", which makes for a valid multi-line field value in the
"Write to PORT a `recutils' record of package P, arranging to fit within "Write to PORT a `recutils' record of package P, arranging to fit within
WIDTH columns." WIDTH columns."
(define (description->recutils str) (define (description->recutils str)
(let ((str (_ str))) (let ((str (P_ str)))
(string->recutils (string->recutils
(fill-paragraph str width (fill-paragraph str width
(string-length "description: "))))) (string-length "description: ")))))
@ -460,7 +467,7 @@ WIDTH columns."
(string-map (match-lambda (string-map (match-lambda
(#\newline #\space) (#\newline #\space)
(chr chr)) (chr chr))
(or (and=> (package-synopsis p) _) (or (and=> (package-synopsis p) P_)
""))) "")))
(format port "description: ~a~%" (format port "description: ~a~%"
(and=> (package-description p) description->recutils)) (and=> (package-description p) description->recutils))

View File

@ -1,17 +1,15 @@
# Makefile variables for PO directory in any package using GNU gettext. # Makefile variables for PO directory in any package using GNU gettext.
DOMAIN = $(PACKAGE) DOMAIN = guix
subdir = po/guix subdir = po/guix
top_builddir = ../.. top_builddir = ../..
# These options get passed to xgettext. We want to catch standard # These options get passed to xgettext. We want to catch standard
# gettext uses, package synopses and descriptions, and SRFI-35 error # gettext uses, and SRFI-35 error condition messages.
# condition messages.
XGETTEXT_OPTIONS = \ XGETTEXT_OPTIONS = \
--language=Scheme --from-code=UTF-8 \ --language=Scheme --from-code=UTF-8 \
--keyword=_ --keyword=N_ \ --keyword=_ --keyword=N_ \
--keyword=synopsis --keyword=description \
--keyword=message --keyword=message
COPYRIGHT_HOLDER = Ludovic Courtès COPYRIGHT_HOLDER = Ludovic Courtès

View File

@ -1,9 +1,6 @@
# List of source files which contain translatable strings. # List of source files which contain translatable strings.
# This should be source files of the various tools, and not package modules.
gnu/packages.scm gnu/packages.scm
gnu/packages/base.scm
gnu/packages/guile.scm
gnu/packages/lout.scm
gnu/packages/recutils.scm
guix/scripts/build.scm guix/scripts/build.scm
guix/scripts/download.scm guix/scripts/download.scm
guix/scripts/package.scm guix/scripts/package.scm

4
po/packages/LINGUAS Normal file
View File

@ -0,0 +1,4 @@
# Set of available languages.
en@boldquot
en@quot

19
po/packages/Makevars Normal file
View File

@ -0,0 +1,19 @@
# Makefile variables for PO directory in any package using GNU gettext.
# This domain contains only translations of package synopses and descriptions.
DOMAIN = guix-packages
subdir = po/packages
top_builddir = ../..
# These options get passed to xgettext. We want to catch exclusively package
# synopses and descriptions.
XGETTEXT_OPTIONS = \
--language=Scheme --from-code=UTF-8 \
--keyword=synopsis --keyword=description
COPYRIGHT_HOLDER = Ludovic Courtès
MSGID_BUGS_ADDRESS = ludo@gnu.org
EXTRA_LOCALE_CATEGORIES =

6
po/packages/POTFILES.in Normal file
View File

@ -0,0 +1,6 @@
# List of source files which contain translatable strings. These should be
# only package modules. Strings of the tools are in 'po/guix'.
gnu/packages/base.scm
gnu/packages/guile.scm
gnu/packages/lout.scm
gnu/packages/recutils.scm