From 385068a3de48cb9593b08a7866add045e536f94c Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 19 Apr 2024 07:52:59 +0000 Subject: [PATCH] Fixes --- app/src/main/java/io/xpipe/app/core/AppI18n.java | 4 ---- .../java/io/xpipe/core/util/CoreJacksonModule.java | 14 ++++++++++---- lang/README.md | 6 +++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/core/AppI18n.java b/app/src/main/java/io/xpipe/app/core/AppI18n.java index 2d3f634b..e6c1b66c 100644 --- a/app/src/main/java/io/xpipe/app/core/AppI18n.java +++ b/app/src/main/java/io/xpipe/app/core/AppI18n.java @@ -90,10 +90,6 @@ public class AppI18n { private static String getCallerModuleName() { var callers = CallingClass.INSTANCE.getCallingClasses(); for (Class caller : callers) { - if (caller.isSynthetic()) { - continue; - } - if (caller.equals(CallingClass.class) || caller.equals(ModuleHelper.class) || caller.equals(ModalOverlayComp.class) diff --git a/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java b/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java index 6b1ad477..9ca22943 100644 --- a/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java +++ b/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java @@ -1,5 +1,6 @@ package io.xpipe.core.util; +import com.fasterxml.jackson.databind.*; import io.xpipe.core.dialog.BaseQueryElement; import io.xpipe.core.dialog.BusyElement; import io.xpipe.core.dialog.ChoiceElement; @@ -13,10 +14,6 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.ObjectIdGenerators; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.fasterxml.jackson.databind.module.SimpleModule; @@ -99,6 +96,15 @@ public class CoreJacksonModule extends SimpleModule { @Override public ShellDialect deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + var tree = JacksonMapper.getDefault().readTree(p); + if (tree.isObject()) { + var t = (JsonNode) tree.get("type"); + if (t == null) { + return null; + } + return ShellDialects.byNameIfPresent(t.asText()).orElse(null); + } + return ShellDialects.byNameIfPresent(p.getValueAsString()).orElse(null); } } diff --git a/lang/README.md b/lang/README.md index 4b65c50e..2dca9ba3 100644 --- a/lang/README.md +++ b/lang/README.md @@ -19,12 +19,16 @@ has to be transformed into #custom key=Correct translation ``` -to mark it being a custom string that should be kept. +to mark it being a custom string that should be kept. It is important to include the `#custom` annotation. ### Correcting texts If you want to correct something in a text in a `.md` file, you don't have to do anything special as these are not being overwritten later on. Just perform and submit your changes. +### Improving automatic translations + +If a string translated from english is wrong in many languages, it might also make sense to adjust the initial translation and context setting to improve the automatic translation. It is possible to augment the original english string and regenerate the translations for that by adding a `#context: ...` annotation to an original english string that is not translated correctly to improve the accuracy. You will already see some english strings that have this information added. + ### Trying them out in action If you have cloned this repository, you can automatically run a developer build of XPipe by following the instructions in the [contribution guide](/CONTRIBUTING.md). This will use your modified translations, so you can see how they look and behave in practice.