changeset 98449:194896c4ead7

(dos-locale-alist): New alist. (dos-codepage-setup): Use it to compute a value of locale with which to call set-locale-environment. Remove code to set terminal, keyboard, and file-name encoding (done by set-locale-environment).
author Eli Zaretskii <eliz@gnu.org>
date Wed, 01 Oct 2008 16:20:41 +0000
parents b8945a3b9fd5
children af59ad63b531
files lisp/term/internal.el
diffstat 1 files changed, 185 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/term/internal.el	Wed Oct 01 16:18:59 2008 +0000
+++ b/lisp/term/internal.el	Wed Oct 01 16:20:41 2008 +0000
@@ -409,6 +409,183 @@
 	  (setq i (1+ i) this (1+ this)))))))
 
 (defvar dos-codepage)
+(defvar dos-country-code)
+
+;; The following alist was compiled from:
+;;
+;; Ralf Brown's Interrupt List. file INTERRUP.F, D-2138, Table 01400
+;; http://www.ethnologue.com/country_index.asp (official languages)
+;; http://unicode.org/onlinedat/languages.html
+;; http://unicode.org/onlinedat/countries.html
+;;
+;; Only the official languages listed for each country.
+;;
+(defvar dos-locale-alist
+  '((  1 . "en_US")
+    (  2 . "fr_CA")
+    (  3 . "es_MX")  ; what the heck is "Latin America"?
+    (  4 . "en_CA")
+    (  7 . "ru_RU")
+    ( 20 . "ar_EG")
+    ( 27 . "af_ZA")
+    ( 30 . "el_GR")
+    ( 31 . "nl_NL")
+    ( 32 . "nl_BE")
+    ( 33 . "fr_FR")
+    ( 34 . "es_ES")
+    ( 35 . "bg_BG")
+    ( 36 . "hu_HU")
+    ( 38 . "sh_YU")
+    ( 39 . "it_IT")
+    ( 40 . "ro_RO")
+    ( 41 . "de_CH")
+    ( 42 . "cs_CZ")
+    ( 43 . "de_AT")
+    ( 44 . "en_UK")
+    ( 45 . "da_DK")
+    ( 46 . "sv_SE")
+    ( 47 . "no_NO")
+    ( 48 . "pl_PL")
+    ( 49 . "de_DE")
+    ( 51 . "es_PE")
+    ( 52 . "es_MX")
+    ( 53 . "es_CU")
+    ( 54 . "es_AR")
+    ( 55 . "pt_BR")
+    ( 56 . "es_CL")
+    ( 57 . "es_CO")
+    ( 58 . "es_VE")
+    ( 60 . "ms_MY")
+    ( 61 . "en_AU")
+    ( 62 . "id_ID")
+    ( 63 . "fil_PH")
+    ( 64 . "en_NZ")
+    ( 65 . "zh_SG")
+    ( 66 . "th_TH")
+    ( 81 . "ja_JP")
+    ( 82 . "ko_KR")
+    ( 84 . "vi_VN")
+    ( 86 . "zh_CN")
+    ( 88 . "zh_TW")
+    ( 90 . "tr_TR")
+    ( 91 . "hi_IN")
+    ( 92 . "ur_PK")
+    ( 93 . "ps_AF")
+    ( 94 . "si_LK")
+    ( 98 . "fa_IR")
+    ( 99 . "en"   )
+    (102 . "he_IL")
+    (112 . "be_BY")
+    (212 . "ar_MA")
+    (213 . "ar_DZ")
+    (216 . "ar_TN")
+    (218 . "ar_LY")
+    (220 . "en_GM")
+    (221 . "fr_SN")
+    (222 . "mey_MR")
+    (223 . "fr_ML")
+    (224 . "fr_GN")
+    (227 . "fr_NE")
+    (228 . "fr_TG")
+    (230 . "fr_MU")
+    (231 . "en_LR")
+    (232 . "en_SL")
+    (233 . "en_GH")
+    (234 . "en_NG")
+    (235 . "ar_TD")
+    (236 . "fr_CF")
+    (237 . "fr_CM")
+    (241 . "fr_GA")
+    (242 . "fr_CG")
+    (243 . "sw_ZR")
+    (244 . "pt_AO")
+    (245 . "pt_GW")
+    (249 . "ar_SD")
+    (250 . "fr_RW")
+    (251 . "am_ET")
+    (252 . "so_SO")
+    (253 . "fr_DJ")
+    (254 . "sw_KE")
+    (255 . "sw_TZ")
+    (256 . "en_UG")
+    (257 . "fr_BI")
+    (259 . "pt_MZ")
+    (260 . "en_ZM")
+    (261 . "mg_MG")
+    (263 . "en_ZW")
+    (264 . "en_NA")
+    (265 . "en_MW")
+    (266 . "st_LS")
+    (267 . "en_BW")
+    (268 . "en_SZ")
+    (299 . "kl_GL")
+    (350 . "en_GI")
+    (351 . "pt_PT")
+    (352 . "fr_LU")
+    (353 . "ga_IE")
+    (354 . "is_IS")
+    (355 . "sq_AL")
+    (356 . "mt_MT")
+    (357 . "gr_CY")
+    (358 . "fi_FI")
+    (359 . "bg_BG")
+    (370 . "lt_LT")
+    (371 . "lv_LV")
+    (372 . "et_EE")
+    (373 . "mo_MD")
+    (380 . "uk_UA")
+    (381 . "sr_RS")
+    (384 . "hr_HR")
+    (385 . "hr_HR")
+    (386 . "sl_SI")
+    (387 . "bs_BA")
+    (388 . "sr_BA")
+    (389 . "mk_MK")
+    (421 . "cs_CZ")
+    (422 . "sk_SK")
+    (502 . "es_GT")
+    (503 . "es_SV")
+    (504 . "es_HN")
+    (505 . "es_NI")
+    (506 . "es_CR")
+    (507 . "es_PA")
+    (509 . "ht_HT")
+    (590 . "fr_GP")
+    (591 . "es_BO")
+    (592 . "en_GY")
+    (593 . "es_EC")
+    (594 . "fr_GF")
+    (595 . "gn_PY")
+    (596 . "fr_MQ")
+    (597 . "nl_SR")
+    (598 . "es_UY")
+    (785 . "ar"   )
+    (804 . "uk_UA")
+    (850 . "ko_KP")
+    (855 . "km_KH")
+    (856 . "lo_LA")
+    (880 . "bn_BD")
+    (886 . "zh_TW")
+    (960 . "dv_MV")
+    (961 . "ar_LB")
+    (962 . "ar_JO")
+    (963 . "ar_SY")
+    (964 . "ar_IQ")
+    (965 . "ar_KW")
+    (966 . "ar_SA")
+    (967 . "ar_YE")
+    (968 . "ar_OM")
+    (969 . "ar_YE")
+    (971 . "ar_AE")
+    (972 . "he_IL")
+    (973 . "ar_BH")
+    (974 . "ar_QA")
+    (975 . "dz_BT")
+    (976 . "mn_MN")
+    (977 . "ne_NP")
+    (995 . "my_MM")
+    )
+    "Alist of MS-DOS country codes and the corresponding locale names.")
 
 (defun dos-codepage-setup ()
   "Set up multilingual environment for the installed DOS codepage.
@@ -417,19 +594,19 @@
 environment options as appropriate for the current value of `dos-codepage'.
 
 This function is automatically run at startup via the `after-init-hook'
-list.  You can (and should) also run it whenever the value of
+list.  You can (and should) also run it if and when the value of
 `dos-codepage' changes."
   (interactive)
-  (let* ((coding (format "cp%s" dos-codepage))
-	 coding-dos coding-unix)
+  (let ((locale (cdr (assq dos-country-code dos-locale-alist)))
+	(coding (format "cp%s" dos-codepage))
+	coding-dos coding-unix)
     (setq coding-dos (intern (format "%s-dos" coding))
 	  coding-unix (intern (format "%s-unix" coding)))
-    ;(set-language-environment lang) FIXME
-    (set-default-coding-systems coding-dos)
+    (setq locale (if locale
+		     (format "%s.cp%s" locale dos-codepage)
+		   "en_US.cp437"))
+    (set-locale-environment locale)
     (set-selection-coding-system coding-dos)
-    (setq file-name-coding-system coding-unix)
-    (set-terminal-coding-system
-     (setq default-terminal-coding-system coding-unix))
     (IT-setup-unicode-display coding-unix)
     (prefer-coding-system coding-dos)
     (and default-enable-multibyte-characters