From 0cf8e32d95da868df7b095814a165d5d29e820d3 Mon Sep 17 00:00:00 2001 From: jerry Date: Fri, 5 Mar 2021 18:09:43 +0800 Subject: [PATCH] v1.0.8 read language-codes from ini file --- autosub-ahk.ahk | 37 ++++++++++++++++++++++++++++++------ autosub-ahk.exe | Bin 1118208 -> 1118208 bytes autosub-ahk.ini | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ read-ini.ahk | 30 +++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 autosub-ahk.ini create mode 100644 read-ini.ahk diff --git a/autosub-ahk.ahk b/autosub-ahk.ahk index 1c9882e..625c019 120000 --- a/autosub-ahk.ahk +++ b/autosub-ahk.ahk @@ -12,6 +12,7 @@ ; v1.0.5 2020/09/02 Add French language ; v1.0.6 2020/09/21 Add tr-tr Turkish (Turkey) ; v1.0.7 2021/01/21 Add ru-ru Russian +; v1.0.8 2021/03/05 Read language-codes from ini file ; =========================== #SingleInstance Force #NoEnv @@ -19,6 +20,7 @@ SetWorkingDir %A_ScriptDir% SetBatchLines -1 #Include %A_ScriptDir%\ControlColor.ahk +#Include %A_ScriptDir%\read-ini.ahk I_ICON := A_ScriptDir . "\cc.ico" global videoFiles @@ -26,11 +28,16 @@ global VIDEO_FORMAT_FAILED videoFiles := [] VALID_VIDEO_FORMAT := "*.mp4;*.mp3;*.wav" -version := "v1.0.7" +version := "v1.0.8" +_iCurrentLanguage := A_Language +;; testing begin +;_iCurrentLanguage := "english" +;; testing end + ; 多語系設定 -if (A_Language in 0404, 0c04, 1404) { ; Chinese_Taiwan, Hong Kong, Macau +if (_iCurrentLanguage == "0404" || _iCurrentLanguage == "0c04" || _iCurrentLanguage == "1404") { ; Chinese_Taiwan, Hong Kong, Macau TITLE := "AutoSub-AHK 字幕產生器" - LANGUAGES := "zh-TW 中文(繁體)||zh-CN 中文(簡體)|en-US English|ja-JP 日本語|ko-KR 한국어|yue-hant-hk 粵語|fr-fr French(France)|tr-tr Turkish (Turkey)|ru-ru Russian" + LANGUAGES := "zh_TW" VIDEO_LANGUAGE := "影片語言(&L)" VIDEO_FILES := "選擇影片檔案(&S)" OUTPUT_FILENAME := "輸出檔名(&O)" @@ -40,9 +47,9 @@ if (A_Language in 0404, 0c04, 1404) { ; Chinese_Taiwan, Hong Kong, Macau BTN_CLOSE := "關閉(&C)" VIDEO_SELECT_TITLE := "選擇影片檔案(可複選)" VIDEO_FORMAT_FAILED := "影片副檔名必須是 " . VALID_VIDEO_FORMAT -} else if (A_Language in 0804,1004) { ; Chinese_PRC, singapore +} else if (_iCurrentLanguage == "0804" || _iCurrentLanguage == "1004") { ; Chinese_PRC, singapore TITLE := "AutoSub-AHK 字幕产生器" - LANGUAGES := "zh-TW 中文(繁体)|zh-CN 中文(简体)||en-US English|ja-JP 日本语|ko-KR 한국어|yue-hant-hk 粤语|fr-fr French(France)|tr-tr Turkish (Turkey)|ru-ru Russian" + LANGUAGES := "zh_CN" VIDEO_LANGUAGE := "视频语言(&L)" VIDEO_FILES := "选择视频文件(&S)" OUTPUT_FILENAME := "输出档名(&O)" @@ -54,7 +61,7 @@ if (A_Language in 0404, 0c04, 1404) { ; Chinese_Taiwan, Hong Kong, Macau VIDEO_FORMAT_FAILED := "影片副档名必须为 " . VALID_VIDEO_FORMAT } else { TITLE := "AutoSub-AHK SubTITLEs Generator" - LANGUAGES := "zh-TW Chinese(Traditional)|zh-CN Chinese(Simplified)|en-US English||ja-JP Japanese|ko-KR Korean|yue-hant-hk Hong Kong|fr-fr French(France)|tr-tr Turkish (Turkey)|ru-ru Russian" + LANGUAGES := "en_US" VIDEO_LANGUAGE := "Video &Language" VIDEO_FILES := "&Select Video File(s)" OUTPUT_FILENAME := "&Output file name" @@ -66,6 +73,24 @@ if (A_Language in 0404, 0c04, 1404) { ; Chinese_Taiwan, Hong Kong, Macau VIDEO_FORMAT_FAILED := "Video's extension must be " . VALID_VIDEO_FORMAT } +FileEncoding, UTF-8 +; After reading ini, LANGUAGEScount, zh_TW1, zh_TW2, ... variables will be created +ReadIni("autosub-ahk.ini") + +_sLanguages := "" +Loop, %LANGUAGEScount% { + if (LANGUAGES == "zh_TW") { + _sLanguages .= zh_TW%A_Index% . "|" + } else if (LANGUAGES == "zh_CN") { + _sLanguages .= zh_CN%A_Index% . "|" + } else { + _sLanguages .= en_US%A_Index% . "|" + } +} + +;;MsgBox languages=%_sLanguages% +LANGUAGES := _sLanguages + Menu Tray, Icon, %I_ICON% Gui +hWndhMainWnd +Resize -MaximizeBox diff --git a/autosub-ahk.exe b/autosub-ahk.exe index 48beb09ce29dec5403d5ffba8c87114b864e6273..c50d7f7a3717b7feab4aa53f5c5663b9689f287a 100644 GIT binary patch delta 1173 zcmaJ*({f zMB@8kqJ3T89Z96{s~Z=aVSExam;mYshmv^|lB&Aoj#!s~p`eR8cdV+9U6@-I%T*m1vU!%x z8GaP46^71iI1tO4vTfes6(mHdv?eW%*#^B&HG-!5)!sx~X)PkW;&bS<%wUV{iog*e z-%o53PZBH&xv(Qz)WBlw^I(&d`-z|-4^;?5BaD?NiAN7?I$$^*?w!7+xbsb8@`SEGe z9ZPD3f$N7Wlm#-bn`2w_E$`dKn$XpftUq|S%H`hh}nUd1Bf|+m>jfD^koXd4d>u5t0~$XB z$p6ELFfU-EAj21+T`=>78SJ(j&k+y`o__6vz-(1>C9cdg1r5h|pTxZM(!}&sh0Ht! z0}}%i9R-7A5NQZxPyhH)z`9;HBwXRij1=qavoXp~knyf@!uKP?AwRP>AXx{4K!9k1H?$J z)T}8g)h#Mj2r4Zu&P>ePuK!738KXFwcPxM&F*JbqLt(o97XfKB&pg>XSrg4K>l(m< zHF!L;ek}pdEO`M`LcV9F13e?UJ?V?U3C4P0Km&u{IU_SKwK!EHq$n{Zvm`S=FEIz^ zZkSYXW^O@FW?E)yiYA)dp)ui=Sda)Z1nPG0{G!yvJd{}Q$j?hx@CFhHw;LeG1aT4Z XO<*eH_V+&o1jVOs;1>+QLI?l=!9qPN diff --git a/autosub-ahk.ini b/autosub-ahk.ini new file mode 100644 index 0000000..53f7e42 --- /dev/null +++ b/autosub-ahk.ini @@ -0,0 +1,49 @@ +[LANGUAGES] +1=zh_TW +2=zh_CN +3=en_US +count=11 + +; number=LanguageCode LanguageDescription +; How to get the required language code? +; 1. Execute cmd.exe +; 2. cd autosub +; 3. autosub.exe -lsc +[zh_TW] +1=zh-TW 中文(繁體) +2=zh-CN 中文(簡體) +3=en-US English +4=ja-JP 日本語 +5=ko-KR 한국어 +6=yue-hant-hk 粵語 +7=fr-fr French(法語) +8=tr-tr Turkish (土耳其語) +9=ru-ru Russian (俄語) +10=es-es Spanish (西班牙語) +11=it-it Italian (義大利語) + +[zh_CN] +1=zh-TW 中文(繁体) +2=zh-CN 中文(简体) +3=en-US English +4=ja-JP 日本语 +5=ko-KR 한국어 +6=yue-hant-hk 粤语 +7=fr-fr French(法语) +8=tr-tr Turkish (土耳其语) +9=ru-ru Russian (俄语) +10=es-es Spanish (西班牙语) +11=it-it Italian (意大利语) + +[en_US] +1=zh-TW Chinese(Traditional) +2=zh-CN Chinese(Simplified) +3=en-US English +4=ja-JP Japanese +5=ko-KR Korean +6=yue-hant-hk Hong Kong +7=fr-fr French(France) +8=tr-tr Turkish (Turkey) +9=ru-ru Russian (Russia) +10=es-es Spanish (Spain) +11=it-it Italian (Italy) diff --git a/read-ini.ahk b/read-ini.ahk new file mode 100644 index 0000000..f232824 --- /dev/null +++ b/read-ini.ahk @@ -0,0 +1,30 @@ + +; https://autohotkey.com/board/topic/33506-read-ini-file-in-one-go/ + +ReadIni( filename = 0 ) +; Read a whole .ini file and creates variables like this: +; %Section%%Key% = %value% +{ +Local s, c, p, key, k + + if not filename + filename := SubStr( A_ScriptName, 1, -3 ) . "ini" + + FileRead, s, %filename% + + Loop, Parse, s, `n`r, %A_Space%%A_Tab% + { + c := SubStr(A_LoopField, 1, 1) + if (c="[") + key := SubStr(A_LoopField, 2, -1) + else if (c=";") + continue + else { + p := InStr(A_LoopField, "=") + if p { + k := SubStr(A_LoopField, 1, p-1) + %key%%k% := SubStr(A_LoopField, p+1) + } + } + } +} \ No newline at end of file