From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Fri, 28 Mar 2008 16:47:27 +0000 (+0000) Subject: Basic infrastructure for using gettext to translate. X-Git-Tag: 1.0.4~24^2~46 X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=commitdiff_plain;h=b2a619b32d66d94779b7fef0363aecfa17cef6f7;hp=d84d67b71144625452b186db38abe876bf877fea Basic infrastructure for using gettext to translate. --- diff --git a/.hgignore b/.hgignore index 3f4fb29..f8063da 100644 --- a/.hgignore +++ b/.hgignore @@ -35,3 +35,9 @@ virt-top/virt-top virt-df/virt-df wininstaller.nsis *.orig +mlvirsh/mlvirsh_gettext.ml +virt-ctrl/virt_ctrl_gettext.ml +virt-df/virt_df_gettext.ml +virt-top/virt_top_gettext.ml +po/*.mo +po/*.po.bak diff --git a/README b/README index 8ae896e..32686c5 100644 --- a/README +++ b/README @@ -35,7 +35,9 @@ the packages below if you want to build from source. ocaml | R | | R | R | R | >= 3.08 | | | | | | | | | - findlib | HR | R | HR | HR | n/a + findlib | HR | R | HR | HR | Note [1] + | | | | | + ocaml-gettext | R | R | R | R | Note [2] | | | | | MinGW + MSYS | | | | | R --------------+----------+---------+---------+----------+--------- @@ -69,6 +71,12 @@ the packages below if you want to build from source. O = optional (just improves functionality, but not required) n/a = not available +Note [1]: Findlib was recently ported to Windows and in future we may +require it because it will let us remove a lot of hacks from the +Makefiles. + +Note [2]: It's not clear if ocaml-gettext works on Windows. + Where to get the packages: libvirt >= 0.2.1 from http://libvirt.org/ (get the latest version available) @@ -80,6 +88,11 @@ Where to get the packages: findlib from http://www.ocaml-programming.de/packages/ or packaged in Debian, Ubuntu and Fedora as 'ocaml-findlib' + ocaml-gettext from http://www.le-gall.net/sylvain+violaine/ocaml-gettext.html + + patch for OCaml 3.10: + http://www.annexia.org/tmp/ocaml-gettext-0.2.0-20080321.patch + (This should appear in ocaml-gettext 0.3.0 shortly). + MinGW + MSYS from http://www.mingw.org/ (only needed for Windows) ocamldoc part of OCaml itself diff --git a/configure.ac b/configure.ac index 427c680..57517f8 100644 --- a/configure.ac +++ b/configure.ac @@ -193,6 +193,7 @@ if test "x$OCAMLFIND" != "x"; then AC_CHECK_OCAML_PKG(xml-light) AC_CHECK_OCAML_PKG(csv) AC_CHECK_OCAML_PKG(dbus) + AC_CHECK_OCAML_PKG(gettext) dnl Need to check which version of calendar is installed. AC_CHECK_OCAML_MODULE(calendar,pkg_calendar2,CalendarLib.Date,[+calendar]) @@ -208,6 +209,7 @@ if test "x$OCAMLFIND" != "x"; then AC_SUBST(pkg_xml_light) AC_SUBST(pkg_csv) AC_SUBST(pkg_dbus) + AC_SUBST(pkg_gettext) AC_SUBST(pkg_calendar) AC_SUBST(pkg_calendar2) else @@ -227,6 +229,7 @@ else AC_CHECK_OCAML_MODULE(xml-light,pkg_xml_light,Xml,[+xml-light]) AC_CHECK_OCAML_MODULE(csv,pkg_csv,Csv,[+csv]) AC_CHECK_OCAML_MODULE(dbus,pkg_dbus,DBus,[+dbus]) + AC_CHECK_OCAML_MODULE(gettext,pkg_gettext,Gettext,[+gettext]) dnl XXX Version check - see above. AC_CHECK_OCAML_MODULE(calendar,pkg_calendar,Calendar,[+calendar]) fi @@ -250,6 +253,9 @@ AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc) dnl Check for optional gdk-pixbuf-mlsource (for icons). AC_CHECK_PROG(HAVE_GDK_PIXBUF_MLSOURCE,gdk-pixbuf-mlsource,gdk-pixbuf-mlsource) +dnl Check for recommended ocaml-gettext tool. +AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext) + dnl Check for optional NSIS (for building a Windows installer). AC_ARG_WITH([nsis], [AS_HELP_STRING([--with-nsis], @@ -339,6 +345,42 @@ AC_SUBST(GNUTLS_DLL_PATH) AC_SUBST(GTK_DLL_PATH) AC_SUBST(GTK_PATH) +dnl Write gettext modules for the programs. +dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html +for d in mlvirsh virt-ctrl virt-df virt-top; do + f=`echo $d | tr - _`_gettext.ml + AC_MSG_NOTICE([creating $d/$f]) + rm -f $d/$f + echo "(* This file is generated automatically by ./configure. *)" > $d/$f + if test "x$pkg_gettext" != "xno"; then + # Gettext module is available, so use it. + cat <>$d/$f +module Gettext = Gettext.Program ( + struct + let textdomain = "$d" + let codeset = None + let dir = None + let dependencies = [[]] + end +) (GettextStub.Native) +EOT + else + # No gettext module is available, so fake the translation functions. + cat <>$d/$f +module Gettext = struct + external s_ : string -> string = "%identity" + external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format + = "%identity" + let sn_ : string -> string -> int -> string + = fun s p n -> if n = 1 then s else p + let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int + -> ('a -> 'b, 'c, 'd) format + = fun s p n -> if n = 1 then s else p +end +EOT + fi +done + dnl Summary. echo "------------------------------------------------------------" echo "Thanks for downloading" $PACKAGE_STRING @@ -351,6 +393,7 @@ AC_CONFIG_FILES([META libvirt/libvirt_version.ml Makefile Make.rules + po/Makefile libvirt/Makefile examples/Makefile mlvirsh/Makefile diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..bef7f4a --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +ja diff --git a/po/Makefile.in b/po/Makefile.in new file mode 100644 index 0000000..9398e2f --- /dev/null +++ b/po/Makefile.in @@ -0,0 +1,79 @@ +# Makefile for po subdirectory. +# @configure_input@ +# +# Copyright (C) 2007-2008 Red Hat Inc. +# Written by Richard W.M. Jones +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +OCAML_GETTEXT_PACKAGE = virt-top +LINGUAS = $(shell cat LINGUAS) +SOURCES = POTFILES + +OCAML_GETTEXT = @OCAML_GETTEXT@ +OCAML_GETTEXT_EXTRACT_OPTIONS = +OCAML_GETTEXT_COMPILE_OPTIONS = +OCAML_GETTEXT_INSTALL_OPTIONS = +OCAML_GETTEXT_MERGE_OPTIONS = + +PODIR = @prefix@/share/locale + +POFILES = $(addsuffix .po,$(LINGUAS)) +MOFILES = $(addsuffix .mo,$(LINGUAS)) +POTFILE = $(OCAML_GETTEXT_PACKAGE).pot + +all: $(MOFILES) $(POTFILE) + +install: install-po + +uninstall: uninstall-po + +clean:: clean-po + +%.mo: %.po + $(OCAML_GETTEXT) --action compile $(OCAML_GETTEXT_COMPILE_OPTIONS) \ + --compile-output $@ $^ + +%.pot: $(SOURCES) $(shell cat $(SOURCES)) + $(OCAML_GETTEXT) --action extract $(OCAML_GETTEXT_EXTRACT_OPTIONS) \ + --extract-pot $@ $< + +# Also includes a fix for incorrectly escaped multi-byte sequences. +%.po: $(POTFILE) + $(OCAML_GETTEXT) --action merge $(OCAML_GETTEXT_MERGE_OPTIONS) \ + --merge-pot $(POTFILE) $@ + mv $@ $@.orig + perl -wpe 's/\\(\d{3})/pack "C*", $$1/ge' < $@.orig > $@ + +$(BUILDPO): + mkdir -p $(BUILDPO) + +.PRECIOUS: $(POTFILE) + +install-po: $(MOFILES) + $(OCAML_GETTEXT) --action install $(OCAML_GETTEXT_INSTALL_OPTIONS) \ + --install-textdomain $(OCAML_GETTEXT_PACKAGE) \ + --install-destdir $(PODIR) $(MOFILES) + +uninstall-po: + $(OCAML_GETTEXT) --action uninstall $(OCAML_GETTEXT_INSTALL_OPTIONS) \ + --uninstall-textdomain $(OCAML_GETTEXT_PACKAGE) \ + --uninstall-orgdir $(PODIR) $(MOFILES) + +clean-po: + -$(OCAML_GETTEXT) --action uninstall $(OCAML_GETTEXT_INSTALL_OPTIONS) \ + --uninstall-textdomain $(OCAML_GETTEXT_PACKAGE) \ + --uninstall-orgdir $(BUILDPO) $(MOFILES) + -$(RM) $(MOFILES) diff --git a/po/POTFILES b/po/POTFILES new file mode 100644 index 0000000..938a847 --- /dev/null +++ b/po/POTFILES @@ -0,0 +1,22 @@ +../mlvirsh/mlvirsh.ml +../virt-ctrl/mingw-gcc-wrapper.ml +../virt-ctrl/vc_connection_dlg.ml +../virt-ctrl/vc_connections.ml +../virt-ctrl/vc_dbus.ml +../virt-ctrl/vc_domain_ops.ml +../virt-ctrl/vc_helpers.ml +../virt-ctrl/vc_icons.ml +../virt-ctrl/vc_mainwindow.ml +../virt-ctrl/virt_ctrl.ml +../virt-df/virt_df_ext2.ml +../virt-df/virt_df_linux_swap.ml +../virt-df/virt_df_lvm2.ml +../virt-df/virt_df_main.ml +../virt-df/virt_df.ml +../virt-top/virt_top_calendar1.ml +../virt-top/virt_top_calendar2.ml +../virt-top/virt_top_csv.ml +../virt-top/virt_top_main.ml +../virt-top/virt_top.ml +../virt-top/virt_top_utils.ml +../virt-top/virt_top_xml.ml diff --git a/po/ja.po b/po/ja.po new file mode 100644 index 0000000..609d69d --- /dev/null +++ b/po/ja.po @@ -0,0 +1,25 @@ +msgid "" +msgstr "" +"Project-Id-Version: virt-p2v--devel\n" +"Report-Msgid-Bugs-To: rjones@redhat.com\n" +"POT-Creation-Date: 2008-03-22 15:53+0000\n" +"PO-Revision-Date: 2008-03-23 20:29+0000\n" +"Last-Translator: Naoko - \n" +"Language-Team: Japanese\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" + +#: ../mlvirsh/mlvirsh.ml:35 +msgid "Hypervisor connection URI" +msgstr "" + +#: ../mlvirsh/mlvirsh.ml:36 +msgid "Read-only connection" +msgstr "" + +#: ../mlvirsh/mlvirsh.ml:40 +msgid "Synopsis:\n %s [options] [command]\n\nList of all commands:\n %s help\n\nFull description of a single command:\n %s help command\n\nOptions:" +msgstr "" + diff --git a/po/virt-top.pot b/po/virt-top.pot new file mode 100644 index 0000000..0a66b9e --- /dev/null +++ b/po/virt-top.pot @@ -0,0 +1,31 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2008-03-28 13:03+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" + +#: ../mlvirsh/mlvirsh.ml:35 +msgid "Hypervisor connection URI" +msgstr "" + +#: ../mlvirsh/mlvirsh.ml:36 +msgid "Read-only connection" +msgstr "" + +#: ../mlvirsh/mlvirsh.ml:40 +msgid "Synopsis:\n %s [options] [command]\n\nList of all commands:\n %s help\n\nFull description of a single command:\n %s help command\n\nOptions:" +msgstr "" +