-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.sh
executable file
·50 lines (39 loc) · 1.13 KB
/
example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# shellcheck shell=bash disable=SC2016
set -eu
. "${0%/*}/lib/i18n.sh"
export TEXTDOMAIN="sh-i18n"
export TEXTDOMAINDIR="${0%/*}/locale"
# Used in some XSI-compliant environments (e.g. OpenIndiana)
export NLSPATH="${0%/*}/locale/%l/LC_MESSAGES/%N.mo"
echo "==== Basic ===="
_ 'Hello World.'
_ 'Hello, %s.' -- Ken
echo
echo "==== Plural forms ===="
n_ 'Here is %d apple.' 'Here are %d apples.' 2
n_ '%2$s has %1$d apple.' '%2$s has %1$d apples.' 1 Ken
echo
echo "==== Using backslash escape sequences ===="
_ $'Here is a tab =>\t<=.'
_ $'It\047s a small world.\n' -n
echo
echo "==== Locale-dependent numeric values ===="
_ "The distance from the earth to the sun is %'d km." 149597870000
_ "PI is %f." 3.1415926535
echo
echo "==== Use \$'...' for msgid that begin with \$. ===="
_ $'$100 is about %\047d Japanese yen.' $((100 * 130))
echo
echo "==== sgettext and nsgettext ===="
s_ 'File|Path'
s_ 'URL|Path'
ns_ 'File|Path (%d)' 'Paths (%d)' 1
ns_ 'URL|Path (%d)' 'Paths (%d)' 2
echo
echo "==== pgettext and npgettext ===="
p_ 'File' 'Path'
p_ 'URL' 'Path'
np_ 'File' 'Path (%d)' 'Paths (%d)' 1
np_ 'URL' 'Path (%d)' 'Paths (%d)' 2
echo