summaryrefslogtreecommitdiffstats
path: root/src/boost/tools/build/example/gettext
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/tools/build/example/gettext')
-rw-r--r--src/boost/tools/build/example/gettext/jamfile.jam26
-rw-r--r--src/boost/tools/build/example/gettext/jamroot.jam6
-rw-r--r--src/boost/tools/build/example/gettext/main.cpp28
-rw-r--r--src/boost/tools/build/example/gettext/readme.txt24
-rw-r--r--src/boost/tools/build/example/gettext/russian.po21
5 files changed, 105 insertions, 0 deletions
diff --git a/src/boost/tools/build/example/gettext/jamfile.jam b/src/boost/tools/build/example/gettext/jamfile.jam
new file mode 100644
index 000000000..c2a5e9bef
--- /dev/null
+++ b/src/boost/tools/build/example/gettext/jamfile.jam
@@ -0,0 +1,26 @@
+# Copyright 2003, 2006 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
+
+
+# Declare a main target.
+exe main : main.cpp ;
+
+# Declare an action for updating translations
+# After changing main.cpp, invocation of
+#
+# bjam update-russian
+#
+# will update translations in russian.po
+gettext.update update-russian : russian.po main ;
+
+# Compiled message catalog.
+gettext.catalog russian : russian.po ;
+
+# A stage rule which installs message catalog to the
+# location gettext expects.
+stage messages-russian : russian
+ : <location>messages/ru_RU.KOI8-R/LC_MESSAGES
+ <name>main.mo
+ ;
+
diff --git a/src/boost/tools/build/example/gettext/jamroot.jam b/src/boost/tools/build/example/gettext/jamroot.jam
new file mode 100644
index 000000000..14f87bb78
--- /dev/null
+++ b/src/boost/tools/build/example/gettext/jamroot.jam
@@ -0,0 +1,6 @@
+# Copyright 2003 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
+
+
+using gettext ;
diff --git a/src/boost/tools/build/example/gettext/main.cpp b/src/boost/tools/build/example/gettext/main.cpp
new file mode 100644
index 000000000..c44d02a81
--- /dev/null
+++ b/src/boost/tools/build/example/gettext/main.cpp
@@ -0,0 +1,28 @@
+// Copyright Vladimir Prus 2003.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE.txt
+// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
+
+
+#include <locale.h>
+#include <libintl.h>
+#define i18n(s) gettext(s)
+
+#include <iostream>
+using namespace std;
+
+int main()
+{
+ // Specify that translations are stored in directory
+ // "messages".
+ bindtextdomain("main", "messages");
+ textdomain("main");
+
+ // Switch to russian locale.
+ setlocale(LC_MESSAGES, "ru_RU.KOI8-R");
+
+ // Output localized message.
+ std::cout << i18n("hello") << "\n";
+
+ return 0;
+}
diff --git a/src/boost/tools/build/example/gettext/readme.txt b/src/boost/tools/build/example/gettext/readme.txt
new file mode 100644
index 000000000..097e49b69
--- /dev/null
+++ b/src/boost/tools/build/example/gettext/readme.txt
@@ -0,0 +1,24 @@
+Copyright 2003 Vladimir Prus
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+
+This example shows how it is possible to use GNU gettext utilities with
+B2.
+
+A simple translation file is compiled and installed as message catalog for
+russian. The main application explicitly switches to russian locale and outputs
+the translation of "hello".
+
+To test:
+
+ bjam
+ bin/gcc/debug/main
+
+To test even more:
+
+ - add more localized strings to "main.cpp"
+ - run "bjam update-russian"
+ - edit "russian.po"
+ - run bjam
+ - run "main"
diff --git a/src/boost/tools/build/example/gettext/russian.po b/src/boost/tools/build/example/gettext/russian.po
new file mode 100644
index 000000000..daa7121c3
--- /dev/null
+++ b/src/boost/tools/build/example/gettext/russian.po
@@ -0,0 +1,21 @@
+# 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 <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2003-07-01 15:45+0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: main.cpp:16
+msgid "hello"
+msgstr "international hello"