]> git.madduck.net Git - etc/zsh.git/blob - .zsh/zprofile/10-locales

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Overhaul of the entire config. Yay for big diffs.
[etc/zsh.git] / .zsh / zprofile / 10-locales
1 #
2 # Defines locale settings
3 #
4 # Copyright © 1994–2017 martin f. krafft <madduck@madduck.net>
5 # Released under the terms of the Artistic Licence 2.0
6 #
7 # Source repository: http://git.madduck.net/v/etc/zsh.git
8 #
9
10 _set_locale()
11 {
12   export LC_CTYPE=$1
13   export LC_COLLATE=$1
14   export LC_MESSAGES=$1
15   export LC_TIME=$1
16   _set_regional_locale $1
17 }
18
19 _set_regional_locale()
20 {
21   export LC_NUMERIC=$1
22   export LC_MONETARY=$1
23   export LC_PAPER=$1
24   export LC_NAME=$1
25   export LC_ADDRESS=$1
26   export LC_TELEPHONE=$1
27   export LC_MEASUREMENT=$1
28   export LC_IDENTIFICATION=$1
29 }
30
31 if [ -x =locale ]; then
32   _LOCALE="$(locale -a)"
33
34   # I prefer British English and UTF-8 over US English and non-UTF-8
35   # And if available, I'll take New Zealand-ey (yes, I love you, GIRLFRIEND)
36   case "$_LOCALE" in
37     *en_NZ.utf8*)
38       _set_locale en_NZ.UTF-8
39       export LANG=en_NZ
40       ;;
41     *en_GB.utf8*)
42       _set_locale en_GB.UTF-8
43       export LANG=en_GB
44       ;;
45     *en_US.utf8*)
46       _set_locale en_US.UTF-8
47       export LANG=en_US
48       ;;
49     *en_NZ.iso885915*)
50       _set_locale en_NZ.ISO-8859-15
51       warn "no utf-8 locale available"
52       export LANG=en_NZ
53       ;;
54     *en_GB.iso885915*)
55       _set_locale en_GB.ISO-8859-15
56       warn "no utf-8 locale available"
57       export LANG=en_GB
58       ;;
59     *en_US.iso885915*)
60       warn "no utf-8 locale available"
61       _set_locale en_US.ISO-8859-15
62       export LANG=en_US
63       ;;
64     *en_NZ.iso88591*)
65       warn "no utf-8 locale available"
66       _set_locale en_NZ.ISO-8859-1
67       export LANG=en_NZ
68       ;;
69     *en_GB.iso88591*)
70       warn "no utf-8 locale available"
71       _set_locale en_GB.ISO-8859-1
72       export LANG=en_GB
73       ;;
74     *en_US.iso88591*)
75       warn "no utf-8 locale available"
76       _set_locale en_US.ISO-8859-1
77       export LANG=en_US
78       ;;
79     *en_NZ*)
80       warn "no utf-8 or iso locale available"
81       _set_locale en_NZ
82       export LANG=en_NZ
83       ;;
84     *en_GB*)
85       warn "no utf-8 or iso locale available"
86       _set_locale en_GB
87       export LANG=en_GB
88       ;;
89     *en_US*)
90       warn "no utf-8 or iso locale available"
91       _set_locale en_US
92       export LANG=en_US
93       ;;
94   esac
95
96   # regional stuff should be German
97   case "$_LOCALE" in
98     *de_DE.utf8*)
99       _set_regional_locale de_DE.UTF-8
100       ;;
101     *de_DE.iso885915*)
102       _set_regional_locale de_DE.ISO-8859-15
103       ;;
104     *de_DE.iso88591*)
105       _set_regional_locale de_DE.ISO-8859-1
106       ;;
107     *de_CH.utf8*)
108       _set_regional_locale de_CH.UTF-8
109       ;;
110     *de_CH.iso885915*)
111       _set_regional_locale de_CH.ISO-8859-15
112       ;;
113     *de_CH.iso88591*)
114       _set_regional_locale de_CH.ISO-8859-1
115       ;;
116   esac
117   unset _LOCALE
118 fi
119
120 export LANGUAGE="${LANG}:${LANG%_*}"
121
122 unfunction _set_regional_locale
123 unfunction _set_locale
124
125 # vim:ft=zsh