Skip to content

Commit

Permalink
Merge pull request #939 from oocytanb/fix/m17n_value_caching
Browse files Browse the repository at this point in the history
Fix incorrect value caching of M17N
  • Loading branch information
ousttrue authored May 13, 2021
2 parents c4ef86c + 07ff382 commit 7095fda
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Assets/UniGLTF/Editor/UniGLTF/ExportDialog/M17N.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static string Get(Languages language, T key)
{
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);
Expand Down
29 changes: 29 additions & 0 deletions Assets/UniGLTF/Tests/UniGLTF/M17NTest.cs
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
11 changes: 11 additions & 0 deletions Assets/UniGLTF/Tests/UniGLTF/M17NTest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7095fda

Please sign in to comment.