Last active
September 6, 2018 10:39
-
-
Save blueset/7761663918e6640bf092932edc13c9bf to your computer and use it in GitHub Desktop.
Telegram Swift Native load language file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Telegram Native Swift 汉化脚本 | |
-- 制作:Eana Hufwe | |
set zh_cn to "简体中文语言文件,来自 @zh_CN 的 GitHub Repo" | |
set zh_tw to "正體中文化文件(台灣),尚未收录" | |
set zh_hk to "繁體中文化文件(香港),尚未收录" | |
set tlocal to "本地语言文件" | |
set iinput to (choose file with prompt "选择您的 Telegram Native Swift 程序。" of type {"app"} default location "Applications") as string | |
set tgpath to POSIX path of iinput | |
set fp to open for access file (iinput & "Contents:Info.plist") | |
set infopl to read fp | |
close access fp | |
if infopl does not contain "ru.keepcoder.Telegram" then | |
display alert "您选择的 Telegram 版本有误。请选择正确的 Telegram Native Swift 程序。" as critical | |
error number -128 | |
end if | |
set source to (choose from list {zh_cn, zh_tw, zh_hk, tlocal} with prompt "请选择需要应用的语言文件。" default items "None" OK button name {"确定"} cancel button name {"取消"}) | |
if (source is equal to false) then | |
error number -128 | |
end if | |
set source to source's item 1 | |
-- error number -128 | |
if (source is equal to zh_cn) then | |
do shell script "mkdir \"" & tgpath & "Contents/Resources/zh_CN.lproj\" &" with administrator privileges | |
do shell script "curl \"https://raw.githubusercontent.com/telegram-zhCN/telegram-language-resources/master/zh-CN/Localizable-macOS.strings\" -o \"" & tgpath & "Contents/Resources/zh_CN.lproj/Localizable.strings\"" with administrator privileges | |
-- do shell script "curl \"https://httpbin.org/get?1\" -o \"" & tgpath & "Contents/Resources/zh_CN.lproj/MainMenu.strings\"" with administrator privileges | |
else if (source is equal to zh_tw) then | |
display alert "尚未完成" as critical | |
error number -128 | |
else if (source is equal to zh_hk) then | |
display alert "尚未完成" as critical | |
error number -128 | |
else if (source is equal to tlocal) then | |
tell application "Finder" | |
do shell script "mkdir \"" & tgpath & "/Contents/Resources/zh.lproj\" &" with administrator privileges | |
do shell script "cp \"" & POSIX path of (choose file with prompt "选择您的 Telegram 语言文件 Localizable.string" of type {"strings"} default location alias ((path to home folder as text) & "Downloads")) & "\" \"" & tgpath & "Contents/Resources/zh.lproj/Localizable.strings\"" with administrator privileges | |
do shell script "cp \"" & POSIX path of (choose file with prompt "选择您的 Telegram 语言文件 MainMenu.string" of type {"strings"} default location alias ((path to home folder as text) & "Downloads")) & "\" \"" & tgpath & "Contents/Resources/zh.lproj/MainMenu.strings\"" with administrator privileges | |
end tell | |
end if | |
display alert "汉化成功,请重新启动 Telegram。 | |
脚本:Eana Hufwe" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
赞一个~~~太方便了。希望可以再支持其他中文,就完美了。