File tree 5 files changed +152
-0
lines changed 5 files changed +152
-0
lines changed Original file line number Diff line number Diff line change
1
+ # !/usr/bin/make -f
2
+ # -
3
+ # Application demonstration for GNU gettext in shell scripts.
4
+ # Copyright © 2015 mirabilos <[email protected] >
5
+ # Published under any OSI-approved Open Source licence.
6
+
7
+ P =itest
8
+ V =1.0
9
+
10
+ D =itest
11
+
12
+ all :
13
+
14
+ clean :
15
+ rm -rf mo po/* .pot po/* ~
16
+
17
+ all : update-translations install-translations
18
+
19
+ update-translations :
20
+ -rm -f po/$D .pot
21
+ find * -name \* .sh | xargs perl -pi -e ' s!^(TEXTDOMAIN=).*$$!$$1$D!'
22
+ find * -name \* .sh | xgettext -f - -d $D -o po/$D .pot \
23
+ -L Shell --from-code=UTF-8 --check=ellipsis-unicode \
24
+ --check=space-ellipsis --check=quote-unicode \
25
+ --sentence-end=single-space -k_ -F --foreign-user \
26
+ --package-name=$P --package-version=$V \
27
+ --msgid-bugs-address=$B
28
+ set -e; for x in po/* .po; do \
29
+ msgmerge -U " $$ x" po/$D .pot; \
30
+ done
31
+
32
+ install-translations :
33
+ rm -rf mo
34
+ set -e; for x in po/* .po; do \
35
+ l=$$ {x## */}; l=$${l%.po}; \
36
+ mkdir -p " mo/$$ l/LC_MESSAGES" ; \
37
+ msgfmt -o " mo/$$ l/LC_MESSAGES/$D .mo" " $$ x" ; \
38
+ done
39
+
40
+ .PHONY : all clean update-translations install-translations
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ # -
3
+ # Application demonstration for GNU gettext in shell scripts.
4
+ # Copyright © 2015 mirabilos <[email protected] >
5
+ # Published under any OSI-approved Open Source licence.
6
+ # -
7
+ # Call with, e.g: $ LC_ALL=de_DE.UTF-8 sh itest.sh x y z
8
+
9
+ . gettext.sh
10
+ TEXTDOMAIN=itest
11
+ TEXTDOMAINDIR=$( dirname " $0 " ) /mo
12
+ export TEXTDOMAIN TEXTDOMAINDIR
13
+
14
+ test -z " $KSH_VERSION " || echo=' print -r --'
15
+ _ () {
16
+ $echo " $( eval_gettext " $1 " ) "
17
+ }
18
+
19
+ echo Internationalised program test: language:
20
+ locale
21
+ echo
22
+
23
+ _ " Hello, World!"
24
+ _ " Five O’Clock is tea time!"
25
+
26
+ nargs=$#
27
+ $echo " $( eval_ngettext " This script was called with one argument." \
28
+ " This script was called with \$ {nargs} arguments." $nargs ) "
Original file line number Diff line number Diff line change
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version : itest 1.0\n "
4
+ "
Report-Msgid-Bugs-To :
[email protected] \n"
5
+ "POT-Creation-Date : 2015-08-28 14:20+0200\n "
6
+ "PO-Revision-Date : 2015-08-28 13:39+0200\n "
7
+ "
Last-Translator :
mirabilos <[email protected] >\n "
8
+ "Language-Team : German\n "
9
+ "Language : de\n "
10
+ "MIME-Version : 1.0\n "
11
+ "Content-Type : text/plain; charset=UTF-8\n "
12
+ "Content-Transfer-Encoding : 8bit\n "
13
+ "Plural-Forms : nplurals=2; plural=(n != 1);\n "
14
+
15
+ #: itest.sh:23
16
+ msgid "Hello, World!"
17
+ msgstr "Hallo, Welt!"
18
+
19
+ #: itest.sh:24
20
+ msgid "Five O’Clock is tea time!"
21
+ msgstr "Um fünf Uhr ist Teezeit!"
22
+
23
+ #: itest.sh:27
24
+ #, sh-format
25
+ msgid "This script was called with one argument."
26
+ msgid_plural "This script was called with ${nargs} arguments."
27
+ msgstr[ 0 ] "Dieses Skript wurde mit einem Argument aufgerufen."
28
+ msgstr[ 1 ] "Dieses Skript wurde mit ${nargs} Argumenten aufgerufen."
Original file line number Diff line number Diff line change
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version : itest 1.0\n "
4
+ "
Report-Msgid-Bugs-To :
[email protected] \n"
5
+ "POT-Creation-Date : 2015-08-28 14:20+0200\n "
6
+ "PO-Revision-Date : 2015-08-28 13:40+0200\n "
7
+ "
Last-Translator :
mirabilos <[email protected] >\n "
8
+ "Language-Team : Spanish\n "
9
+ "Language : es\n "
10
+ "MIME-Version : 1.0\n "
11
+ "Content-Type : text/plain; charset=UTF-8\n "
12
+ "Content-Transfer-Encoding : 8bit\n "
13
+ "Plural-Forms : nplurals=2; plural=(n != 1);\n "
14
+
15
+ #: itest.sh:23
16
+ msgid "Hello, World!"
17
+ msgstr "¡Hola el mundo!"
18
+
19
+ #: itest.sh:24
20
+ msgid "Five O’Clock is tea time!"
21
+ msgstr "Á las cincos hace té."
22
+
23
+ #: itest.sh:27
24
+ #, sh-format
25
+ msgid "This script was called with one argument."
26
+ msgid_plural "This script was called with ${nargs} arguments."
27
+ msgstr[ 0 ] ""
28
+ msgstr[ 1 ] ""
Original file line number Diff line number Diff line change
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version : itest 1.0\n "
4
+ "
Report-Msgid-Bugs-To :
[email protected] \n"
5
+ "POT-Creation-Date : 2015-08-28 14:20+0200\n "
6
+ "PO-Revision-Date : 2015-08-28 14:10+0200\n "
7
+ "
Last-Translator :
mirabilos <[email protected] >\n "
8
+ "Language-Team : French\n "
9
+ "Language : fr\n "
10
+ "MIME-Version : 1.0\n "
11
+ "Content-Type : text/plain; charset=UTF-8\n "
12
+ "Content-Transfer-Encoding : 8bit\n "
13
+ "Plural-Forms : nplurals=2; plural=(n > 1);\n "
14
+
15
+ #: itest.sh:23
16
+ msgid "Hello, World!"
17
+ msgstr ""
18
+
19
+ #: itest.sh:24
20
+ msgid "Five O’Clock is tea time!"
21
+ msgstr ""
22
+
23
+ #: itest.sh:27
24
+ #, sh-format
25
+ msgid "This script was called with one argument."
26
+ msgid_plural "This script was called with ${nargs} arguments."
27
+ msgstr[ 0 ] ""
28
+ msgstr[ 1 ] ""
You can’t perform that action at this time.
0 commit comments