Patchwork [0,of,9,STABLE?,V2] make i18n man and html

login
register
mail settings
Submitter Martin Geisler
Date May 22, 2013, 10:03 p.m.
Message ID <87mwrmy8n3.fsf@hbox.dyndns.org>
Download mbox | patch
Permalink /patch/1661/
State Rejected, archived
Headers show

Comments

Martin Geisler - May 22, 2013, 10:03 p.m.
Takumi IINO <trot.thunder@gmail.com> writes:

Hi Takumi,

> This patch series aim is make i18n man and html.

Thanks for working on this! I'm really bad at taking time for Mercurial
work these days, but I wanted to reply since I once played with the same
idea... I've just updated my old patch to make it work with the default
branch. The version seems to work.

I think it is simpler than your patch series, but maybe my patch is
missing something? Could you take a look at it and see if it produces
okay output for you?

The ignore file needs to be updated and I think the Makefile can be
further improved -- there is a hard-coded list of locales to generate
and there is some redundancy with the patch below. But it was just a
quick attempt :)

Btw, the extra newlines after the ..note directives were needed to make
Docutils like the input. I forget the details, but I seem to recall that
this changed between Docutils versions, i.e., that a newer version
required the newline.


# HG changeset patch
# User Martin Geisler <martin@geisler.net>
# Date 1369259619 -7200
#      Wed May 22 23:53:39 2013 +0200
# Node ID f225f9e1316fff783d06a837c497a06cf56b8c0c
# Parent  0ec31231afad3fc171f882226aae50d4737559b5
[mq]: translate-manpages
Takumi IINO - May 23, 2013, 5:13 p.m.
Hi Martin.

2013/5/23 Martin Geisler <martin@geisler.net>

> Takumi IINO <trot.thunder@gmail.com> writes:
>
> Hi Takumi,
>
> > This patch series aim is make i18n man and html.
>
> Thanks for working on this! I'm really bad at taking time for Mercurial
> work these days, but I wanted to reply since I once played with the same
> idea... I've just updated my old patch to make it work with the default
> branch. The version seems to work.
>

I applied your patch and tried to generate translated html with GNU Make
3.81 on mac os x 10.8.3,
but I could not generate html:

  % hg log -r qparent --template "{node}\n"
  865beb8497208ee8e719c939035a6bb5cd9238fc
  % LANGUAGE=da make clean all 2>&1 | tail
  python runrst hgmanpage  --halt warning \
            --strip-elements-with-class htmlonly hgrc.5.txt hgrc.5
  python runrst html  --halt warning \
            --link-stylesheet --stylesheet-path style.css hg.1.txt hg.1.html
  python runrst html  --halt warning \
            --link-stylesheet --stylesheet-path style.css hgignore.5.txt
hgignore.5.html
  python runrst html  --halt warning \
            --link-stylesheet --stylesheet-path style.css hgrc.5.txt
hgrc.5.html
  make[1]: *** No rule to make target `hg.1.da.html', needed by `html'.
 Stop.
  make: *** [doc] Error 2

i have a mistake or use older version?

I think it is simpler than your patch series, but maybe my patch is
> missing something? Could you take a look at it and see if it produces
> okay output for you?
>

HTML, which is translated in Japanese partially exists.

- http://mercurial.selenic.com/wiki/TranslatedManPages

The goal is to translate all.

I seem your patch dose not output translation of these files as html:

- doc/common.txt
- content of doc/hgignore.5.txt (mercurial/help/hgignore.txt)
- content of doc/hgrc.5.txt (mercurial/help/config.txt)

Regards.


>
> The ignore file needs to be updated and I think the Makefile can be
> further improved -- there is a hard-coded list of locales to generate
> and there is some redundancy with the patch below. But it was just a
> quick attempt :)
>
> Btw, the extra newlines after the ..note directives were needed to make
> Docutils like the input. I forget the details, but I seem to recall that
> this changed between Docutils versions, i.e., that a newer version
> required the newline.
>
>
> # HG changeset patch
> # User Martin Geisler <martin@geisler.net>
> # Date 1369259619 -7200
> #      Wed May 22 23:53:39 2013 +0200
> # Node ID f225f9e1316fff783d06a837c497a06cf56b8c0c
> # Parent  0ec31231afad3fc171f882226aae50d4737559b5
> [mq]: translate-manpages
>
> diff --git a/Makefile b/Makefile
> --- a/Makefile
> +++ b/Makefile
> @@ -9,7 +9,7 @@
>  PYTHON=python
>  PURE=
>  PYFILES:=$(shell find mercurial hgext doc -name '*.py')
> -DOCFILES=mercurial/help/*.txt
> +DOCFILES=mercurial/help/*.txt doc/hg.1.txt doc/hgignore.5.txt
> doc/hgrc.5.txt
>
>  # Set this to e.g. "mingw32" to use a non-default compiler.
>  COMPILER=
> diff --git a/doc/Makefile b/doc/Makefile
> --- a/doc/Makefile
> +++ b/doc/Makefile
> @@ -7,16 +7,16 @@
>  MANDIR=$(PREFIX)/share/man
>  INSTALL=install -c -m 644
>  PYTHON=python
> +LOCALES=da
>  RSTARGS=
>
> -export LANGUAGE=C
> -export LC_ALL=C
> +export HGENCODING=UTF-8
>
>  all: man html
>
>  man: $(MAN)
>
> -html: $(HTML)
> +html: $(HTML) $(foreach lang,$(LOCALES),$(HTML:%.html=%.$(lang).html))
>
>  hg.1.txt: hg.1.gendoc.txt
>         touch hg.1.txt
> @@ -29,6 +29,19 @@
>
>  hgrc.5.html: ../mercurial/help/config.txt
>
> +hg.1.%.txt: hg.1.gendoc.txt ../i18n/%.po $(GENDOC)
> +       LANGUAGE=$* ${PYTHON} gendoc.py > hg.1.gendoc.txt
> +       LANGUAGE=$* $(PYTHON) translate.py < hg.1.txt > $@
> +
> +hgignore.5.%.txt: hgignore.5.txt
> +       LANGUAGE=$* $(PYTHON) translate.py < $< > $@
> +
> +hgrc.5.%.txt: hgrc.5.txt
> +       LANGUAGE=$* $(PYTHON) translate.py < $< > $@
> +
> +hg.5.%.txt: hg.5.txt
> +       LANGUAGE=$* $(PYTHON) translate.py < $< > $@
> +
>  %: %.txt common.txt
>         $(PYTHON) runrst hgmanpage $(RSTARGS) --halt warning \
>           --strip-elements-with-class htmlonly $*.txt $*
> diff --git a/doc/gendoc.py b/doc/gendoc.py
> --- a/doc/gendoc.py
> +++ b/doc/gendoc.py
> @@ -7,7 +7,7 @@
>  from mercurial import encoding
>  from mercurial import minirst
>  from mercurial.commands import table, globalopts
> -from mercurial.i18n import _
> +from mercurial.i18n import _, gettext
>  from mercurial.help import helptable
>  from mercurial import extensions
>  from mercurial import util
> @@ -16,6 +16,7 @@
>      if not docstr:
>          return "", ""
>      # sanitize
> +    docstr = gettext(docstr)
>      docstr = docstr.strip("\n")
>      docstr = docstr.rstrip()
>      shortdesc = docstr.splitlines()[0].strip()
> diff --git a/doc/translate.py b/doc/translate.py
> new file mode 100644
> --- /dev/null
> +++ b/doc/translate.py
> @@ -0,0 +1,6 @@
> +
> +import sys
> +from mercurial.i18n import gettext
> +
> +if __name__ == "__main__":
> +    sys.stdout.write(gettext(sys.stdin.read()))
> diff --git a/i18n/da.po b/i18n/da.po
> --- a/i18n/da.po
> +++ b/i18n/da.po
> @@ -11990,7 +11990,7 @@
>  msgstr "Datoformater"
>
>  msgid "File Name Patterns"
> -msgstr "Mønstre for filnavne"
> +msgstr ""
>
>  msgid "Environment Variables"
>  msgstr "Miljøvariable"
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -396,6 +396,7 @@
>      changes and the merged result is left uncommitted.
>
>      .. note::
> +
>        backout cannot be used to fix either an unwanted or
>        incorrect merge.
>
> @@ -933,6 +934,7 @@
>      """set or show the current branch name
>
>      .. note::
> +
>         Branch names are permanent and global. Use :hg:`bookmark` to
> create a
>         light-weight bookmark instead. See :hg:`help glossary` for more
>         information about named branches and bookmarks.
> @@ -2675,6 +2677,7 @@
>      Differences between files are shown using the unified diff format.
>
>      .. note::
> +
>         diff may generate unexpected results for merges, as it will
>         default to comparing against the working directory's first
>         parent changeset if no revisions are specified.
> @@ -2764,6 +2767,7 @@
>      comment.
>
>      .. note::
> +
>         export may generate unexpected diff output for merge
>         changesets, as it will compare the merge changeset against its
>         first parent only.
> @@ -2896,6 +2900,7 @@
>      continued with the -c/--continue option.
>
>      .. note::
> +
>        The -c/--continue option does not reapply earlier options.
>
>      .. container:: verbose
> @@ -3944,12 +3949,14 @@
>      changed files and full commit message are shown.
>
>      .. note::
> +
>         log -p/--patch may generate unexpected diff output for merge
>         changesets, as it will only compare the merge changeset against
>         its first parent. Also, only files different from BOTH parents
>         will appear in files:.
>
>      .. note::
> +
>         for performance reasons, log FILE may omit duplicate changes
>         made on branches and will not show deletions. To see all
>         changes including duplicates and deletions, use the --removed
> @@ -4934,6 +4941,7 @@
>      """restore files to their checkout state
>
>      .. note::
> +
>         To check out earlier revisions, you should use :hg:`update REV`.
>         To cancel an uncommitted merge (and lose your changes), use
>         :hg:`update --clean .`.
> @@ -5257,6 +5265,7 @@
>      unless explicitly requested with -u/--unknown or -i/--ignored.
>
>      .. note::
> +
>         status may appear to disagree with diff if permissions have
>         changed or a merge has occurred. The standard diff format does
>         not report permission changes and diff only reports changes
>
>
>
>
> --
> Martin Geisler
>

Patch

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ 
 PYTHON=python
 PURE=
 PYFILES:=$(shell find mercurial hgext doc -name '*.py')
-DOCFILES=mercurial/help/*.txt
+DOCFILES=mercurial/help/*.txt doc/hg.1.txt doc/hgignore.5.txt doc/hgrc.5.txt
 
 # Set this to e.g. "mingw32" to use a non-default compiler.
 COMPILER=
diff --git a/doc/Makefile b/doc/Makefile
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -7,16 +7,16 @@ 
 MANDIR=$(PREFIX)/share/man
 INSTALL=install -c -m 644
 PYTHON=python
+LOCALES=da
 RSTARGS=
 
-export LANGUAGE=C
-export LC_ALL=C
+export HGENCODING=UTF-8
 
 all: man html
 
 man: $(MAN)
 
-html: $(HTML)
+html: $(HTML) $(foreach lang,$(LOCALES),$(HTML:%.html=%.$(lang).html))
 
 hg.1.txt: hg.1.gendoc.txt
 	touch hg.1.txt
@@ -29,6 +29,19 @@ 
 
 hgrc.5.html: ../mercurial/help/config.txt
 
+hg.1.%.txt: hg.1.gendoc.txt ../i18n/%.po $(GENDOC)
+	LANGUAGE=$* ${PYTHON} gendoc.py > hg.1.gendoc.txt
+	LANGUAGE=$* $(PYTHON) translate.py < hg.1.txt > $@
+
+hgignore.5.%.txt: hgignore.5.txt
+	LANGUAGE=$* $(PYTHON) translate.py < $< > $@
+
+hgrc.5.%.txt: hgrc.5.txt
+	LANGUAGE=$* $(PYTHON) translate.py < $< > $@
+
+hg.5.%.txt: hg.5.txt
+	LANGUAGE=$* $(PYTHON) translate.py < $< > $@
+
 %: %.txt common.txt
 	$(PYTHON) runrst hgmanpage $(RSTARGS) --halt warning \
 	  --strip-elements-with-class htmlonly $*.txt $*
diff --git a/doc/gendoc.py b/doc/gendoc.py
--- a/doc/gendoc.py
+++ b/doc/gendoc.py
@@ -7,7 +7,7 @@ 
 from mercurial import encoding
 from mercurial import minirst
 from mercurial.commands import table, globalopts
-from mercurial.i18n import _
+from mercurial.i18n import _, gettext
 from mercurial.help import helptable
 from mercurial import extensions
 from mercurial import util
@@ -16,6 +16,7 @@ 
     if not docstr:
         return "", ""
     # sanitize
+    docstr = gettext(docstr)
     docstr = docstr.strip("\n")
     docstr = docstr.rstrip()
     shortdesc = docstr.splitlines()[0].strip()
diff --git a/doc/translate.py b/doc/translate.py
new file mode 100644
--- /dev/null
+++ b/doc/translate.py
@@ -0,0 +1,6 @@ 
+
+import sys
+from mercurial.i18n import gettext
+
+if __name__ == "__main__":
+    sys.stdout.write(gettext(sys.stdin.read()))
diff --git a/i18n/da.po b/i18n/da.po
--- a/i18n/da.po
+++ b/i18n/da.po
@@ -11990,7 +11990,7 @@ 
 msgstr "Datoformater"
 
 msgid "File Name Patterns"
-msgstr "Mønstre for filnavne"
+msgstr ""
 
 msgid "Environment Variables"
 msgstr "Miljøvariable"
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -396,6 +396,7 @@ 
     changes and the merged result is left uncommitted.
 
     .. note::
+
       backout cannot be used to fix either an unwanted or
       incorrect merge.
 
@@ -933,6 +934,7 @@ 
     """set or show the current branch name
 
     .. note::
+
        Branch names are permanent and global. Use :hg:`bookmark` to create a
        light-weight bookmark instead. See :hg:`help glossary` for more
        information about named branches and bookmarks.
@@ -2675,6 +2677,7 @@ 
     Differences between files are shown using the unified diff format.
 
     .. note::
+
        diff may generate unexpected results for merges, as it will
        default to comparing against the working directory's first
        parent changeset if no revisions are specified.
@@ -2764,6 +2767,7 @@ 
     comment.
 
     .. note::
+
        export may generate unexpected diff output for merge
        changesets, as it will compare the merge changeset against its
        first parent only.
@@ -2896,6 +2900,7 @@ 
     continued with the -c/--continue option.
 
     .. note::
+
       The -c/--continue option does not reapply earlier options.
 
     .. container:: verbose
@@ -3944,12 +3949,14 @@ 
     changed files and full commit message are shown.
 
     .. note::
+
        log -p/--patch may generate unexpected diff output for merge
        changesets, as it will only compare the merge changeset against
        its first parent. Also, only files different from BOTH parents
        will appear in files:.
 
     .. note::
+
        for performance reasons, log FILE may omit duplicate changes
        made on branches and will not show deletions. To see all
        changes including duplicates and deletions, use the --removed
@@ -4934,6 +4941,7 @@ 
     """restore files to their checkout state
 
     .. note::
+
        To check out earlier revisions, you should use :hg:`update REV`.
        To cancel an uncommitted merge (and lose your changes), use
        :hg:`update --clean .`.
@@ -5257,6 +5265,7 @@ 
     unless explicitly requested with -u/--unknown or -i/--ignored.
 
     .. note::
+
        status may appear to disagree with diff if permissions have
        changed or a merge has occurred. The standard diff format does
        not report permission changes and diff only reports changes