Skip to content

Commit

Permalink
支持语言文件的本地化
Browse files Browse the repository at this point in the history
语言文件的读取不在插件本身了
  • Loading branch information
stevei5mc committed Jun 21, 2024
1 parent 50b45d3 commit ff127a2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## **插件介绍**
- **敬请期待**
## **使用方法**
1. **将插件放进`plugins`文件夹**
1. **将插件放进`plugins`文件夹,并确保安装[MemoriesOfTime-GameCore](https://motci.cn/job/GameCore/)插件后重启服务器**
2. **启动(重启)服务器并调整好配置(如何配置请看插件介绍)**
3. **重载配置文件或重启服务器**
4. **自动重启还需要脚本的配合才能实现相关脚本在[Actions](https://github.com/stevei5mc/NewTipsVariables/actions)编译完成后会一并给出,你也可以到对应[仓库](https://github.com/stevei5mc/McStartServer)获取,[Releases](https://github.com/stevei5mc/AutoRestart/releases)中也可以获取得到但只会在版本发布后才会有相关脚本(Windows用.bat后缀的脚本,Linux请用.sh后缀的脚本,另外每种系统的脚本都有两个根据你的需求选择)**
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void loadLanguage() {
}
for (String language : languages) {
Config languageConfig = new Config(Config.PROPERTIES);
languageConfig.load(this.getResource("language/" + language + ".properties"));
languageConfig.load(this.getDataFolder() + "/language/" + language + ".properties");
this.languageMap.put(language, new Language(languageConfig));
}
this.getLogger().info(this.getLang().translateString("plugin_language"));
Expand All @@ -126,7 +126,6 @@ public Language getLang(CommandSender sender) {
String playerLanguage = player.getLoginChainData().getLanguageCode();
if (!this.languageMap.containsKey(playerLanguage)) {
playerLanguage = this.defaultLanguage;
getLogger().info("zhcn");
}
return this.languageMap.get(playerLanguage);
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/language/en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ kick_player_msg=Server restarting, See you later
form_title=Auto Rstart system
form_button_restart_cancel=取消自动重启任务
form_button_restart_run=执行自动重启任务
form_button_reload=重载配置文件
form_button_reload=重载配置文件
command_not_permission=§c你没有权限使用此命令!
command_in_game_run=§c请在游戏内使用此命令!
4 changes: 3 additions & 1 deletion src/main/resources/language/zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ kick_player_msg=§e服务器重启中 稍后再会
form_title=Auto Rstart system
form_button_restart_cancel=取消自动重启任务
form_button_restart_run=执行自动重启任务
form_button_reload=重载配置文件
form_button_reload=重载配置文件
command_not_permission=§c你没有权限使用此命令!
command_in_game_run=§c请在游戏内使用此命令!
4 changes: 3 additions & 1 deletion src/main/resources/language/zh_TW.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ kick_player_msg=§e服務器重啓中 稍後再會
form_title=Auto Rstart system
form_button_restart_cancel=取消自动重启任务
form_button_restart_run=执行自动重启任务
form_button_reload=重载配置文件
form_button_reload=重载配置文件
command_not_permission=§c你没有权限使用此命令!
command_in_game_run=§c请在游戏内使用此命令!

1 comment on commit ff127a2

@stevei5mc
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在这之前的语言文件读取是在插件本身放置的语言文件
这个提交后可以读取在插件的配置文件夹的language文件夹中的语言文件

Please sign in to comment.