This repository has been archived by the owner on Apr 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25c86ea
commit d5ebb38
Showing
7 changed files
with
197 additions
and
74 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
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
34 changes: 34 additions & 0 deletions
34
src/main/java/vip/floatationdevice/mc2gforward/I18nUtil.java
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,34 @@ | ||
package vip.floatationdevice.mc2gforward; | ||
|
||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
|
||
import java.io.File; | ||
|
||
public class I18nUtil | ||
{ | ||
private static FileConfiguration l; | ||
private static String lang = "en_US"; | ||
|
||
public static String setLanguage(String language) | ||
{ | ||
if (language == null || language.equals("")) return lang; | ||
lang = language; | ||
File langFile = new File(MC2GForward.instance.getDataFolder(), "lang_" + lang + ".yml"); | ||
if (!langFile.exists()) MC2GForward.instance.saveResource("lang_" + lang + ".yml", false); | ||
l = YamlConfiguration.loadConfiguration(langFile); | ||
return lang; | ||
} | ||
|
||
public static String getLocalizedMessage(String key) | ||
{ | ||
String msg = l.getString(key); | ||
if (msg == null) return "[NO TRANSLATION: " + key + "]"; | ||
return msg; | ||
} | ||
|
||
public String getLanguage() | ||
{ | ||
return lang; | ||
} | ||
} |
Oops, something went wrong.