forked from hannibal002/SkyHanni
-
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.
Improvement: Multiple Languages (hannibal002#2403)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
- Loading branch information
1 parent
28db8ce
commit a15589f
Showing
6 changed files
with
146 additions
and
17 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
37 changes: 37 additions & 0 deletions
37
src/main/java/at/hannibal2/skyhanni/config/features/chat/TranslatorConfig.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,37 @@ | ||
package at.hannibal2.skyhanni.config.features.chat; | ||
|
||
import at.hannibal2.skyhanni.config.FeatureToggle; | ||
import at.hannibal2.skyhanni.features.chat.translation.TranslatableLanguage; | ||
import com.google.gson.annotations.Expose; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; | ||
import io.github.notenoughupdates.moulconfig.observer.Property; | ||
|
||
public class TranslatorConfig { | ||
|
||
@Expose | ||
@ConfigOption( | ||
name = "Translate On Click", | ||
desc = "Click on a message to translate it to English.\n" + | ||
"Use §e/shcopytranslation§7 to translate from English.\n" + | ||
"§cTranslation is not guaranteed to be 100% accurate." | ||
) | ||
@ConfigEditorBoolean | ||
@FeatureToggle | ||
public boolean translateOnClick = false; | ||
|
||
@ConfigOption(name = "Language Name", desc = "The name of the language selected below. Note that languages marked as unknown might still be supported.") | ||
@Expose | ||
@ConfigEditorDropdown | ||
public Property<TranslatableLanguage> languageName = Property.of(TranslatableLanguage.ENGLISH); | ||
|
||
@Expose | ||
@ConfigOption( | ||
name = "Language Code", | ||
desc = "Enter a language code here to translate on chat click into another language. " + | ||
"E.g. `es` for spanish or 'de' for german. Empty for english.") | ||
@ConfigEditorText | ||
public Property<String> languageCode = Property.of("en"); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/at/hannibal2/skyhanni/features/chat/translation/TranslatableLanguage.kt
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,45 @@ | ||
package at.hannibal2.skyhanni.features.chat.translation | ||
|
||
enum class TranslatableLanguage(private val englishName: String, private val nativeName: String, val languageCode: String) { | ||
|
||
// 1. First Language - The primary language of the application. | ||
ENGLISH("English", "", "en"), | ||
|
||
// 2. Well Supported - Major languages commonly used in Europe and North America. | ||
SPANISH("Spanish", "Español", "es"), // Major language in Spain and Latin America | ||
GERMAN("German", "Deutsch", "de"), // Important language in Germany, Austria, and Switzerland | ||
FRENCH("French", "Français", "fr"), // Significant language in France, Canada, and parts of Africa | ||
DUTCH("Dutch", "Nederlands", "nl"), // Spoken in the Netherlands and Belgium | ||
RUSSIAN("Russian", "Русский", "ru"), // Major language in Russia and other parts of Eastern Europe and Central Asia | ||
POLISH("Polish", "Polski", "pl"), // Spoken primarily in Poland | ||
ITALIAN("Italian", "Italiano", "it"), // Important language in Italy and parts of Switzerland | ||
UKRAINIAN("Ukrainian", "Українська", "uk"), // Spoken in Ukraine | ||
PORTUGUESE("Portuguese", "Português", "pt"), // Spoken in Portugal and Brazil | ||
TURKISH("Turkish", "Türkçe", "tr"), // Significant in Turkey and Central Asia | ||
SWEDISH("Swedish", "Svenska", "sv"), // Relevant in Northern Europe | ||
|
||
// 3. Global Languages - Widely spoken languages with significant global presence. | ||
CHINESE("Chinese", "中文", "zh"), // Major language in China and other parts of East Asia | ||
ARABIC("Arabic", "العربية", "ar"), // Significant language in the Middle East and North Africa | ||
JAPANESE("Japanese", "日本語", "ja"), // Major language in Japan | ||
HINDI("Hindi", "हिन्दी", "hi"), // Major language in India | ||
BENGALI("Bengali", "বাংলা", "bn"), // Widely spoken in India and Bangladesh | ||
KOREAN("Korean", "한국어", "ko"), // Important for East Asia | ||
VIETNAMESE("Vietnamese", "Tiếng Việt", "vi"), // Major language in Vietnam | ||
INDONESIAN("Indonesian", "Bahasa Indonesia", "id"), // Key language in Southeast Asia | ||
THAI("Thai", "ภาษาไทย", "th"), // Important in Thailand | ||
|
||
// 4. Other Supported Languages | ||
PERSIAN("Persian", "فارسی", "fa"), // Spoken in Iran and other parts of the Middle East | ||
TAGALOG("Tagalog", "Tagalog", "tl"), // Major language in the Philippines | ||
PUNJABI("Punjabi", "ਪੰਜਾਬੀ", "pa"), // Significant in India and Pakistan | ||
|
||
// 5. need better name | ||
UNKNOWN("Unknown Language", "", ""), | ||
; | ||
|
||
// Limit to 20 characters so that the text is not too small in the config | ||
private val displayName: String = if (nativeName.isBlank()) englishName else "$englishName/$nativeName".take(20) | ||
|
||
override fun toString(): String = displayName | ||
} |
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