[Groonga-commit] groonga/groonga [master] [doc] support I18N in conf.py.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 5月 22日 (日) 23:08:03 JST


Kouhei Sutou	2011-05-22 14:08:03 +0000 (Sun, 22 May 2011)

  New Revision: 9c900a76305fc175c462c4f85421d2905f88a876

  Log:
    [doc] support I18N in conf.py.

  Added files:
    doc/locale/en/LC_MESSAGES/conf.po
    doc/locale/ja/LC_MESSAGES/conf.po
  Modified files:
    build/makefiles/gettext-files.am
    build/makefiles/gettext.am
    build/makefiles/sphinx-build.am
    doc/source/conf.py

  Modified: build/makefiles/gettext-files.am (+29 -28)
===================================================================
--- build/makefiles/gettext-files.am    2011-05-22 10:28:55 +0000 (c6a722e)
+++ build/makefiles/gettext-files.am    2011-05-22 14:08:03 +0000 (2e51b62)
@@ -1,34 +1,35 @@
-# (cd ../../doc; echo "po_files = \\"; find pot -type f -name '*.pot' | sort | sed -e 's,^pot/,\t,g' -e 's,pot$,po \\,'; echo -n "\t\$(NULL)")
-po_files =					\
-	characteristic.po			\
-	command_version.po			\
-	commands.po				\
-	commands_not_implemented.po		\
-	developer.po				\
-	execfile.po				\
-	expr.po					\
-	functions.po				\
-	grnslap.po				\
-	grntest.po				\
-	http.po					\
-	index.po				\
-	install.po				\
-	limitations.po				\
-	news.po					\
-	process.po				\
-	pseudo_column.po			\
-	reference.po				\
-	spec.po					\
-	troubleshooting.po			\
-	tutorial.po				\
-	type.po
+# (cd ../../doc/locale/en/LC_MESSAGES; echo "po_files = \\"; find . -type f -name '*.pot' | sort | sed -e 's,^\./,\t,g' -e 's,pot$,po \\,'; echo -n "\t\$(NULL)")
+po_files = \
+	characteristic.po \
+	command_version.po \
+	commands.po \
+	conf.po \
+	developer.po \
+	execfile.po \
+	expr.po \
+	functions.po \
+	grnslap.po \
+	grntest.po \
+	http.po \
+	index.po \
+	install.po \
+	limitations.po \
+	news.po \
+	process.po \
+	pseudo_column.po \
+	reference.po \
+	spec.po \
+	troubleshooting.po \
+	tutorial.po \
+	type.po \
+	$(NULL)
 
-# (cd ../../doc; echo "mo_files = \\"; find pot -type f -name '*.pot' | sort | sed -e 's,^pot/,\t,g' -e 's,pot$,mo \\,'; echo -n "\t\$(NULL)")
+# (cd ../../doc/locale/en/LC_MESSAGES; echo "mo_files = \\"; find . -type f -name '*.pot' | sort | sed -e 's,^\./,\t,g' -e 's,pot$,mo \\,'; echo -n "\t\$(NULL)")
 mo_files = \
 	characteristic.mo \
 	command_version.mo \
 	commands.mo \
-	commands_not_implemented.mo \
+	conf.mo \
 	developer.mo \
 	execfile.mo \
 	expr.mo \
@@ -49,12 +50,12 @@ mo_files = \
 	type.mo \
 	$(NULL)
 
-# (cd ../../doc; echo "mo_files_relative_from_locale_dir = \\"; find pot -type f -name '*.pot' | sort | sed -e 's,^pot/,\tLC_MESSAGES/,g' -e 's,pot$,mo \\,'; echo -n "\t\$(NULL)")
+# (cd ../../doc/locale/en; echo "mo_files_relative_from_locale_dir = \\"; find LC_MESSAGES -type f -name '*.pot' | sort | sed -e 's,^,\t,g' -e 's,pot$,mo \\,'; echo -n "\t\$(NULL)")
 mo_files_relative_from_locale_dir = \
 	LC_MESSAGES/characteristic.mo \
 	LC_MESSAGES/command_version.mo \
 	LC_MESSAGES/commands.mo \
-	LC_MESSAGES/commands_not_implemented.mo \
+	LC_MESSAGES/conf.mo \
 	LC_MESSAGES/developer.mo \
 	LC_MESSAGES/execfile.mo \
 	LC_MESSAGES/expr.mo \

  Modified: build/makefiles/gettext.am (+5 -0)
===================================================================
--- build/makefiles/gettext.am    2011-05-22 10:28:55 +0000 (d930f8b)
+++ build/makefiles/gettext.am    2011-05-22 14:08:03 +0000 (7f1fbac)
@@ -28,13 +28,18 @@ pdf: build
 
 gettext: sphinx-ensure-updated
 	$(SPHINX_BUILD_COMMAND) -d doctrees -b gettext $(ALLSPHINXOPTS) .
+	xgettext --language Python --output conf.pot ../../../source/conf.py
 
 init: gettext
 	for po in $(po_files); do						\
 	  pot=`basename $${po} | sed -e 's,po$$,pot,g'`;			\
+	  test "$FORCE_INIT" != "yes" -o -f $${po} && continue;			\
 	  msginit --input=$${pot} --output-file=$${po} --locale=$(LOCALE);	\
 	done
 
+reinit:
+	$(MAKE) FORCE_INIT=yes init
+
 pot-build-stamp: $(source_files)
 	$(MAKE) gettext
 	@touch $@

  Modified: build/makefiles/sphinx-build.am (+2 -1)
===================================================================
--- build/makefiles/sphinx-build.am    2011-05-22 10:28:55 +0000 (52ce260)
+++ build/makefiles/sphinx-build.am    2011-05-22 14:08:03 +0000 (e148b5c)
@@ -5,9 +5,10 @@ SPHINXOPTS    =
 PAPER         =
 
 # Internal variables.
+SOURCE_DIR      = $(abs_top_srcdir)/doc/source
 PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(abs_top_srcdir)/doc/source
+ALLSPHINXOPTS   = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SOURCE_DIR)
 
 SPHINX_DIR = $(abs_top_builddir)/doc/sphinx
 SPHINX_BUILD = $(SPHINX_DIR)/sphinx-build.py

  Added: doc/locale/en/LC_MESSAGES/conf.po (+31 -0) 100644
===================================================================
--- /dev/null
+++ doc/locale/en/LC_MESSAGES/conf.po    2011-05-22 14:08:03 +0000 (c2994a9)
@@ -0,0 +1,31 @@
+# English translations for groonga package.
+# Copyright (C) 2011 THE groonga'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the groonga package.
+# Kouhei Sutou <kou****@clear*****>, 2011.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: groonga 1.2.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-05-22 22:56+0900\n"
+"PO-Revision-Date: 2011-05-22 22:49+0900\n"
+"Last-Translator: Kouhei Sutou <kou****@clear*****>\n"
+"Language-Team: English\n"
+"Language: en\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ASCII\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../../../source/conf.py:166
+#, python-format
+msgid "%(project)s v%(release)s documentation"
+msgstr "%(project)s v%(release)s documentation"
+
+#: ../../../source/conf.py:237 ../../../source/conf.py:280
+msgid "groonga documentation"
+msgstr "groonga documentation"
+
+#: ../../../source/conf.py:263
+msgid "groonga project"
+msgstr "groonga project"

  Added: doc/locale/ja/LC_MESSAGES/conf.po (+34 -0) 100644
===================================================================
--- /dev/null
+++ doc/locale/ja/LC_MESSAGES/conf.po    2011-05-22 14:08:03 +0000 (b072216)
@@ -0,0 +1,34 @@
+# Japanese translations for 1.2.1 package.
+# Copyright (C) 2009-2011, Brazil, Inc
+# This file is distributed under the same license as the groonga package.
+# Kouhei Sutou <kou****@clear*****>, 2011.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: 1.2.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-05-22 22:56+0900\n"
+"PO-Revision-Date: 2011-05-22 21:45+0900\n"
+"Last-Translator: Kouhei Sutou <kou****@clear*****>\n"
+"Language-Team: Japanese\n"
+"Language: ja\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+#: ../../../source/conf.py:166
+#, python-format
+msgid "%(project)s v%(release)s documentation"
+msgstr "%(project)s v%(release)sドキュメント"
+
+#: ../../../source/conf.py:237 ../../../source/conf.py:280
+msgid "groonga documentation"
+msgstr "groongaのドキュメント"
+
+#: ../../../source/conf.py:263
+msgid "groonga project"
+msgstr "groongaプロジェクト"
+
+#~ msgid "groonga Documentation"
+#~ msgstr "groongaのドキュメント"

  Modified: doc/source/conf.py (+15 -5)
===================================================================
--- doc/source/conf.py    2011-05-22 10:28:55 +0000 (985b90f)
+++ doc/source/conf.py    2011-05-22 14:08:03 +0000 (6c00269)
@@ -17,6 +17,7 @@ RST2PDF_VERSION_REQUIRED = "0.14.2"
 import re
 import sphinx
 import sys, os
+import gettext
 from datetime import datetime
 from pkg_resources import parse_version
 
@@ -94,6 +95,13 @@ locale_dirs = ["../locale"]
 # for a list of supported languages.
 language = os.environ['LOCALE']
 
+locale_dir = os.path.dirname(__file__) + "/../locale"
+try:
+  catalog = gettext.Catalog("conf", localedir=locale_dir, languages=[language])
+  _ = catalog.gettext
+except:
+  _ = lambda msgid: msgid
+
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:
 #today = ''
@@ -155,7 +163,9 @@ html_theme_path = ["../themes"]
 
 # The name for this set of Sphinx documents.  If None, it defaults to
 # "<project> v<release> documentation".
-#html_title = None
+html_title_format = unicode(_("%(project)s v%(release)s documentation"), "utf-8")
+html_title = html_title_format % {"project": project,
+                                  "release": unicode(release, "utf-8")}
 
 # A shorter title for the navigation bar.  Default is the same as html_title.
 #html_short_title = None
@@ -224,7 +234,7 @@ htmlhelp_basename = 'groongadoc'
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-  ('index', 'groonga.tex', u'groonga Documentation',
+  ('index', 'groonga.tex', unicode(_('groonga documentation'), "utf-8"),
    u'Brazil, Inc', 'manual'),
 ]
 
@@ -249,8 +259,8 @@ latex_documents = [
 pdf_documents = [
   ('index',
    u'groonga-%s' % (release,),
-   u'groonga %s document' % (release,),
-   u'groonga project')
+   html_title,
+   unicode(_('groonga project'), "utf-8"))
 ]
 pdf_stylesheets = ['sphinx', 'kerning', 'a4']
 if 'language' in dir():
@@ -267,6 +277,6 @@ pdf_break_level = 2
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'groonga', u'groonga documentation',
+    ('index', 'groonga', unicode(_('groonga documentation'), "utf-8"),
      [u'groonga project'], 1)
 ]




Groonga-commit メーリングリストの案内
Back to archive index