JPP: Removed enum from kaas talk localizer
Some checks failed
Run test asserts / Test-Asserts (push) Failing after 45s
Some checks failed
Run test asserts / Test-Asserts (push) Failing after 45s
This commit is contained in:
parent
4ba8edbb6e
commit
04d6d2e3b3
9 changed files with 86 additions and 22 deletions
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
package ᒢᣘᐧᐧ.ᑊᑉᣔᣔᔆ.ᐪᣔᒻᑊᑉ;
|
||||
|
||||
/// Marker interface for using babel blue text.
|
||||
/// Marker interface for using kaas talk text.
|
||||
///
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
|
|
|
|||
|
|
@ -35,21 +35,23 @@ import ᒢᣘᐧᐧ.ᣕᓫᐪᑋᓫᣗ.ᐪᐤᣕᓫ.NetherTone;
|
|||
///
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public enum KaasTalkTextFactory {
|
||||
亞;
|
||||
public final class KaasTalkTextLocalizer {
|
||||
|
||||
public String buildMessage(final Class<? extends KaasTalkText> babelMsg, final Object...msgArgs) {
|
||||
return buildMessage(null , babelMsg, msgArgs);
|
||||
private KaasTalkTextLocalizer() {
|
||||
}
|
||||
|
||||
static public String format(final Class<? extends KaasTalkText> babelMsg, final Object...msgArgs) {
|
||||
return formatToned(null , babelMsg, msgArgs);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String buildMessage(final Class<? extends NetherTone> linguaId, final Class<? extends KaasTalkText> babelMsg, final Object...msgArgs) {
|
||||
static public String formatToned(final Class<? extends NetherTone> linguaId, final Class<? extends KaasTalkText> babelMsg, final Object...msgArgs) {
|
||||
if (babelMsg == null) {
|
||||
throw new NullPointerException("No babel message class given.");
|
||||
throw new NullPointerException("No kaas talk message class given.");
|
||||
}
|
||||
Object[] formatArgs = Arrays.asList(msgArgs).stream().map(v -> {
|
||||
if (v instanceof Class<?> && KaasTalkText.class.isAssignableFrom((Class<?>)v)) {
|
||||
return buildMessage(linguaId, (Class<KaasTalkText>)v);
|
||||
return formatToned(linguaId, (Class<KaasTalkText>)v);
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
|
|
@ -60,7 +62,7 @@ public enum KaasTalkTextFactory {
|
|||
}
|
||||
KaasTalkTextRepeatable注 stringTower = babelMsg.getAnnotation(KaasTalkTextRepeatable注.class);
|
||||
if (stringTower == null) {
|
||||
throw new RuntimeException("No BabelẞlueText注 annotation on: " + babelMsg);
|
||||
throw new RuntimeException("No KaasTalkText注 annotation on: " + babelMsg);
|
||||
}
|
||||
KaasTalkText注 fallback = null;
|
||||
for (KaasTalkText注 duyts:stringTower.value()) {
|
||||
|
|
@ -77,6 +79,6 @@ public enum KaasTalkTextFactory {
|
|||
if (fallback != null) {
|
||||
return String.format(fallback.txt(), formatArgs);
|
||||
}
|
||||
throw new RuntimeException("Empty BabelẞlueTextRepeatable注 annotations on: " + babelMsg);
|
||||
throw new RuntimeException("Empty KaasTalkTextRepeatable注 annotations on: " + babelMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/// Babel blue translations text container.
|
||||
/// Kaas talk translations text container.
|
||||
///
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.lang.annotation.Target;
|
|||
|
||||
import ᒢᣘᐧᐧ.ᣕᓫᐪᑋᓫᣗ.ᐪᐤᣕᓫ.NetherTone;
|
||||
|
||||
/// Define babel blue text.
|
||||
/// Define kaas talk text.
|
||||
///
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package ᒢᣘᐧᐧ.ᑊᑉᣔᣔᔆ.ᐪᣔᒻᑊᑉ;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class KaasTalkTextLocalizerTest {
|
||||
|
||||
@KaasTalkText注(嘴 = 嘴ᗮᙿᗮ.English.class, txt = "Missing required annotation %s on %s")
|
||||
@KaasTalkText注(嘴 = 嘴ᗮᙿᗮ.Dutch.class, txt = "Ontbrekende vereiste annotatie %s op %s")
|
||||
@KaasTalkText注(嘴 = 嘴ᗮᙿᗮ.China.class, txt = "%s 上缺少必需的註釋 %s")
|
||||
@KaasTalkText注(嘴 = 嘴ᗮᙿᗮ.Hindi.class, txt = "%s पर आवश्यक एनोटेशन %s गुम है")
|
||||
protected enum ₜₓₜMissingAnnotationTest implements KaasTalkText {}
|
||||
|
||||
@Test
|
||||
public void testFormat() {
|
||||
Assertions.assertThrows(NullPointerException.class, () -> {
|
||||
KaasTalkTextLocalizer.format(null);
|
||||
});
|
||||
Assertions.assertNotNull(KaasTalkTextLocalizer.formatToned(嘴ᗮᙿᗮ.English.class, ₜₓₜMissingAnnotationTest.class, "", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatTonedEN() {
|
||||
String res = KaasTalkTextLocalizer.formatToned(嘴ᗮᙿᗮ.English.class, ₜₓₜMissingAnnotationTest.class, "foo", "bar");
|
||||
Assertions.assertNotNull(res);
|
||||
Assertions.assertTrue(res.contains("required"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatTonedCN() {
|
||||
String res = KaasTalkTextLocalizer.formatToned(嘴ᗮᙿᗮ.China.class, ₜₓₜMissingAnnotationTest.class, "foo", "bar");
|
||||
Assertions.assertNotNull(res);
|
||||
Assertions.assertTrue(res.contains("必需"));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue