Class Translator
java.lang.Object
valorless.valorlessutils.translate.Translator
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionDownloadLanguage(String key) Downloads a language file from GitHub and saves it to the plugin's data folder.booleanFileExists(String key) Checks if the specified language file exists in the plugin's data folder.Reads the content of a language file.Gets the current language key.Loads the fallback language file from the plugin's data folder.voidSetLanguage(String key) Sets the language for translation.Translates a given key to the corresponding language.
- 
Constructor Details- 
TranslatorConstructor for Translator class.- Parameters:
- key- The language key to initialize the translator with.
 
 
- 
- 
Method Details- 
TranslateTranslates a given key to the corresponding language.- Parameters:
- translationKey- The key to be translated.
- Returns:
- The translated string or the original key if translation is not available.
 
- 
GetLanguageKeyGets the current language key.- Returns:
- The current language key.
 
- 
LoadFallbackLanguageLoads the fallback language file from the plugin's data folder. If the file doesn't exist, it is copied from the plugin's resources.- Returns:
- The content of the fallback language file, or nullif an error occurs.
 
- 
FileExistsChecks if the specified language file exists in the plugin's data folder.- Parameters:
- key- The name of the language file (without the extension).
- Returns:
- trueif the language file exists,- falseotherwise.
 
- 
SetLanguageSets the language for translation.- Parameters:
- key- The language key to set.
 
- 
GetLanguageFileContentReads the content of a language file.- Parameters:
- key- The language key.
- Returns:
- The content of the language file as a string.
 
- 
DownloadLanguageDownloads a language file from GitHub and saves it to the plugin's data folder.This method fetches the language file from a specified GitHub URL and saves it in the plugin's data folder. It also ensures the necessary directories are created and logs the success or failure of the download. - Parameters:
- key- The name of the language file (without the extension).
- Returns:
- The content of the downloaded language file as a string, or nullif an error occurs during the download or reading process.
 
 
-