bug-libunistring
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-libunistring] libunistring: translating long names


From: Daiki Ueno
Subject: [bug-libunistring] libunistring: translating long names
Date: Wed, 18 Feb 2015 17:22:59 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Hello,

Since libunistring 0.9.4, a few functions have been added to retrieve
human-readable names of certain character properties.  For example,
uc_combining_class_long_name(UC_CCC_NR) returns "Not Reordered".

It would be nice if those strings are presented in user's native
language on client applications, but translating those in each
application would be too much effort.  I'm thinking if it is feasible to
gettextize libunistring and distribute PO/MO files.

The attached is an experimental patch.  When building, it create the
'pot-gen' program which produces an intermidiate POT file.  And then it
will be processed through the normal gettext po/ infrastructure.

If possible, I'd like to use the Translation Project (Cc'ed the
coordinator, also a generated POT file is attached for reference).

Comments and suggestions would be appreciated.

Thanks,
--
Daiki Ueno
>From a451e39f2592215e2a25ca100e5a9344a1963475 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <address@hidden>
Date: Wed, 18 Feb 2015 16:52:47 +0900
Subject: [PATCH] build: use gettext to translate long names

* Makefile.am (SUBDIRS): Add po.
* autogen.sh: Call 'autopoint --force'.
* configure.ac: Invoke AM_GNU_GETTEXT and AM_GNU_GETTEXT_VERSION.
* lib/Makefile.am (libunistring.pot): New rule.
(noinst_PROGRAMS): New variable.
(pot_gen_SOURCES): New variable.
(pot_gen_LDADD): New variable.
* lib/pot-gen.c: New file.
* po/Makevars: New file.
* po/POTFILES.in: New file.
---
 ChangeLog       |  14 ++++++
 Makefile.am     |   2 +-
 autogen.sh      |   1 +
 configure.ac    |   4 ++
 lib/Makefile.am |   8 ++++
 lib/pot-gen.c   | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 po/Makevars     |  78 ++++++++++++++++++++++++++++++
 po/POTFILES.in  |   1 +
 8 files changed, 251 insertions(+), 1 deletion(-)
 create mode 100644 lib/pot-gen.c
 create mode 100644 po/Makevars
 create mode 100644 po/POTFILES.in

diff --git a/ChangeLog b/ChangeLog
index 08d992f..ec6ff38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2015-02-18  Daiki Ueno  <address@hidden>
+
+       build: use gettext to translate long names
+       * Makefile.am (SUBDIRS): Add po.
+       * autogen.sh: Call 'autopoint --force'.
+       * configure.ac: Invoke AM_GNU_GETTEXT and AM_GNU_GETTEXT_VERSION.
+       * lib/Makefile.am (libunistring.pot): New rule.
+       (noinst_PROGRAMS): New variable.
+       (pot_gen_SOURCES): New variable.
+       (pot_gen_LDADD): New variable.
+       * lib/pot-gen.c: New file.
+       * po/Makevars: New file.
+       * po/POTFILES.in: New file.
+
 2015-02-16  Daiki Ueno  <address@hidden>
 
        * Version 0.9.5 released.
diff --git a/Makefile.am b/Makefile.am
index 91c0bf3..19db1b9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,7 +20,7 @@ AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies
 ACLOCAL = build-aux/fixaclocal @ACLOCAL@
 ACLOCAL_AMFLAGS = -I m4 -I gnulib-m4
 
-SUBDIRS = doc gnulib-local lib tests
+SUBDIRS = doc gnulib-local lib po tests
 
 EXTRA_DIST = \
   version.sh BUGS DEPENDENCIES HACKING autogen.sh \
diff --git a/autogen.sh b/autogen.sh
index f558615..c29bded 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -456,6 +456,7 @@ if test $skip_gnulib = false; then
   fi
 fi
 
+autopoint --force
 build-aux/fixaclocal aclocal -I m4 -I gnulib-m4
 autoconf
 autoheader && touch config.h.in
diff --git a/configure.ac b/configure.ac
index 38fe5dd..13e21a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,6 +148,9 @@ AC_PATH_PROG([TEXI2DVI], [texi2dvi], 
[$ac_aux_dir_abs/missing texi2dvi])
 AC_PATH_PROG([DVIPS], [dvips], [$ac_aux_dir_abs/missing dvips])
 AC_PATH_PROG([PERL], [perl], [$ac_aux_dir_abs/missing perl])
 
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION([0.19.4])
+
 AC_CONFIG_FILES([Makefile])
 AC_CONFIG_FILES([doc/Makefile])
 AC_CONFIG_FILES([gnulib-local/Makefile])
@@ -155,5 +158,6 @@ AC_CONFIG_FILES([lib/Makefile])
 AC_CONFIG_FILES([lib/exported.sh])
 AC_CONFIG_FILES([lib/unistring/version.h:lib/unistring/version.in.h])
 AC_CONFIG_FILES([lib/unistring/woe32dll.h:lib/unistring/woe32dll.in.h])
+AC_CONFIG_FILES([po/Makefile.in])
 AC_CONFIG_FILES([tests/Makefile])
 AC_OUTPUT
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 265ff46..26384b6 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -319,3 +319,11 @@ LTV_AGE=0
 libunistring_la_LDFLAGS += \
   -version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \
   -rpath $(libdir)
+
+# How to build libunistring.pot.
+noinst_PROGRAMS = pot-gen
+pot_gen_SOURCES = pot-gen.c
+pot_gen_LDADD = libunistring.la
+
+libunistring.pot: pot-gen
+       $(AM_V_GEN) $(builddir)/pot-gen > $@
diff --git a/lib/pot-gen.c b/lib/pot-gen.c
new file mode 100644
index 0000000..1213503
--- /dev/null
+++ b/lib/pot-gen.c
@@ -0,0 +1,144 @@
+/* Generate POT file for GNU libunistring.
+   Copyright (C) 2015 Free Software Foundation, Inc.
+   Written by Daiki Ueno <address@hidden, 2015.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation; either version 3 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <unictype.h>
+
+int
+main (int argc, char **argv)
+{
+  const uc_script_t *scripts;
+  const uc_block_t *blocks;
+  size_t count, i;
+  const char *context = "";
+
+#define PAIR(str) \
+      printf ("\
+msgctxt \"%s\"\n\
+msgid \"%s\"\n\
+msgstr \"\"\n\n", context, str)
+
+  context = "general category";
+  PAIR (uc_general_category_long_name (UC_CATEGORY_L));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_LC));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Lu));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Ll));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Lt));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Lm));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Lo));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_M));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Mn));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Mc));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Me));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_N));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Nd));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Nl));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_No));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_P));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Pc));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Pd));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Ps));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Pe));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Pi));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Pf));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Po));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_S));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Sm));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Sc));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Sk));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_So));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Z));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Zs));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Zl));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Zp));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_C));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Cc));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Cf));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Cs));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Co));
+  PAIR (uc_general_category_long_name (UC_CATEGORY_Cn));
+
+  context = "combining class";
+  PAIR (uc_combining_class_long_name (UC_CCC_NR));
+  PAIR (uc_combining_class_long_name (UC_CCC_OV));
+  PAIR (uc_combining_class_long_name (UC_CCC_NK));
+  PAIR (uc_combining_class_long_name (UC_CCC_KV));
+  PAIR (uc_combining_class_long_name (UC_CCC_VR));
+  PAIR (uc_combining_class_long_name (UC_CCC_ATBL));
+  PAIR (uc_combining_class_long_name (UC_CCC_ATB));
+  PAIR (uc_combining_class_long_name (UC_CCC_ATA));
+  PAIR (uc_combining_class_long_name (UC_CCC_ATAR));
+  PAIR (uc_combining_class_long_name (UC_CCC_BL));
+  PAIR (uc_combining_class_long_name (UC_CCC_B));
+  PAIR (uc_combining_class_long_name (UC_CCC_BR));
+  PAIR (uc_combining_class_long_name (UC_CCC_L));
+  PAIR (uc_combining_class_long_name (UC_CCC_R));
+  PAIR (uc_combining_class_long_name (UC_CCC_AL));
+  PAIR (uc_combining_class_long_name (UC_CCC_A));
+  PAIR (uc_combining_class_long_name (UC_CCC_AR));
+  PAIR (uc_combining_class_long_name (UC_CCC_DB));
+  PAIR (uc_combining_class_long_name (UC_CCC_DA));
+  PAIR (uc_combining_class_long_name (UC_CCC_IS));
+
+  context = "bidi class";
+  PAIR (uc_bidi_class_long_name (UC_BIDI_L));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_LRE));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_LRO));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_R));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_AL));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_RLE));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_RLO));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_PDF));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_EN));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_ES));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_ET));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_AN));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_CS));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_NSM));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_BN));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_B));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_S));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_WS));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_ON));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_LRI));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_RLI));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_FSI));
+  PAIR (uc_bidi_class_long_name (UC_BIDI_PDI));
+
+  context = "joining type";
+  PAIR (uc_joining_type_long_name (UC_JOINING_TYPE_U));
+  PAIR (uc_joining_type_long_name (UC_JOINING_TYPE_T));
+  PAIR (uc_joining_type_long_name (UC_JOINING_TYPE_C));
+  PAIR (uc_joining_type_long_name (UC_JOINING_TYPE_L));
+  PAIR (uc_joining_type_long_name (UC_JOINING_TYPE_R));
+  PAIR (uc_joining_type_long_name (UC_JOINING_TYPE_D));
+
+  context = "script";
+  uc_all_scripts (&scripts, &count);
+  for (i = 0; i < count; i++)
+    PAIR (scripts[i].name);
+
+  context = "block";
+  uc_all_blocks (&blocks, &count);
+  for (i = 0; i < count; i++)
+    PAIR (blocks[i].name);
+#undef PAIR
+
+  return 0;
+}
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000..0648ec7
--- /dev/null
+++ b/po/Makevars
@@ -0,0 +1,78 @@
+# Makefile variables for PO directory in any package using GNU gettext.
+
+# Usually the message domain is the same as the package name.
+DOMAIN = $(PACKAGE)
+
+# These two variables depend on the location of this directory.
+subdir = po
+top_builddir = ..
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
+# package.  (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.)  Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright.  The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+COPYRIGHT_HOLDER = Free Software Foundation, Inc.
+
+# This tells whether or not to prepend "GNU " prefix to the package
+# name that gets inserted into the header of the $(DOMAIN).pot file.
+# Possible values are "yes", "no", or empty.  If it is empty, try to
+# detect it automatically by scanning the files in $(top_srcdir) for
+# "GNU packagename" string.
+PACKAGE_GNU =
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+#   in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+#   understood.
+# - Strings which make invalid assumptions about notation of date, time or
+#   money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS =
+
+# This is the list of locale categories, beyond LC_MESSAGES, for which the
+# message catalogs shall be used.  It is usually empty.
+EXTRA_LOCALE_CATEGORIES =
+
+# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
+# context.  Possible values are "yes" and "no".  Set this to yes if the
+# package uses functions taking also a message context, like pgettext(), or
+# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
+USE_MSGCTXT = no
+
+# These options get passed to msgmerge.
+# Useful options are in particular:
+#   --previous            to keep previous msgids of translated messages,
+#   --quiet               to reduce the verbosity.
+MSGMERGE_OPTIONS =
+
+# These options get passed to msginit.
+# If you want to disable line wrapping when writing PO files, add
+# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and
+# MSGINIT_OPTIONS.
+MSGINIT_OPTIONS =
+
+# This tells whether or not to regenerate a PO file when $(DOMAIN).pot
+# has changed.  Possible values are "yes" and "no".  Set this to no if
+# the POT file is checked in the repository and the version control
+# program ignores timestamps.
+PO_DEPENDS_ON_POT = yes
+
+# This tells whether or not to forcibly update $(DOMAIN).pot and
+# regenerate PO files on "make dist".  Possible values are "yes" and
+# "no".  Set this to no if the POT file and PO files are maintained
+# externally.
+DIST_DEPENDS_ON_UPDATE_PO = yes
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..4e75fad
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1 @@
+lib/libunistring.pot
-- 
2.1.0

Attachment: libunistring.pot.gz
Description: application/gzip


reply via email to

[Prev in Thread] Current Thread [Next in Thread]