Skip to content

Commit

Permalink
Add built-in var A_Language
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Jul 20, 2023
1 parent 2b750b1 commit 2c056ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1843,11 +1843,11 @@ <h4 class="calibre25"><a id="Variables.htm__os" href="#Variables.htm__os" class=
</tr>
<tr class="calibre3">
<td class="calibre4">A_OSVersion</td>
<td class="calibre4"> <a id="Variables.htm__OSVersion" href="#Variables.htm__OSVersion" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">#</a> <span class="tbd">One of the following strings: WIN_XP, WIN_2000, WIN_NT4, WIN_95, WIN_98, WIN_ME.</span></td>
<td class="calibre4"> <a id="Variables.htm__OSVersion" href="#Variables.htm__OSVersion" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">#</a> <span class="rm">One of the following strings: WIN_XP, WIN_2000, WIN_NT4, WIN_95, WIN_98, WIN_ME.</span></td>
</tr>
<tr class="calibre3">
<td class="calibre4">A_Language</td>
<td class="calibre4"><a id="Variables.htm__Language" href="#Variables.htm__Language" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">#</a> <span class="tbd">The system's default language, which is one of the strings from the <a href="#Languages.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">language table</a></span>. [requires 1.0.24+]</td>
<td class="calibre4"><a id="Variables.htm__Language" href="#Variables.htm__Language" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">#</a> The system's default language, which is one of the strings from the <a href="#Languages.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">language table</a>. <span class="x11">Note: To get the ISO language code instead, run `EnvGet, var, LANG` instead.</span></td>
</tr>
<tr class="calibre3">
<td class="calibre4">A_ComputerName</td>
Expand Down Expand Up @@ -16254,6 +16254,7 @@ <h3 class="calibre45">On-Screen Keyboard (requires XP/2k/NT) -- by Jon</h3>
</div>
</div>
</div>
</div>
<div class="calibreMain">
<div class="calibreEbookContent">
<a id="Languages.htm" href="#Languages.htm">#</a>
Expand Down Expand Up @@ -16772,6 +16773,7 @@ <h3 class="calibre45">On-Screen Keyboard (requires XP/2k/NT) -- by Jon</h3>
</table>
</div>
</div>
<div class="tbd">
<div class="calibreMain">
<div class="calibreEbookContent">
<a id="MinimizeToTrayMenu.htm" href="#MinimizeToTrayMenu.htm">#</a>
Expand Down
2 changes: 2 additions & 0 deletions src/run/runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require "./timer"
require "./display/hotkey"
require "../cmd/base"
require "system/user"
require "../util/lcid-mapping"

module Run
enum SingleInstance
Expand Down Expand Up @@ -269,6 +270,7 @@ module Run
when "a_issuspended" then @suspension ? "1" : "0"
when "a_iscompiled" then @is_compiled ? "1" : ""
when "a_timeidle" then (Time.monotonic - display.last_event_received).total_milliseconds.round.to_i.to_s
when "a_language" then Util::LcidMapping.mapping[ENV["LANG"].split('.')[0]]? || ""
when "0" then (ARGV.size - (@script_file ? 1 : 0)).to_s
else
if i = var.to_i?
Expand Down
6 changes: 6 additions & 0 deletions src/util/lcid-mapping.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Util::LcidMapping
def self.mapping
# Thanks to Sindre Sorhus @ https://github.com/sindresorhus/lcid/tree/main
{ "zh_CHS" => "0004", "ar_SA" => "0401", "bg_BG" => "0402", "ca_ES" => "0403", "zh_TW" => "0404", "cs_CZ" => "0405", "da_DK" => "0406", "de_DE" => "0407", "el_GR" => "0408", "en_US" => "0409", "fi_FI" => "040b", "fr_FR" => "040c", "he_IL" => "040d", "hu_HU" => "040e", "is_IS" => "040f", "it_IT" => "0410", "ja_JP" => "0411", "ko_KR" => "0412", "nl_NL" => "0413", "nb_NO" => "0414", "pl_PL" => "0415", "pt_BR" => "0416", "rm_CH" => "0417", "ro_RO" => "0418", "ru_RU" => "0419", "hr_HR" => "041a", "sk_SK" => "041b", "sq_AL" => "041c", "sv_SE" => "041d", "th_TH" => "041e", "tr_TR" => "041f", "ur_PK" => "0420", "id_ID" => "0421", "uk_UA" => "0422", "be_BY" => "0423", "sl_SI" => "0424", "et_EE" => "0425", "lv_LV" => "0426", "lt_LT" => "0427", "tg_TJ" => "0428", "fa_IR" => "0429", "vi_VN" => "042a", "hy_AM" => "042b", "eu_ES" => "042d", "wen_DE" => "042e", "mk_MK" => "042f", "st_ZA" => "0430", "ts_ZA" => "0431", "tn_ZA" => "0432", "ven_ZA" => "0433", "xh_ZA" => "0434", "zu_ZA" => "0435", "af_ZA" => "0436", "ka_GE" => "0437", "fo_FO" => "0438", "hi_IN" => "0439", "mt_MT" => "043a", "se_NO" => "043b", "gd_GB" => "043c", "yi" => "043d", "ms_MY" => "043e", "kk_KZ" => "043f", "ky_KG" => "0440", "sw_KE" => "0441", "tk_TM" => "0442", "tt_RU" => "0444", "bn_IN" => "0445", "pa_IN" => "0446", "gu_IN" => "0447", "or_IN" => "0448", "ta_IN" => "0449", "te_IN" => "044a", "kn_IN" => "044b", "ml_IN" => "044c", "as_IN" => "044d", "mr_IN" => "044e", "sa_IN" => "044f", "mn_MN" => "0450", "bo_CN" => "0451", "cy_GB" => "0452", "kh_KH" => "0453", "lo_LA" => "0454", "my_MM" => "0455", "gl_ES" => "0456", "kok_IN" => "0457", "sd_IN" => "0459", "syr_SY" => "045a", "si_LK" => "045b", "chr_US" => "045c", "am_ET" => "045e", "tmz" => "045f", "ne_NP" => "0461", "fy_NL" => "0462", "ps_AF" => "0463", "fil_PH" => "0464", "div_MV" => "0465", "bin_NG" => "0466", "fuv_NG" => "0467", "ha_NG" => "0468", "ibb_NG" => "0469", "yo_NG" => "046a", "quz_BO" => "046b", "ns_ZA" => "046c", "ba_RU" => "046d", "lb_LU" => "046e", "kl_GL" => "046f", "ii_CN" => "0478", "arn_CL" => "047a", "moh_CA" => "047c", "br_FR" => "047e", "ug_CN" => "0480", "mi_NZ" => "0481", "oc_FR" => "0482", "co_FR" => "0483", "gsw_FR" => "0484", "sah_RU" => "0485", "qut_GT" => "0486", "rw_RW" => "0487", "wo_SN" => "0488", "gbz_AF" => "048c", "ar_IQ" => "0801", "zh_CN" => "0804", "de_CH" => "0807", "en_GB" => "0809", "es_MX" => "080a", "fr_BE" => "080c", "it_CH" => "0810", "nl_BE" => "0813", "nn_NO" => "0814", "pt_PT" => "0816", "ro_MD" => "0818", "ru_MD" => "0819", "sv_FI" => "081d", "ur_IN" => "0820", "az_AZ" => "082c", "dsb_DE" => "082e", "se_SE" => "083b", "ga_IE" => "083c", "ms_BN" => "083e", "uz_UZ" => "0843", "mn_CN" => "0850", "bo_BT" => "0851", "iu_CA" => "085d", "tmz_DZ" => "085f", "ne_IN" => "0861", "quz_EC" => "086b", "ti_ET" => "0873", "ar_EG" => "0c01", "zh_HK" => "0c04", "de_AT" => "0c07", "en_AU" => "0c09", "es_ES" => "0c0a", "fr_CA" => "0c0c", "sr_SP" => "0c1a", "se_FI" => "0c3b", "quz_PE" => "0c6b", "ar_LY" => "1001", "zh_SG" => "1004", "de_LU" => "1007", "en_CA" => "1009", "es_GT" => "100a", "fr_CH" => "100c", "hr_BA" => "101a", "smj_NO" => "103b", "ar_DZ" => "1401", "zh_MO" => "1404", "de_LI" => "1407", "en_NZ" => "1409", "es_CR" => "140a", "fr_LU" => "140c", "smj_SE" => "143b", "ar_MA" => "1801", "en_IE" => "1809", "es_PA" => "180a", "fr_MC" => "180c", "sma_NO" => "183b", "ar_TN" => "1c01", "en_ZA" => "1c09", "es_DO" => "1c0a", "fr_029" => "1c0c", "sr_BA" => "1c1a", "sma_SE" => "1c3b", "ar_OM" => "2001", "en_JA" => "2009", "es_VE" => "200a", "fr_RE" => "200c", "bs_BA" => "201a", "sms_FI" => "203b", "ar_YE" => "2401", "en_CB" => "2409", "es_CO" => "240a", "fr_CG" => "240c", "smn_FI" => "243b", "ar_SY" => "2801", "en_BZ" => "2809", "es_PE" => "280a", "fr_SN" => "280c", "ar_JO" => "2c01", "en_TT" => "2c09", "es_AR" => "2c0a", "fr_CM" => "2c0c", "ar_LB" => "3001", "en_ZW" => "3009", "es_EC" => "300a", "fr_CI" => "300c", "ar_KW" => "3401", "en_PH" => "3409", "es_CL" => "340a", "fr_ML" => "340c", "ar_AE" => "3801", "en_ID" => "3809", "es_UR" => "380a", "fr_MA" => "380c", "ar_BH" => "3c01", "en_HK" => "3c09", "es_PY" => "3c0a", "fr_HT" => "3c0c", "ar_QA" => "4001", "en_IN" => "4009", "es_BO" => "400a", "en_MY" => "4409", "es_SV" => "440a", "en_SG" => "4809", "es_HN" => "480a", "es_NI" => "4c0a", "es_PR" => "500a", "es_US" => "540a", "zh_CHT" => "7c04" }
end
end

0 comments on commit 2c056ba

Please sign in to comment.