Merge pull request #939 from oocytanb/fix/m17n_value_caching

Fix incorrect value caching of M17N
This commit is contained in:
ousttrue
2021-05-13 19:23:18 +09:00
committed by GitHub
3 changed files with 41 additions and 1 deletions

View File

@@ -61,7 +61,7 @@ namespace UniGLTF.M17N
{
var match = GetAttribute(value, language);
// Attribute。無かったら enum の ToString
map.Add(value, match != null ? match.Message : key.ToString());
map.Add(value, match != null ? match.Message : value.ToString());
}
s_cache.Add(language, map);

View File

@@ -0,0 +1,29 @@
using NUnit.Framework;
using UniGLTF.M17N;
using UnityEngine;
namespace UniGLTF
{
public class M17NTest
{
enum M17NTestEnum
{
Foo,
Bar,
Baz,
}
[Test]
public void SimpleMsgTest()
{
Assert.AreEqual("Foo", M17NTestEnum.Foo.Msg());
Assert.AreEqual("Bar", M17NTestEnum.Bar.Msg());
Assert.AreEqual("Baz", M17NTestEnum.Baz.Msg());
// test caching
Assert.AreEqual("Foo", M17NTestEnum.Foo.Msg());
Assert.AreEqual("Bar", M17NTestEnum.Bar.Msg());
Assert.AreEqual("Baz", M17NTestEnum.Baz.Msg());
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e993fe746592bab4abe41c880b81555a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: