This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(i18n): 🌐 add multilanguage (resolve #18)
- Loading branch information
1 parent
23bb19e
commit 6a5ffd9
Showing
13 changed files
with
186 additions
and
27 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"conventionalCommits.scopes": [ | ||
"ui", | ||
"download", | ||
"config" | ||
"config", | ||
"i18n" | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
langName: English | ||
license.title: License Notice | ||
license.content: | | ||
Copyright © 2022 Andy Zhang and contributors | ||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
window.search.search: Search | ||
window.show.resultWarning.title: Warning | ||
window.show.resultWarning.content: Got 0 results! | ||
window.filters.sort: 'Sort: ' | ||
window.filters.gameVersion: 'Game Version: ' | ||
window.filters.modpackVersion: 'Modpack Version: ' | ||
window.buttons.import: Import | ||
window.buttons.download: Download | ||
window.buttons.exit: Exit | ||
download.file.title: Downloading Configuration... | ||
download.mods.title: Downloading Mods... | ||
download.getURLFail.title: Warning | ||
download.getURLFail.content: Fail to get mod download URLs, this may caused by a network issue, please try again. | ||
download.finish.title: Finished | ||
download.finish.content: | | ||
Please import to launcher | ||
Issues: | ||
https://github.com/AnzhiZhang/CurseForgeModpackDownloader | ||
download.downloadFail: '{0} mods download fail, please download them manually!' | ||
download.getModWarning.title: Warning | ||
download.getModWarning.content: | | ||
{0} | ||
Please get more info in log. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
langName: 简体中文 | ||
license.title: 版权声明 | ||
license.content: | | ||
Copyright © 2022 Andy Zhang and contributors | ||
本程序是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。 | ||
发布该程序是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。 | ||
你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看 https://www.gnu.org/licenses/。 | ||
window.search.search: 搜索 | ||
window.show.resultWarning.title: 警告 | ||
window.show.resultWarning.content: 共搜索到 0 个结果! | ||
window.filters.sort: 排序: | ||
window.filters.gameVersion: 游戏版本: | ||
window.filters.modpackVersion: 整合包版本: | ||
window.buttons.import: 导入 | ||
window.buttons.download: 下载 | ||
window.buttons.exit: 退出 | ||
download.file.title: 下载配置文件………… | ||
download.mods.title: 正在下载模组………… | ||
download.getURLFail.title: 警告 | ||
download.getURLFail.content: 获取模组下载地址失败,这可能是由于网络不稳定,请重试 | ||
download.finish.title: 下载完成 | ||
download.finish.content: | | ||
请直接导入启动器 | ||
问题反馈: | ||
https://github.com/AnzhiZhang/CurseForgeModpackDownloader | ||
download.downloadFail: '{0} 个模组下载失败,请手动下载!' | ||
download.getModWarning.title: 警告 | ||
download.getModWarning.content: | | ||
{0} | ||
请查看日志获取详细信息 |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
|
||
import yaml | ||
|
||
from typing import TYPE_CHECKING, Dict, List | ||
|
||
if TYPE_CHECKING: | ||
from utils.factory import Factory | ||
|
||
from utils.constant import PATH | ||
|
||
|
||
class Language: | ||
def __init__(self, factory: 'Factory'): | ||
self.__data: Dict[str, Dict[str, str]] = {} | ||
self.__lang = factory.config['language'] | ||
self.__load() | ||
|
||
def __load(self): | ||
for i in os.listdir(PATH.LANG_DIR_PATH): | ||
path = os.path.join(PATH.LANG_DIR_PATH, i) | ||
with open(path, encoding='utf-8') as f: | ||
self.__data[os.path.splitext(i)[0]] = yaml.safe_load(f) | ||
|
||
def translate(self, key: str, *args) -> str: | ||
""" | ||
Translate words from key. | ||
:param key: Key of words. | ||
:param lang: Language name. | ||
:return: Words. | ||
""" | ||
return self.__data.get(self.__lang).get(key).format(*args) | ||
|
||
def get_languages_list(self) -> List[str]: | ||
""" | ||
Get languages list. | ||
:return: Language name list. | ||
""" | ||
return list(self.__data.keys()) |
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
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
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
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
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