diff --git a/Assets/Editor/LocalizationExpansionTests.cs b/Assets/Editor/LocalizationExpansionTests.cs index 39939c33b..cb73417e9 100644 --- a/Assets/Editor/LocalizationExpansionTests.cs +++ b/Assets/Editor/LocalizationExpansionTests.cs @@ -24,6 +24,11 @@ namespace AibisDream.SystemEditor.Tests "GetLocalizedNameByKind", BindingFlags.Instance | BindingFlags.NonPublic); + private static readonly MethodInfo GetCharacterVoByKeyMethod = + typeof(YarnUtil).GetMethod( + "GetCharacterVoByKey", + BindingFlags.Static | BindingFlags.NonPublic); + [TestCase("ru", LocaleKind.Ru)] [TestCase("ru-RU", LocaleKind.Ru)] [TestCase("es", LocaleKind.Es)] @@ -48,7 +53,7 @@ namespace AibisDream.SystemEditor.Tests } [Test] - public void CharacterVo_AddedLocaleName_ReturnsTranslationOrKey() + public void CharacterVo_LocalizedName_ReturnsOnlySelectedLocaleContent() { Assert.That(GetLocalizedNameMethod, Is.Not.Null); @@ -65,9 +70,12 @@ namespace AibisDream.SystemEditor.Tests Assert.That(GetLocalizedName(translated, LocaleKind.PtBr), Is.EqualTo(translated.ptBr)); var untranslated = new CharacterVo { key = "actor_key" }; - Assert.That(GetLocalizedName(untranslated, LocaleKind.Ru), Is.EqualTo(untranslated.key)); - Assert.That(GetLocalizedName(untranslated, LocaleKind.Es), Is.EqualTo(untranslated.key)); - Assert.That(GetLocalizedName(untranslated, LocaleKind.PtBr), Is.EqualTo(untranslated.key)); + Assert.That(GetLocalizedName(untranslated, LocaleKind.Cn), Is.Null); + Assert.That(GetLocalizedName(untranslated, LocaleKind.En), Is.Null); + Assert.That(GetLocalizedName(untranslated, LocaleKind.Ja), Is.Null); + Assert.That(GetLocalizedName(untranslated, LocaleKind.Ru), Is.Null); + Assert.That(GetLocalizedName(untranslated, LocaleKind.Es), Is.Null); + Assert.That(GetLocalizedName(untranslated, LocaleKind.PtBr), Is.Null); } [Test] diff --git a/Assets/Scripts/Framework/Config/Character.cs b/Assets/Scripts/Framework/Config/Character.cs index 96a4d27fb..759ed7d73 100644 --- a/Assets/Scripts/Framework/Config/Character.cs +++ b/Assets/Scripts/Framework/Config/Character.cs @@ -76,6 +76,11 @@ namespace AibisDream.Kit rawName = GetLocalizedNameByKind(LocalizationKit.CurrentLocaleKind); } + if (string.IsNullOrWhiteSpace(rawName)) + { + return string.Empty; + } + return string.IsNullOrEmpty(nameColor) ? rawName : $"{rawName}"; } @@ -84,19 +89,18 @@ namespace AibisDream.Kit switch (kind) { case LocaleKind.En: - return string.IsNullOrWhiteSpace(en) ? key : en; + return en; case LocaleKind.Ja: - if (!string.IsNullOrWhiteSpace(ja)) return ja; - return string.IsNullOrWhiteSpace(cn) ? key : cn; + return ja; case LocaleKind.Ru: - return string.IsNullOrWhiteSpace(ru) ? key : ru; + return ru; case LocaleKind.Es: - return string.IsNullOrWhiteSpace(es) ? key : es; + return es; case LocaleKind.PtBr: - return string.IsNullOrWhiteSpace(ptBr) ? key : ptBr; + return ptBr; case LocaleKind.Cn: default: - return string.IsNullOrWhiteSpace(cn) ? key : cn; + return cn; } } diff --git a/Assets/Scripts/Utility/YarnUtil.cs b/Assets/Scripts/Utility/YarnUtil.cs index 2d13f0951..358b7b39d 100644 --- a/Assets/Scripts/Utility/YarnUtil.cs +++ b/Assets/Scripts/Utility/YarnUtil.cs @@ -134,6 +134,11 @@ namespace AibisDream.Utility { key = charKey, cn = charKey, + en = charKey, + ja = charKey, + ru = charKey, + es = charKey, + ptBr = charKey, role = ActorRole.Aside }; }