You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add custom internationalization provider support (#2)
fixes addSubcategoryDescription requiring the localized subcategory name
The subcategory comparator in SortingBehavior is still passed the localized version of names. This is not ideal, but changing this would require breaking changes (or introducing a new version of SortingBehavior).
EssentialGG#55
Copy file name to clipboardExpand all lines: api/Vigilance.api
+12
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,8 @@ public abstract class gg/essential/vigilance/Vigilant {
14
14
public fun <init> (Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;)V
15
15
public fun <init> (Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;)V
16
16
public synthetic fun <init> (Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
17
+
public fun <init> (Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;Lgg/essential/vigilance/i18n/I18nProvider;)V
18
+
public synthetic fun <init> (Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;Lgg/essential/vigilance/i18n/I18nProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
17
19
public final fun addDependency (Ljava/lang/String;Ljava/lang/String;)V
18
20
public final fun addDependency (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
19
21
public final fun addDependency (Ljava/lang/reflect/Field;Ljava/lang/reflect/Field;)V
@@ -26,6 +28,7 @@ public abstract class gg/essential/vigilance/Vigilant {
26
28
public final fun getCategories ()Ljava/util/List;
27
29
public final fun getCategoryFromSearch (Ljava/lang/String;)Lgg/essential/vigilance/data/Category;
28
30
public final fun getGuiTitle ()Ljava/lang/String;
31
+
public final fun getI18nProvider ()Lgg/essential/vigilance/i18n/I18nProvider;
29
32
protected fun getMigrations ()Ljava/util/List;
30
33
public final fun getSortingBehavior ()Lgg/essential/vigilance/data/SortingBehavior;
31
34
public final fun gui ()Lgg/essential/vigilance/gui/SettingsGui;
@@ -667,6 +670,15 @@ public final class gg/essential/vigilance/gui/settings/TextComponent : gg/essent
667
670
public fun closePopups (Z)V
668
671
}
669
672
673
+
public abstract interface class gg/essential/vigilance/i18n/I18nProvider {
674
+
public abstract fun translate (Ljava/lang/String;)Ljava/lang/String;
675
+
}
676
+
677
+
public final class gg/essential/vigilance/i18n/PlatformI18nProvider : gg/essential/vigilance/i18n/I18nProvider {
678
+
public static final field INSTANCE Lgg/essential/vigilance/i18n/PlatformI18nProvider;
679
+
public fun translate (Ljava/lang/String;)Ljava/lang/String;
680
+
}
681
+
670
682
public final class gg/essential/vigilance/utils/ExtensionsKt {
671
683
public static final fun onLeftClick (Lgg/essential/elementa/UIComponent;Lkotlin/jvm/functions/Function2;)Lgg/essential/elementa/UIComponent;
name ="This is a switch property with a very long name. It is recommended to use the description for lengthy property text, however this is still supported",
"Buttons are a great way for the user to run an action. Buttons don't have any associated state, and as such their annotation target has to be a method."
582
623
)
624
+
625
+
setSubcategoryDescription(
626
+
"Property Deep-Dive",
627
+
"config.subcategory.localized",
628
+
"config.subcategory.localized.description"
629
+
)
630
+
}
631
+
632
+
object ExampleI18nProvider : I18nProvider {
633
+
overridefuntranslate(key:String): String=
634
+
when(key) {
635
+
"config.subcategory.localized"->"Localized"
636
+
"config.subcategory.localized.description"->"Vigilance has (some) localization support!"
0 commit comments