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 48beb09..c50d7f7 100644 Binary files a/autosub-ahk.exe and b/autosub-ahk.exe differ 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