#!/bin/sh

vdir=$(dirname $0)
. $vdir/vasm-functions

check_root

T_PX="$ROOT"
LANG_CONF=$T_PX/etc/profile.d/lang.sh

function set_locale()
{
  LOCALE=$1
  perl -i -pwnle "s/=.*$/=$LOCALE/ if /^export LANG/" $LANG_CONF
}

function menu_locale()
{
  $DCMD --backtitle "$BACKTITLE" --title "LOCALE CONFIGURATION" \
  --default-item "$LANG" \
  --menu "\n
The language used by programs on your system is usually determined
by the LANG environment variable, set in /etc/profile/lang.sh.
Choose an appropriate locale value for your language.\n
Note: all 'Euro' locales use the ISO-8859-15 character set." 18 70 7 \
"aa_DJ" "Afar (Djibouti, CaduLaaqo Dialects)" \
"aa_DJ.utf8" "Afar (Djibouti, CaduLaaqo Dialects, Unicode)" \
"aa_ER" "Afar (Eritrea, CaduLaaqo Dialects)" \
"aa_ER@saaho" "Afar (Eritrea, Saaho Dialect)" \
"aa_ET" "Afar (Ethiopia, CaduCarra Dialects)" \
"af_ZA" "Afrikaans (South Africa)" \
"af_ZA.utf8" "Afrikaans (South Africa, Unicode)" \
"am_ET" "Amharic (Ethiopia)" \
"an_ES" "Aragonese (Spain)" \
"an_ES.utf8" "Aragonese (Spain, Unicode)" \
"ar_AE" "Arabic (United Arab Emirates)" \
"ar_AE.utf8" "Arabic (United Arab Emirates, Unicode)" \
"ar_BH" "Arabic (Bahrain)" \
"ar_BH.utf8" "Arabic (Bahrain, Unicode)" \
"ar_DZ" "Arabic (Algeria)" \
"ar_DZ.utf8" "Arabic (Algeria, Unicode)" \
"ar_EG" "Arabic (Egypt)" \
"ar_EG.utf8" "Arabic (Egypt, Unicode)" \
"ar_IN" "Arabic (India)" \
"ar_IQ" "Arabic (Iraq)" \
"ar_IQ.utf8" "Arabic (Iraq, Unicode)" \
"ar_JO" "Arabic (Jordan)" \
"ar_JO.utf8" "Arabic (Jordan, Unicode)" \
"ar_KW" "Arabic (Kuwait)" \
"ar_KW.utf8" "Arabic (Kuwait, Unicode)" \
"ar_LB" "Arabic (Lebanon)" \
"ar_LB.utf8" "Arabic (Lebanon, Unicode)" \
"ar_LY" "Arabic (Libyan Arab Jamahiriya)" \
"ar_LY.utf8" "Arabic (Libyan Arab Jamahiriya, Unicode)" \
"ar_MA" "Arabic (Morocco)" \
"ar_MA.utf8" "Arabic (Morocco, Unicode)" \
"ar_OM" "Arabic (Oman)" \
"ar_OM.utf8" "Arabic (Oman, Unicode)" \
"ar_QA" "Arabic (Qatar)" \
"ar_QA.utf8" "Arabic (Qatar, Unicode)" \
"ar_SA" "Arabic (Saudi Arabia)" \
"ar_SA.utf8" "Arabic (Saudi Arabia, Unicode)" \
"ar_SD" "Arabic (Sudan)" \
"ar_SD.utf8" "Arabic (Sudan, Unicode)" \
"ar_SY" "Arabic (Syrian Arab Republic)" \
"ar_SY.utf8" "Arabic (Syrian Arab Republic, Unicode)" \
"ar_TN" "Arabic (Tunisia)" \
"ar_TN.utf8" "Arabic (Tunisia, Unicode)" \
"ar_YE" "Arabic (Yemen)" \
"ar_YE.utf8" "Arabic (Yemen, Unicode)" \
"as_IN.utf8" "Assamese (India, Unicode)" \
"az_AZ.utf8" "Azeri (Azerbaijan, Unicode, Latin)" \
"be_BY" "Belarusian (Belarus)" \
"be_BY.utf8" "Belarusian (Belarus, Unicode)" \
"be_BY@latin" "Belarusian (Belarus, Unicode, Latin)" \
"bg_BG" "Bulgarian (Bulgaria)" \
"bg_BG.utf8" "Bulgarian (Bulgaria, Unicode)" \
"bn_BD" "Bengali (Bangladesh)" \
"bn_IN" "Bengali (India)" \
"br_FR" "Breton (France)" \
"br_FR.utf8" "Breton (France, Unicode)" \
"br_FR@euro" "Breton (France, with Euro)" \
"bs_BA" "Bosnian (Bosnia and Herzegowina)" \
"bs_BA.utf8" "Bosnian (Bosnia and Herzegowina, Unicode)" \
"byn_ER" "Blin (Eritrea, Unicode)" \
"ca_AD" "Catalan (Andorra)" \
"ca_AD.utf8" "Catalan (Andorra, Unicode)" \
"ca_ES" "Catalan (Spain)" \
"ca_ES.utf8" "Catalan (Spain, Unicode)" \
"ca_ES@euro" "Catalan (Catalonia, with Euro)" \
"ca_FR" "Catalan (France)" \
"ca_FR.utf8" "Catalan (France, Unicode)" \
"ca_IT" "Catalan (Italy (L'Alguer))" \
"ca_IT.utf8" "Catalan (Italy (L'Alguer), Unicode)" \
"cs_CZ" "Czech (Czech Republic)" \
"cs_CZ.utf8" "Czech (Czech Republic, Unicode)" \
"csb_PL" "Kashubian (Poland, Unicode)" \
"cy_GB" "Welsh (Great Britain)" \
"cy_GB.utf8" "Welsh (Great Britain, Unicode)" \
"da_DK" "Danish (Denmark)" \
"da_DK.utf8" "Danish (Denmark, Unicode)" \
"de_AT" "German (Austria)" \
"de_AT.utf8" "German (Austria, Unicode)" \
"de_AT@euro" "German (Austria, with Euro)" \
"de_BE" "German (Belgium)" \
"de_BE.utf8" "German (Belgium, Unicode)" \
"de_BE@euro" "German (Belgium, with Euro)" \
"de_CH" "German (Switzerland)" \
"de_CH.utf8" "German (Switzerland, Unicode)" \
"de_DE" "German (Germany)" \
"de_DE.utf8" "German (Germany, Unicode)" \
"de_DE@euro" "German (Germany, with Euro)" \
"de_LU" "German (Luxemburg)" \
"de_LU.utf8" "German (Luxemburg, Unicode)" \
"de_LU@euro" "German (Luxemburg, with Euro)" \
"dz_BT" "Dzongkha (Bhutan)" \
"el_CY" "Greek (Cyprus)" \
"el_CY.utf8" "Greek (Cyprus, Unicode)" \
"el_GR" "Greek (Greece)" \
"el_GR.utf8" "Greek (Greece, Unicode)" \
"en_AU" "English (Australia)" \
"en_AU.utf8" "English (Australia, Unicode)" \
"en_BW" "English (Botswana)" \
"en_BW.utf8" "English (Botswana, Unicode)" \
"en_CA" "English (Canada)" \
"en_CA.utf8" "English (Canada, Unicode)" \
"en_DK" "English (Denmark)" \
"en_DK.utf8" "English (Denmark, Unicode)" \
"en_GB" "English (Britain)" \
"en_GB.utf8" "English (Britain, Unicode)" \
"en_HK" "English (Hong Kong)" \
"en_HK.utf8" "English (Hong Kong, Unicode)" \
"en_IE" "English (Ireland)" \
"en_IE.utf8" "English (Ireland, Unicode)" \
"en_IE@euro" "English (Ireland, with Euro)" \
"en_IN" "English (India)" \
"en_NZ" "English (New Zealand)" \
"en_NZ.utf8" "English (New Zealand, Unicode)" \
"en_PH" "English (Philippines)" \
"en_PH.utf8" "English (Philippines, Unicode)" \
"en_SG" "English (Singapore)" \
"en_SG.utf8" "English (Singapore, Unicode)" \
"en_US" "English (USA)" \
"en_US.utf8" "English (USA, Unicode)" \
"en_ZA" "English (South Africa)" \
"en_ZA.utf8" "English (South Africa, Unicode)" \
"en_ZW" "English (Zimbabwe)" \
"en_ZW.utf8" "English (Zimbabwe, Unicode)" \
"es_AR" "Spanish (Argentina)" \
"es_AR.utf8" "Spanish (Argentina, Unicode)" \
"es_BO" "Spanish (Bolivia)" \
"es_BO.utf8" "Spanish (Bolivia, Unicode)" \
"es_CL" "Spanish (Chile)" \
"es_CL.utf8" "Spanish (Chile, Unicode)" \
"es_CO" "Spanish (Colombia)" \
"es_CO.utf8" "Spanish (Colombia, Unicode)" \
"es_CR" "Spanish (Costa Rica)" \
"es_CR.utf8" "Spanish (Costa Rica, Unicode)" \
"es_DO" "Spanish (Dominican Republic)" \
"es_DO.utf8" "Spanish (Dominican Republic, Unicode)" \
"es_EC" "Spanish (Ecuador)" \
"es_EC.utf8" "Spanish (Ecuador, Unicode)" \
"es_ES" "Spanish (Spain)" \
"es_ES.utf8" "Spanish (Spain, Unicode)" \
"es_ES@euro" "Spanish (Spain, with Euro)" \
"es_GT" "Spanish (Guatemala)" \
"es_GT.utf8" "Spanish (Guatemala, Unicode)" \
"es_HN" "Spanish (Honduras)" \
"es_HN.utf8" "Spanish (Honduras, Unicode)" \
"es_MX" "Spanish (Mexico)" \
"es_MX.utf8" "Spanish (Mexico, Unicode)" \
"es_NI" "Spanish (Nicaragua)" \
"es_NI.utf8" "Spanish (Nicaragua, Unicode)" \
"es_PA" "Spanish (Panama)" \
"es_PA.utf8" "Spanish (Panama, Unicode)" \
"es_PE" "Spanish (Peru)" \
"es_PE.utf8" "Spanish (Peru, Unicode)" \
"es_PR" "Spanish (Puerto Rico)" \
"es_PR.utf8" "Spanish (Puerto Rico, Unicode)" \
"es_PY" "Spanish (Paraguay)" \
"es_PY.utf8" "Spanish (Paraguay, Unicode)" \
"es_SV" "Spanish (El Salvador)" \
"es_SV.utf8" "Spanish (El Salvador, Unicode)" \
"es_US" "Spanish (USA)" \
"es_US.utf8" "Spanish (USA, Unicode)" \
"es_UY" "Spanish (Uruguay)" \
"es_UY.utf8" "Spanish (Uruguay, Unicode)" \
"es_VE" "Spanish (Venezuela)" \
"es_VE.utf8" "Spanish (Venezuela, Unicode)" \
"et_EE" "Estonian (Estonia)" \
"et_EE.iso885915" "Estonian (Estonia, ISO-8859-15)" \
"et_EE.utf8" "Estonian (Estonia, Unicode)" \
"eu_ES" "Basque (Spain)" \
"eu_ES.utf8" "Basque (Spain, Unicode)" \
"eu_ES@euro" "Basque (Spain, with Euro)" \
"fa_IR" "Persian (Iran)" \
"fi_FI" "Finnish (Finland)" \
"fi_FI.utf8" "Finnish (Finland, Unicode)" \
"fi_FI@euro" "Finnish (Finland, with Euro)" \
"fo_FO" "Faroese (Faroe Islands)" \
"fo_FO.utf8" "Faroese (Faroe Islands, Unicode)" \
"fr_BE" "French (Belgium)" \
"fr_BE.utf8" "French (Belgium, Unicode)" \
"fr_BE@euro" "French (Belgium, with Euro)" \
"fr_CA" "French (Canada)" \
"fr_CA.utf8" "French (Canada, Unicode)" \
"fr_CH" "French (Switzerland)" \
"fr_CH.utf8" "French (Switzerland, Unicode)" \
"fr_FR" "French (France)" \
"fr_FR.utf8" "French (France, Unicode)" \
"fr_FR@euro" "French (France, with Euro)" \
"fr_LU" "French (Luxemburg)" \
"fr_LU.utf8" "French (Luxemburg, Unicode)" \
"fr_LU@euro" "French (Luxemburg, with Euro)" \
"fy_NL" "Frisian (Netherlands)" \
"ga_IE" "Irish (Ireland)" \
"ga_IE.utf8" "Irish (Ireland, Unicode)" \
"ga_IE@euro" "Irish (Ireland, with Euro)" \
"gd_GB" "Scots Gaelic (Great Britain)" \
"gd_GB.utf8" "Scots Gaelic (Great Britain, Unicode)" \
"gez_ER" "Ge'ez (Eritrea, Unicode)" \
"gez_ER@abegede" "Ge'ez (Eritrea With Abegede Collation, Unicode)" \
"gez_ET" "Ge'ez (Ethiopia, Unicode)" \
"gez_ET@abegede" "Ge'ez (Ethiopia With Abegede Collation, Unicode)" \
"gl_ES" "Galician (Spain)" \
"gl_ES.utf8" "Galician (Spain, Unicode)" \
"gl_ES@euro" "Galician (Spain, with Euro)" \
"gu_IN" "Gujarati (India)" \
"gv_GB" "Manx Gaelic (Britain)" \
"gv_GB.utf8" "Manx Gaelic (Britain, Unicode)" \
"he_IL" "Hebrew (Israel)" \
"he_IL.utf8" "Hebrew (Israel, Unicode)" \
"hi_IN" "Hindi (India)" \
"hr_HR" "Croatian (Croatia)" \
"hr_HR.utf8" "Croatian (Croatia, Unicode)" \
"hsb_DE" "Upper Sorbian (Germany, ISO-8859-2)" \
"hsb_DE.utf8" "Upper Sorbian (Germany, Unicode)" \
"hu_HU" "Hungarian (Hungary)" \
"hu_HU.utf8" "Hungarian (Hungary, Unicode)" \
"hy_AM" "Armenian (Armenia)" \
"hy_AM.armscii8" "Armenian (Armenia, ARMSCII-8)" \
"id_ID" "Indonesian (Indonesia)" \
"id_ID.utf8" "Indonesian (Indonesia, Unicode)" \
"is_IS" "Icelandic (Iceland)" \
"is_IS.utf8" "Icelandic (Iceland, Unicode)" \
"it_CH" "Italian (Switzerland)" \
"it_CH.utf8" "Italian (Switzerland, Unicode)" \
"it_IT" "Italian (Italy)" \
"it_IT.utf8" "Italian (Italy, Unicode)" \
"it_IT@euro" "Italian (Italy, with Euro)" \
"iw_IL" "Hebrew (Israel)" \
"iw_IL.utf8" "Hebrew (Israel, Unicode)" \
"ja_JP.eucjp" "Japanese (Japan, EUC-JP)" \
"ja_JP.utf8" "Japanese (Japan, Unicode)" \
"ka_GE" "Georgian (Georgia)" \
"ka_GE.utf8" "Georgian (Georgia, Unicode)" \
"kk_KZ" "Kazakh (Kazakhstan)" \
"kk_KZ.utf8" "Kazakh (Kazakhstan, Unicode)" \
"kl_GL" "Greenlandic (Greenland)" \
"kl_GL.utf8" "Greenlandic (Greenland, Unicode)" \
"km_KH" "Khmer (Cambodia)" \
"kn_IN" "Kannada (India)" \
"ko_KR.euckr" "Korean (Republic of Korea, EUC-KR)" \
"ko_KR.utf8" "Korean (Republic of Korea, Unicode)" \
"ku_TR" "Kurdish (Turkey, Latin)" \
"ku_TR.utf8" "Kurdish (Turkey, Unicode, Latin)" \
"kw_GB" "Cornish (Britain)" \
"kw_GB.utf8" "Cornish (Britain, Unicode)" \
"ky_KG" "Kyrgyz (Kyrgyzstan)" \
"lg_UG" "Luganda (Uganda)" \
"lg_UG.utf8" "Luganda (Uganda, Unicode)" \
"lo_LA" "Lao (Laos)" \
"lt_LT" "Lithuanian (Lithuania)" \
"lt_LT.utf8" "Lithuanian (Lithuania, Unicode)" \
"lv_LV" "Latvian (Latvia)" \
"lv_LV.utf8" "Latvian (Latvia, Unicode)" \
"mg_MG" "Malagasy (Madagascar)" \
"mg_MG.utf8" "Malagasy (Madagascar, Unicode)" \
"mi_NZ" "Maori (New Zealand)" \
"mi_NZ.utf8" "Maori (New Zealand, Unicode)" \
"mk_MK" "Macedonian (Macedonia)" \
"mk_MK.utf8" "Macedonian (Macedonia, Unicode)" \
"ml_IN" "Malayalam (India)" \
"mn_MN" "Mongolian (Mongolia)" \
"mr_IN" "Marathi (India)" \
"ms_MY" "Malay (Malaysia)" \
"ms_MY.utf8" "Malay (Malaysia, Unicode)" \
"mt_MT" "Maltese (Malta)" \
"mt_MT.utf8" "Maltese (Malta, Unicode)" \
"nb_NO" "Norwegian (Bokmaal) (Norway)" \
"nb_NO.utf8" "Norwegian (Bokmaal) (Norway, Unicode)" \
"ne_NP" "Nepali (Nepal)" \
"nl_BE" "Dutch (Belgium)" \
"nl_BE.utf8" "Dutch (Belgium, Unicode)" \
"nl_BE@euro" "Dutch (Belgium, with Euro)" \
"nl_NL" "Dutch (Netherlands)" \
"nl_NL.utf8" "Dutch (Netherlands, Unicode)" \
"nl_NL@euro" "Dutch (Netherlands, with Euro)" \
"nn_NO" "Nynorsk (Norway)" \
"nn_NO.utf8" "Nynorsk (Norway, Unicode)" \
"nr_ZA" "Southern Ndebele (South Africa)" \
"nso_ZA" "Northern Sotho (South Africa, Unicode)" \
"oc_FR" "Occitan (France)" \
"oc_FR.utf8" "Occitan (France, Unicode)" \
"om_ET" "Oromo (Ethiopia)" \
"om_KE" "Oromo (Kenya)" \
"om_KE.utf8" "Oromo (Kenya, Unicode)" \
"or_IN" "Oriya (India)" \
"pa_IN" "Punjabi (India)" \
"pa_PK" "Punjabi (Pakistan)" \
"pl_PL" "Polish (Poland)" \
"pl_PL.utf8" "Polish (Poland, Unicode)" \
"pt_BR" "Portuguese (Brasil)" \
"pt_BR.utf8" "Portuguese (Brasil, Unicode)" \
"pt_PT" "Portuguese (Portugal)" \
"pt_PT.utf8" "Portuguese (Portugal, Unicode)" \
"pt_PT@euro" "Portuguese (Portugal, with Euro)" \
"ro_RO" "Romanian (Romania)" \
"ro_RO.utf8" "Romanian (Romania, Unicode)" \
"ru_RU" "Russian (Russia)" \
"ru_RU.cp1251" "Russian (Russia, CP1251)" \
"ru_RU.koi8r" "Russian (Russia, KOI8-R)" \
"ru_RU.utf8" "Russian (Russia, Unicode)" \
"ru_UA" "Russian (Ukraine)" \
"ru_UA.utf8" "Russian (Ukraine, Unicode)" \
"rw_RW" "Kinyarwanda (Rwanda)" \
"sa_IN" "Sanskrit (India)" \
"se_NO" "Northern Saami (Norway)" \
"si_LK" "Sinhala (Sri Lanka)" \
"sid_ET" "Sidama (Ethiopia, Unicode)" \
"sk_SK" "Slovak (Slovak)" \
"sk_SK.utf8" "Slovak (Slovak, Unicode)" \
"sl_SI" "Slovenian (Slovenia)" \
"sl_SI.utf8" "Slovenian (Slovenia, Unicode)" \
"so_DJ" "Somali (Djibouti)" \
"so_DJ.utf8" "Somali (Djibouti, Unicode)" \
"so_ET" "Somali (Ethiopia)" \
"so_KE" "Somali (Kenya)" \
"so_KE.utf8" "Somali (Kenya, Unicode)" \
"so_SO" "Somali (Somalia)" \
"so_SO.utf8" "Somali (Somalia, Unicode)" \
"sq_AL" "Albanian (Albania)" \
"sq_AL.utf8" "Albanian (Albania, Unicode)" \
"sr_CS" "Serbian (Serbia and Montenegro)" \
"sr_CS.utf8" "Serbian (Serbia and Montenegro, Unicode)" \
"sr_ME" "Serbian (Serbia and Montenegro)" \
"ss_ZA" "Swati (South Africa)" \
"st_ZA" "Sotho (South Africa)" \
"st_ZA.utf8" "Sotho (South Africa, Unicode)" \
"sv_FI" "Swedish (Finland)" \
"sv_FI.utf8" "Swedish (Finland, Unicode)" \
"sv_FI@euro" "Swedish (Finland, with Euro)" \
"sv_SE" "Swedish (Sweden)" \
"sv_SE.utf8" "Swedish (Sweden, Unicode)" \
"ta_IN" "Tamil (India)" \
"te_IN" "Telugu (India)" \
"tg_TJ" "Tajik (Tajikistan)" \
"tg_TJ.utf8" "Tajik (Tajikistan, Unicode)" \
"th_TH" "Thai (Thailand)" \
"th_TH.utf8" "Thai (Thailand, Unicode)" \
"ti_ER" "Tigrigna (Eritrea)" \
"ti_ET" "Tigrigna (Ethiopia)" \
"tig_ER" "Tigre (Eritrea, Unicode)" \
"tl_PH" "Tagalog (Philippines)" \
"tl_PH.utf8" "Tagalog (Philippines, Unicode)" \
"tn_ZA" "Tswana (South Africa)" \
"tr_CY" "Turkish (Cyprus)" \
"tr_CY.utf8" "Turkish (Cyprus, Unicode)" \
"tr_TR" "Turkish (Turkey)" \
"tr_TR.utf8" "Turkish (Turkey, Unicode)" \
"ts_ZA" "Tsonga (South Africa)" \
"tt_RU.utf8" "Tatar (Tatarstan, Unicode)" \
"uk_UA" "Ukrainian (Ukraine)" \
"uk_UA.utf8" "Ukrainian (Ukraine, Unicode)" \
"ur_PK" "Urdu (Pakistan)" \
"uz_UZ" "Uzbek (latin) (Uzbekistan)" \
"uz_UZ@cyrillic" "Uzbek (Uzbekistan, Unicode, Cyrillic)" \
"ve_ZA" "Venda (South Africa)" \
"vi_VN" "Vietnamese (Vietnam)" \
"vi_VN.tcvn" "Vietnamese (Vietnam, TCVN5712-1)" \
"wa_BE" "Walloon (Belgium)" \
"wa_BE.utf8" "Walloon (Belgium, Unicode)" \
"wa_BE@euro" "Walloon (Belgium, with Euro)" \
"xh_ZA" "Xhosa (South Africa)" \
"xh_ZA.utf8" "Xhosa (South Africa, Unicode)" \
"yi_US" "Yiddish (USA)" \
"yi_US.utf8" "Yiddish (USA, Unicode)" \
"zh_CN" "Chinese (Peoples Republic of China)" \
"zh_CN.gb18030" "Chinese (Peoples Republic of China, GB18030)" \
"zh_CN.gbk" "Chinese (Peoples Republic of China, GBK)" \
"zh_CN.utf8" "Chinese (Peoples Republic of China, Unicode)" \
"zh_HK" "Chinese (Hong Kong)" \
"zh_HK.utf8" "Chinese (Hong Kong, Unicode)" \
"zh_SG" "Chinese (Singapore)" \
"zh_SG.gbk" "Chinese (Singapore, GBK)" \
"zh_SG.utf8" "Chinese (Singapore, Unicode)" \
"zh_TW" "Chinese (Taiwan R.O.C.)" \
"zh_TW.euctw" "Chinese (Taiwan R.O.C., EUC-TW)" \
"zh_TW.utf8" "Chinese (Taiwan R.O.C., Unicode)" \
"zu_ZA" "Zulu (South Africa)" \
"zu_ZA.utf8" "Zulu (South Africa, Unicode)" \
  2> $freply || return $?

  LOCALE="$(cat $freply)"
  set_locale $LOCALE

  clean_exit 0
}

wizard menu_locale

clean_exit $?