Skip to content

Commit

Permalink
Fix backportI18nSuppoprt break tweakermore translation logic (#153)
Browse files Browse the repository at this point in the history
Signed-off-by: Hendrix-Shen <[email protected]>
  • Loading branch information
Hendrix-Shen committed Jan 18, 2025
1 parent bfe4b00 commit 6bfdfe8
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ public abstract class MixinConfigBase implements IConfigBase {
private static final ValueContainer<Class<?>> masa_gadget_mod$tweakerMoreIConfigBaseClass = ReflectionUtil
.getClass("me.fallenbreath.tweakermore.config.options.TweakerMoreIConfigBase");

@Inject(
method = "getComment",
at = @At("RETURN"),
cancellable = true
)
@Inject(method = "getComment", at = @At("RETURN"), cancellable = true)
private void useI18nComment(CallbackInfoReturnable<String> cir) {
if (Configs.backportI18nSupport.getBooleanValue()) {
cir.setReturnValue(MiscUtil.getTranslatedOrFallback("config.comment." + this.getName().toLowerCase(),
Expand All @@ -56,20 +52,16 @@ public String getConfigGuiDisplayName() {
}

@SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"})
@Inject(
method = "getConfigGuiDisplayName",
at = @At("HEAD"),
cancellable = true
)
@Inject(method = "getConfigGuiDisplayName", at = @At("HEAD"), cancellable = true)
private void patchGetConfigGuiDisplayName(CallbackInfoReturnable<String> cir) {
if (MixinConfigBase.masa_gadget_mod$tweakerMoreIConfigBaseClass
.filter(clazz -> clazz.isInstance(this)).isPresent()) {
cir.setReturnValue(I18n.tr("tweakermore.config.".concat(this.getName())));
return;
}

if (Configs.backportI18nSupport.getBooleanValue()) {
cir.setReturnValue(I18n.translateOrFallback("config.name." + this.getName().toLowerCase(),
this.getName()));
cir.setReturnValue(I18n.translateOrFallback("config.name.".concat(this.getName().toLowerCase()), this.getName()));
}
}
}

0 comments on commit 6bfdfe8

Please sign in to comment.