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

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:

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