]> git.madduck.net Git - etc/zsh.git/commitdiff

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:

set the locale
authormartin f. krafft <madduck@madduck.net>
Tue, 6 May 2008 09:45:05 +0000 (10:45 +0100)
committermartin f. krafft <madduck@madduck.net>
Tue, 6 May 2008 09:45:05 +0000 (10:45 +0100)
.zsh/zshrc/10_locale [new file with mode: 0644]

diff --git a/.zsh/zshrc/10_locale b/.zsh/zshrc/10_locale
new file mode 100644 (file)
index 0000000..0c69342
--- /dev/null
@@ -0,0 +1,104 @@
+# zshrc/10_locale
+#
+# Defines locale settings
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+
+_set_locale()
+{
+  export LC_CTYPE=$1
+  export LC_COLLATE=$1
+  export LC_MESSAGES=$1
+  export LC_TIME=$1
+  _set_regional_locale $1
+}
+
+_set_regional_locale()
+{
+  export LC_NUMERIC=$1
+  export LC_MONETARY=$1
+  export LC_PAPER=$1
+  export LC_NAME=$1
+  export LC_ADDRESS=$1
+  export LC_TELEPHONE=$1
+  export LC_MEASUREMENT=$1
+  export LC_IDENTIFICATION=$1
+}
+
+if [ -x =locale ]; then
+  _LOCALE="$(locale -a)"
+
+  # I prefer British English and UTF-8 over US English and non-UTF-8
+  case "$_LOCALE" in
+    *en_GB.utf8*)
+      _set_locale en_GB.UTF-8
+      export LANG=en_GB
+      ;;
+    *en_US.utf8*)
+      _set_locale en_US.UTF-8
+      export LANG=en_US
+      ;;
+    *en_GB.iso885915*)
+      _set_locale en_GB.ISO-8859-15
+      warn "no utf-8 locale available"
+      export LANG=en_GB
+      ;;
+    *en_US.iso885915*)
+      warn "no utf-8 locale available"
+      _set_locale en_US.ISO-8859-15
+      export LANG=en_US
+      ;;
+    *en_GB.iso88591*)
+      warn "no utf-8 locale available"
+      _set_locale en_GB.ISO-8859-1
+      export LANG=en_GB
+      ;;
+    *en_US.iso88591*)
+      warn "no utf-8 locale available"
+      _set_locale en_US.ISO-8859-1
+      export LANG=en_US
+      ;;
+    *en_GB*)
+      warn "no utf-8 or iso locale available"
+      _set_locale en_GB
+      export LANG=en_GB
+      ;;
+    *en_US*)
+      warn "no utf-8 or iso locale available"
+      _set_locale en_US
+      export LANG=en_US
+      ;;
+  esac
+
+  # regional stuff should be Swiss over German
+  case "$_LOCALE" in
+    *de_CH.utf8*)
+      _set_regional_locale de_CH.UTF-8
+      ;;
+    *de_CH.iso885915*)
+      _set_regional_locale de_CH.ISO-8859-15
+      ;;
+    *de_CH.iso88591*)
+      _set_regional_locale de_CH.ISO-8859-1
+      ;;
+    *de_DE.utf8*)
+      _set_regional_locale de_DE.UTF-8
+      ;;
+    *de_DE.iso885915*)
+      _set_regional_locale de_DE.ISO-8859-15
+      ;;
+    *de_DE.iso88591*)
+      _set_regional_locale de_DE.ISO-8859-1
+      ;;
+  esac
+  unset _LOCALE
+fi
+
+unfunction _set_regional_locale
+unfunction _set_locale
+
+# vim:ft=zsh