* [bug#46114] [PATCH] website: Localize package list.
@ 2021-01-26 16:56 Julien Lepiller
2021-01-26 21:29 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: Julien Lepiller @ 2021-01-26 16:56 UTC (permalink / raw)
To: 46114
[-- Attachment #1: Type: text/plain, Size: 812 bytes --]
Hi Guix!
This patch lets us localize package synopsis and description in package
lists. This is not super useful, because our guix-packages domain is
almost untranslated, for every language, but I think it's better than
nothing.
Locally, you can simply copy an existing guix-packages.mo (on the Guix
System,
/run/current-system/profile/share/locale/de/LC_MESSAGES/guix-packages.mo
for the German translation) to the local locale directory
(de/LC_MESSAGES/guix-packages.mo), in the same way we do for the
guix-website domain.
I also modified .guix.scm so the website can be generated with
localized packages. I used the latest guix package from the current
guix, because latest-guix (defined in .guix.scm) does not have any
locale information in it (mo or po). Any idea to get the latest
translations instead?
[-- Attachment #2: 0001-website-Update-announce-online-Guix-days.patch --]
[-- Type: text/x-patch, Size: 1488 bytes --]
From 87a0bb44fb28ff3a7e2237b2b559c1edbcbc6913 Mon Sep 17 00:00:00 2001
From: zimoun <zimon.toutoune@gmail.com>
Date: Tue, 3 Nov 2020 10:05:50 +0100
Subject: [PATCH] website: Update announce online Guix days.
* website/posts/online-guix-day-announce-1.md: Fix email, update the deadline.
---
website/posts/online-guix-day-announce-1.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/website/posts/online-guix-day-announce-1.md b/website/posts/online-guix-day-announce-1.md
index 686c01b..b4ca308 100644
--- a/website/posts/online-guix-day-announce-1.md
+++ b/website/posts/online-guix-day-announce-1.md
@@ -11,7 +11,7 @@ and will be held entirely online. Want to speak? Submit your proposal!
Important dates:
-1. **November 6th**: Deadline for talks proposal.
+1. **November 10th**: Deadline for talks proposal.
1. **November 14th**: Deadline for releasing your pre-recorded talks.
1. **November 16th**: Release of the schedule.
1. **November 22nd**: Conference day!
@@ -27,9 +27,9 @@ The agenda of the day is:
*There will be no presentation on the 22nd!* And **no registration fee**.
-##### Until November 6th: talks proposal
+##### Until November 10th: talks proposal
-Propose your talks by sending them to `guix-devel@gnu.org`. Feel free to drop
+Propose your talks by sending them to `guix-days@gnu.org`. Feel free to drop
in `#guix` on irc.freenode.net to discuss what you would like to talk about
before submitting. :)
--
2.28.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bug#46114] [PATCH] website: Localize package list.
2021-01-26 16:56 [bug#46114] [PATCH] website: Localize package list Julien Lepiller
@ 2021-01-26 21:29 ` Ludovic Courtès
2021-01-26 21:43 ` Julien Lepiller
0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2021-01-26 21:29 UTC (permalink / raw)
To: Julien Lepiller; +Cc: 46114
Hi,
Julien Lepiller <julien@lepiller.eu> skribis:
> This patch lets us localize package synopsis and description in package
> lists. This is not super useful, because our guix-packages domain is
> almost untranslated, for every language, but I think it's better than
> nothing.
Yes, good idea.
> Locally, you can simply copy an existing guix-packages.mo (on the Guix
> System,
> /run/current-system/profile/share/locale/de/LC_MESSAGES/guix-packages.mo
> for the German translation) to the local locale directory
> (de/LC_MESSAGES/guix-packages.mo), in the same way we do for the
> guix-website domain.
>
> I also modified .guix.scm so the website can be generated with
> localized packages. I used the latest guix package from the current
> guix, because latest-guix (defined in .guix.scm) does not have any
> locale information in it (mo or po). Any idea to get the latest
> translations instead?
‘latest-guix’ is the same as what you get with ‘guix pull’, so it knows
where to find its .gmo files—see this bit in (guix self):
(bindtextdomain "guix"
#$(locale-data source "guix"))
(bindtextdomain "guix-packages"
#$(locale-data source
"guix-packages"
"packages"))
Now, you sent the wrong patch. :-)
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [bug#46114] [PATCH] website: Localize package list.
2021-01-26 21:29 ` Ludovic Courtès
@ 2021-01-26 21:43 ` Julien Lepiller
2021-01-27 22:18 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: Julien Lepiller @ 2021-01-26 21:43 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 46114
[-- Attachment #1: Type: text/plain, Size: 1734 bytes --]
Le Tue, 26 Jan 2021 22:29:33 +0100,
Ludovic Courtès <ludo@gnu.org> a écrit :
> Hi,
>
> Julien Lepiller <julien@lepiller.eu> skribis:
>
> > This patch lets us localize package synopsis and description in
> > package lists. This is not super useful, because our guix-packages
> > domain is almost untranslated, for every language, but I think it's
> > better than nothing.
>
> Yes, good idea.
>
> > Locally, you can simply copy an existing guix-packages.mo (on the
> > Guix System,
> > /run/current-system/profile/share/locale/de/LC_MESSAGES/guix-packages.mo
> > for the German translation) to the local locale directory
> > (de/LC_MESSAGES/guix-packages.mo), in the same way we do for the
> > guix-website domain.
> >
> > I also modified .guix.scm so the website can be generated with
> > localized packages. I used the latest guix package from the current
> > guix, because latest-guix (defined in .guix.scm) does not have any
> > locale information in it (mo or po). Any idea to get the latest
> > translations instead?
>
> ‘latest-guix’ is the same as what you get with ‘guix pull’, so it
> knows where to find its .gmo files—see this bit in (guix self):
>
> (bindtextdomain "guix"
> #$(locale-data source "guix"))
> (bindtextdomain "guix-packages"
> #$(locale-data source
> "guix-packages"
> "packages"))
yeah, but that's not very helpful. I don't understand how to get them
from guix-latest?
>
> Now, you sent the wrong patch. :-)
haha, indeed ^^'
>
> Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-website-Localize-package-list.patch --]
[-- Type: text/x-patch, Size: 6744 bytes --]
From ee20fd1a63914b9f3d13afb061b2192d65a26ee7 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Tue, 26 Jan 2021 17:48:47 +0100
Subject: [PATCH] website: Localize package list.
* .guix.scm: Copy guix-packages gettext domain locally.
* apps/i18n.scm: Bind the guix-packages gettext domain.
* apps/packages/templates/components.scm (package-preview): Localize
package description.
* apps/packages/utils.scm (package-description-shtml, package-synopsis-shtml):
Localize package synopsis and description.
* i18n-howto.txt: Document package list localization.
---
website/.guix.scm | 21 +++++++++++++++++--
website/apps/i18n.scm | 3 +++
.../apps/packages/templates/components.scm | 4 +++-
website/apps/packages/utils.scm | 7 +++++--
website/i18n-howto.txt | 7 ++++++-
5 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/website/.guix.scm b/website/.guix.scm
index 5f5c570..f656d47 100644
--- a/website/.guix.scm
+++ b/website/.guix.scm
@@ -33,6 +33,7 @@
(use-modules (guix) (gnu)
(gnu packages guile)
(gnu packages guile-xyz)
+ (gnu packages package-management)
(guix modules)
(guix git-download)
(guix gexp)
@@ -145,7 +146,13 @@
"/bin/msgfmt"))
(lingua-file (string-append "po/" lingua ".po"))
(lang (car (string-split lingua #\_)))
- (lang-file (string-append "po/" lang ".po")))
+ (lang-file (string-append "po/" lang ".po"))
+ (packages-lingua-mo (string-append
+ #$guix "/share/locale/" lingua
+ "/LC_MESSAGES/guix-packages.mo"))
+ (packages-lang-mo (string-append
+ #$guix "/share/locale/" lang
+ "/LC_MESSAGES/guix-packages.mo")))
(define (create-mo filename)
(begin
(invoke msgfmt filename)
@@ -158,7 +165,17 @@
(create-mo lingua-file))
((file-exists? lang-file)
(create-mo lang-file))
- (else #t))))
+ (else #t))
+ (cond
+ ((file-exists? packages-lingua-mo)
+ (copy-file packages-lingua-mo
+ (string-append lingua "/LC_MESSAGES/"
+ "guix-packages.mo")))
+ ((file-exists? packages-lang-mo)
+ (copy-file packages-lang-mo
+ (string-append lingua "/LC_MESSAGES/"
+ "guix-packages.mo")))
+ (else #t))))
(list #$@%linguas))
;; So we can read/write UTF-8 files.
diff --git a/website/apps/i18n.scm b/website/apps/i18n.scm
index d88333a..09f275e 100644
--- a/website/apps/i18n.scm
+++ b/website/apps/i18n.scm
@@ -20,6 +20,7 @@
#:use-module (haunt asset)
#:use-module (haunt page)
#:use-module (haunt utils)
+ #:use-module ((guix i18n) #:select (%package-text-domain))
#:use-module (ice-9 match)
#:use-module (sexp-xgettext)
#:use-module (srfi srfi-1)
@@ -41,6 +42,8 @@
(bindtextdomain %gettext-domain (getcwd))
(bind-textdomain-codeset %gettext-domain "UTF-8")
(textdomain %gettext-domain)
+(bindtextdomain %package-text-domain (getcwd))
+(bind-textdomain-codeset %package-text-domain "UTF-8")
;; NOTE: The sgettext macros have no hygiene because they use
;; datum->syntax and do not preserve the semantics of anything looking
diff --git a/website/apps/packages/templates/components.scm b/website/apps/packages/templates/components.scm
index 565b408..785b01a 100644
--- a/website/apps/packages/templates/components.scm
+++ b/website/apps/packages/templates/components.scm
@@ -14,6 +14,7 @@
#:use-module (apps packages utils)
#:use-module (guix licenses)
#:use-module (guix packages)
+ #:use-module ((guix i18n) #:select (P_))
#:use-module (guix gnu-maintenance)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
@@ -186,7 +187,8 @@
(p
(@ (class "item-summary"))
,(string-summarize
- (stexi->plain-text (texi-fragment->stexi (package-description package)))
+ (stexi->plain-text
+ (texi-fragment->stexi (P_ (package-description package))))
30)
"…")))
diff --git a/website/apps/packages/utils.scm b/website/apps/packages/utils.scm
index 66edfc6..2a1be86 100644
--- a/website/apps/packages/utils.scm
+++ b/website/apps/packages/utils.scm
@@ -24,9 +24,11 @@
(define-module (apps packages utils)
#:use-module (apps aux web)
#:use-module (apps base utils)
+ #:use-module (apps i18n)
#:use-module (apps packages data)
#:use-module (apps packages types)
#:use-module (guix packages)
+ #:use-module ((guix i18n) #:select (P_))
#:use-module (guix utils)
#:use-module (guix build utils)
#:use-module (guix build download)
@@ -92,12 +94,13 @@
(define (package-description-shtml package)
"Return a SXML representation of PACKAGE description field with HTML
vocabulary."
- (and=> (package-description package) texinfo->shtml))
+ ;(setenv "LC_ALL" (getenv "LANG"))
+ (and=> (and=> (package-description package) P_) texinfo->shtml))
(define (package-synopsis-shtml package)
"Return a SXML representation of PACKAGE synopsis field with HTML
vocabulary."
- (and=> (package-synopsis package)
+ (and=> (and=> (package-synopsis package) P_)
(lambda (synopsis)
;; Strip the paragraph that 'texinfo->shtml' adds.
(match (texinfo->shtml synopsis)
diff --git a/website/i18n-howto.txt b/website/i18n-howto.txt
index 9ec8e81..1cf836b 100644
--- a/website/i18n-howto.txt
+++ b/website/i18n-howto.txt
@@ -70,11 +70,16 @@ msgfmt de.po
cd ..
mv po/messages.mo de/LC_MESSAGES/guix-website.mo
+To translate package synopsis and descriptions, you will need the guix-packages
+domain. On the Guix System, you can copy one from your installation:
+
+cp /run/current-system/profile/share/locale/de/LC_MESSAGES/guix-packages.mo de/LC_MESSAGES/
+
To build all languages:
guix build -f .guix.scm
-To test the de_DE translation, update its mo file as above, then:
+To test the de_DE translation, update its mo files as above, then:
guix environment --ad-hoc haunt
LC_ALL=de_DE.utf8 \
--
2.30.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bug#46114] [PATCH] website: Localize package list.
2021-01-26 21:43 ` Julien Lepiller
@ 2021-01-27 22:18 ` Ludovic Courtès
2021-01-29 1:52 ` Julien Lepiller
2021-01-29 1:53 ` bug#46114: " Julien Lepiller
0 siblings, 2 replies; 6+ messages in thread
From: Ludovic Courtès @ 2021-01-27 22:18 UTC (permalink / raw)
To: Julien Lepiller; +Cc: 46114
Hi,
Julien Lepiller <julien@lepiller.eu> skribis:
> Le Tue, 26 Jan 2021 22:29:33 +0100,
> Ludovic Courtès <ludo@gnu.org> a écrit :
[...]
>> ‘latest-guix’ is the same as what you get with ‘guix pull’, so it
>> knows where to find its .gmo files—see this bit in (guix self):
>>
>> (bindtextdomain "guix"
>> #$(locale-data source "guix"))
>> (bindtextdomain "guix-packages"
>> #$(locale-data source
>> "guix-packages"
>> "packages"))
>
> yeah, but that's not very helpful. I don't understand how to get them
> from guix-latest?
Oh you need the .mo files so you can ‘bindtextdomain’ hmmm…
It would be easier if the web site used the inferior API; you would
delegate translation to the inferior and that’s it.
> From ee20fd1a63914b9f3d13afb061b2192d65a26ee7 Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> Date: Tue, 26 Jan 2021 17:48:47 +0100
> Subject: [PATCH] website: Localize package list.
>
> * .guix.scm: Copy guix-packages gettext domain locally.
> * apps/i18n.scm: Bind the guix-packages gettext domain.
> * apps/packages/templates/components.scm (package-preview): Localize
> package description.
> * apps/packages/utils.scm (package-description-shtml, package-synopsis-shtml):
> Localize package synopsis and description.
> * i18n-howto.txt: Document package list localization.
[...]
> + (packages-lingua-mo (string-append
> + #$guix "/share/locale/" lingua
> + "/LC_MESSAGES/guix-packages.mo"))
> + (packages-lang-mo (string-append
> + #$guix "/share/locale/" lang
> + "/LC_MESSAGES/guix-packages.mo")))
> (define (create-mo filename)
> (begin
> (invoke msgfmt filename)
> @@ -158,7 +165,17 @@
> (create-mo lingua-file))
> ((file-exists? lang-file)
> (create-mo lang-file))
> - (else #t))))
> + (else #t))
> + (cond
> + ((file-exists? packages-lingua-mo)
> + (copy-file packages-lingua-mo
> + (string-append lingua "/LC_MESSAGES/"
> + "guix-packages.mo")))
> + ((file-exists? packages-lang-mo)
> + (copy-file packages-lang-mo
> + (string-append lingua "/LC_MESSAGES/"
> + "guix-packages.mo")))
So we copy them for the sake of ‘bindtextdomain’, right?
In practice those .mo files should be the same as what you’d get via
‘latest-guix’ so that’s probably fine.
Why “lingua” and “lang” BTW?
[...]
> (define (package-description-shtml package)
> "Return a SXML representation of PACKAGE description field with HTML
> vocabulary."
> - (and=> (package-description package) texinfo->shtml))
> + ;(setenv "LC_ALL" (getenv "LANG"))
Leftover. :-)
LGTM, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [bug#46114] [PATCH] website: Localize package list.
2021-01-27 22:18 ` Ludovic Courtès
@ 2021-01-29 1:52 ` Julien Lepiller
2021-01-29 1:53 ` bug#46114: " Julien Lepiller
1 sibling, 0 replies; 6+ messages in thread
From: Julien Lepiller @ 2021-01-29 1:52 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 46114
Le Wed, 27 Jan 2021 23:18:02 +0100,
Ludovic Courtès <ludo@gnu.org> a écrit :
>
> So we copy them for the sake of ‘bindtextdomain’, right?
>
> In practice those .mo files should be the same as what you’d get via
> ‘latest-guix’ so that’s probably fine.
>
> Why “lingua” and “lang” BTW?
I simply copied the same template as for the po file. I think lingua
contains the specific language+territory code, whearas lang contains
only the language code. If we have a specific translation, we want to
use it, otherwise we use the generic one for the language.
>
>
> [...]
>
> > (define (package-description-shtml package)
> > "Return a SXML representation of PACKAGE description field with
> > HTML vocabulary."
> > - (and=> (package-description package) texinfo->shtml))
> > + ;(setenv "LC_ALL" (getenv "LANG"))
>
> Leftover. :-)
Fixed.
>
> LGTM, thanks!
>
> Ludo’.
Pushed as f56e35bbd34aca09b67c3623fcd9b05cc0467d6f, thank you!
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#46114: [PATCH] website: Localize package list.
2021-01-27 22:18 ` Ludovic Courtès
2021-01-29 1:52 ` Julien Lepiller
@ 2021-01-29 1:53 ` Julien Lepiller
1 sibling, 0 replies; 6+ messages in thread
From: Julien Lepiller @ 2021-01-29 1:53 UTC (permalink / raw)
To: 46114-done
Forgot to close :)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-29 1:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-26 16:56 [bug#46114] [PATCH] website: Localize package list Julien Lepiller
2021-01-26 21:29 ` Ludovic Courtès
2021-01-26 21:43 ` Julien Lepiller
2021-01-27 22:18 ` Ludovic Courtès
2021-01-29 1:52 ` Julien Lepiller
2021-01-29 1:53 ` bug#46114: " 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).