]> 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:

limit fonts
[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: http://git.madduck.net/v/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   case "$_LOCALE" in
37     *en_GB.utf8*)
38       _set_locale en_GB.UTF-8
39       export LANG=en_GB
40       ;;
41     *en_US.utf8*)
42       _set_locale en_US.UTF-8
43       export LANG=en_US
44       ;;
45     *en_GB.iso885915*)
46       _set_locale en_GB.ISO-8859-15
47       warn "no utf-8 locale available"
48       export LANG=en_GB
49       ;;
50     *en_US.iso885915*)
51       warn "no utf-8 locale available"
52       _set_locale en_US.ISO-8859-15
53       export LANG=en_US
54       ;;
55     *en_GB.iso88591*)
56       warn "no utf-8 locale available"
57       _set_locale en_GB.ISO-8859-1
58       export LANG=en_GB
59       ;;
60     *en_US.iso88591*)
61       warn "no utf-8 locale available"
62       _set_locale en_US.ISO-8859-1
63       export LANG=en_US
64       ;;
65     *en_GB*)
66       warn "no utf-8 or iso locale available"
67       _set_locale en_GB
68       export LANG=en_GB
69       ;;
70     *en_US*)
71       warn "no utf-8 or iso locale available"
72       _set_locale en_US
73       export LANG=en_US
74       ;;
75   esac
76
77   # regional stuff should be Swiss over German
78   case "$_LOCALE" in
79     *de_CH.utf8*)
80       _set_regional_locale de_CH.UTF-8
81       ;;
82     *de_CH.iso885915*)
83       _set_regional_locale de_CH.ISO-8859-15
84       ;;
85     *de_CH.iso88591*)
86       _set_regional_locale de_CH.ISO-8859-1
87       ;;
88     *de_DE.utf8*)
89       _set_regional_locale de_DE.UTF-8
90       ;;
91     *de_DE.iso885915*)
92       _set_regional_locale de_DE.ISO-8859-15
93       ;;
94     *de_DE.iso88591*)
95       _set_regional_locale de_DE.ISO-8859-1
96       ;;
97   esac
98   unset _LOCALE
99 fi
100
101 export LANGUAGE="${LANG}:en"
102
103 unfunction _set_regional_locale
104 unfunction _set_locale
105
106 # vim:ft=zsh