commit b67ac0ec289760b95646d60a5b8f8707d0748c57 Author: Ahmed Siam Date: Mon Aug 21 06:03:33 2023 +0300 i18n patch 1 diff --git a/.gitignore b/.gitignore index d16ffc9..b432bf1 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,10 @@ src/*.o src/lsx-comp src/lsx-proc *.pyc + +/.vscode/ +/locales/Makefile +/locales/Makefile.in +*.res +*.dat +/configure~ diff --git a/Makefile.am b/Makefile.am index b3c756f..48f33e8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,13 @@ pkgconfigdir = $(libdir)/pkgconfig dist_pkgconfig_DATA = apertium-separable.pc -SUBDIRS = src +SUBDIRS = src locales EXTRA_DIST=autogen.sh test: (cd tests; ./run_tests.py) + +export LTTB_I18N_DATA=$(datadir)/lttoolbox/lttoolbox.dat +export LOCALES_DIR=$(datadir)/$(PACKAGE_NAME) +export APSP_I18N_DATA=$(LOCALES_DIR)/apsp.dat diff --git a/README.md b/README.md deleted file mode 120000 index 100b938..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -README \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..da4b466 Binary files /dev/null and b/README.md differ diff --git a/configure.ac b/configure.ac index 8467aa9..903fb79 100644 --- a/configure.ac +++ b/configure.ac @@ -23,6 +23,7 @@ AC_ARG_ENABLE(debug, esac]) PKG_CHECK_MODULES([LTTOOLBOX], [lttoolbox >= required_lttoolbox_version]) +PKG_CHECK_MODULES(I18N, [i18n], CPPFLAGS="$CPPFLAGS $I18N_CFLAGS"; LIBS="$LIBS $I18N_LIBS") AC_SUBST(LTTOOLBOX_CFLAGS) AC_SUBST(LTTOOLBOX_LIBS) @@ -62,5 +63,6 @@ AC_CONFIG_FILES([ apertium-separable.pc Makefile src/Makefile + locales/Makefile ]) AC_OUTPUT diff --git a/locales/Makefile.am b/locales/Makefile.am new file mode 100644 index 0000000..4c4d40c --- /dev/null +++ b/locales/Makefile.am @@ -0,0 +1,7 @@ +apsp.dat: root.txt en.txt + genrb -d . root.txt en.txt + echo root.res en.res > package_list.txt + pkgdata -p apsp --mode archive -d . package_list.txt + +localesdir = $(LOCALES_DIR) +dist_locales_DATA = apsp.dat diff --git a/locales/en.txt b/locales/en.txt new file mode 100644 index 0000000..0bd10e4 --- /dev/null +++ b/locales/en.txt @@ -0,0 +1,2 @@ +en{ +} \ No newline at end of file diff --git a/locales/package_list.txt b/locales/package_list.txt new file mode 100644 index 0000000..d5134dd --- /dev/null +++ b/locales/package_list.txt @@ -0,0 +1 @@ +root.res en.res diff --git a/locales/root.txt b/locales/root.txt new file mode 100644 index 0000000..e3b823b --- /dev/null +++ b/locales/root.txt @@ -0,0 +1,8 @@ +root{ + lsx_proc_desc{"re-tokenize a stream"} + postgen_desc{"act as a postgenerator"} + repeat_desc{"continue applying rules until they match"} + dictionary_case_desc{"use dictionary case instead of surface case"} + null_flush_desc{"flush output on the null character"} + help_desc{"print this message and exit"} +} diff --git a/src/Makefile.am b/src/Makefile.am index 68d8f23..6eea86d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,4 +4,6 @@ bin_PROGRAMS = lsx-proc lsx_proc_SOURCES = lsx_processor.cc lsx_proc.cc +AM_CPPFLAGS = -DAPSP_I18N_DATA='"$(APSP_I18N_DATA)"' -DLTTB_I18N_DATA='"$(LTTB_I18N_DATA)"' + EXTRA_DIST = lsx_compiler.h diff --git a/src/lsx_proc.cc b/src/lsx_proc.cc index 044c320..a613b7d 100644 --- a/src/lsx_proc.cc +++ b/src/lsx_proc.cc @@ -1,6 +1,7 @@ #include #include #include +#include #include "lsx_processor.h" @@ -8,13 +9,14 @@ using namespace std; int main (int argc, char** argv) { + I18n i18n {APSP_I18N_DATA, "apsp"}; LtLocale::tryToSetLocale(); - CLI cli("re-tokenize a stream", PACKAGE_VERSION); - cli.add_bool_arg('p', "postgen", "act as a postgenerator"); - cli.add_bool_arg('r', "repeat", "continue applying rules until they match"); - cli.add_bool_arg('w', "dictionary-case", "use dictionary case instead of surface case"); - cli.add_bool_arg('z', "null-flush", "flush output on the null character"); - cli.add_bool_arg('h', "help", "print this message and exit"); + CLI cli(i18n.format("lsx_proc_desc"), PACKAGE_VERSION); + cli.add_bool_arg('p', "postgen", i18n.format("postgen_desc")); + cli.add_bool_arg('r', "repeat", i18n.format("repeat_desc")); + cli.add_bool_arg('w', "dictionary-case", i18n.format("dictionary_case_desc")); + cli.add_bool_arg('z', "null-flush", i18n.format("null_flush_desc")); + cli.add_bool_arg('h', "help", i18n.format("help_desc")); cli.add_file_arg("fst_file", false); cli.add_file_arg("input_file", true); cli.add_file_arg("output_file", true);