Skip to content

Commit

Permalink
Merge pull request #2253 from andy840119/translate-to-translation
Browse files Browse the repository at this point in the history
Rename from translate to translation(s) everywhere.
  • Loading branch information
andy840119 authored Jul 5, 2024
2 parents 600fd57 + 27b1039 commit 775b93d
Show file tree
Hide file tree
Showing 56 changed files with 319 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void TestDecodeBeatmapLyric()
}

[Test]
public void TestDecodeNote()
public void TestDecodeNotes()
{
// Karaoke beatmap
var beatmap = decodeBeatmap("karaoke-note-samples");
Expand All @@ -77,34 +77,34 @@ public void TestDecodeNote()
}

[Test]
public void TestDecodeTranslate()
public void TestDecodeTranslations()
{
// Karaoke beatmap
var beatmap = decodeBeatmap("karaoke-translate-samples");
var beatmap = decodeBeatmap("karaoke-translation-samples");

// Get translate
var translates = beatmap.AvailableTranslates();
// Get translations
var translations = beatmap.AvailableTranslationLanguages();
var lyrics = beatmap.HitObjects.OfType<Lyric>().ToList();

// Check is not null
Assert.IsNotNull(translates);
Assert.IsNotNull(translations);

// Check translate count
Assert.AreEqual(2, translates.Count);
// Check translations count
Assert.AreEqual(2, translations.Count);

// All lyric should have two translates
Assert.AreEqual(2, lyrics[0].Translates.Count);
Assert.AreEqual(2, lyrics[1].Translates.Count);
// All lyric should have two translations
Assert.AreEqual(2, lyrics[0].Translations.Count);
Assert.AreEqual(2, lyrics[1].Translations.Count);

// Check chinese translate
var chineseLanguageId = translates[0];
Assert.AreEqual("卡拉OK", lyrics[0].Translates[chineseLanguageId]);
Assert.AreEqual("喜歡", lyrics[1].Translates[chineseLanguageId]);
// Check chinese translations
var chineseLanguageId = translations[0];
Assert.AreEqual("卡拉OK", lyrics[0].Translations[chineseLanguageId]);
Assert.AreEqual("喜歡", lyrics[1].Translations[chineseLanguageId]);

// Check english translate
var englishLanguageId = translates[1];
Assert.AreEqual("karaoke", lyrics[0].Translates[englishLanguageId]);
Assert.AreEqual("like it", lyrics[1].Translates[englishLanguageId]);
// Check english translations
var englishLanguageId = translations[1];
Assert.AreEqual("karaoke", lyrics[0].Translations[englishLanguageId]);
Assert.AreEqual("like it", lyrics[1].Translations[englishLanguageId]);
}

private static KaraokeBeatmap decodeBeatmap(string fileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override void LoadComplete()
[TestCase("karaoke-file-samples")]
[TestCase("karaoke-file-samples-without-note")]
[TestCase("karaoke-note-samples")]
[TestCase("karaoke-translate-samples")]
[TestCase("karaoke-translation-samples")]
public void TestNullBeatmap(string fileName)
{
using var resStream = TestResources.OpenBeatmapResource(fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void TestAdd()
{
SetUpKaraokeBeatmap(karaokeBeatmap =>
{
karaokeBeatmap.AvailableTranslates = new List<CultureInfo>
karaokeBeatmap.AvailableTranslationLanguages = new List<CultureInfo>
{
new("zh-TW"),
};
Expand All @@ -31,9 +31,9 @@ public void TestAdd()

AssertKaraokeBeatmap(karaokeBeatmap =>
{
Assert.AreEqual(2, karaokeBeatmap.AvailableTranslates.Count);
Assert.AreEqual(new CultureInfo("zh-TW"), karaokeBeatmap.AvailableTranslates[0]);
Assert.AreEqual(new CultureInfo("Ja-jp"), karaokeBeatmap.AvailableTranslates[1]);
Assert.AreEqual(2, karaokeBeatmap.AvailableTranslationLanguages.Count);
Assert.AreEqual(new CultureInfo("zh-TW"), karaokeBeatmap.AvailableTranslationLanguages[0]);
Assert.AreEqual(new CultureInfo("Ja-jp"), karaokeBeatmap.AvailableTranslationLanguages[1]);
});
}

Expand All @@ -42,7 +42,7 @@ public void TestRemove()
{
SetUpKaraokeBeatmap(karaokeBeatmap =>
{
karaokeBeatmap.AvailableTranslates = new List<CultureInfo>
karaokeBeatmap.AvailableTranslationLanguages = new List<CultureInfo>
{
new("zh-TW"),
new("Ja-jp"),
Expand All @@ -56,17 +56,17 @@ public void TestRemove()

AssertKaraokeBeatmap(karaokeBeatmap =>
{
Assert.AreEqual(1, karaokeBeatmap.AvailableTranslates.Count);
Assert.AreEqual(new CultureInfo("zh-TW"), karaokeBeatmap.AvailableTranslates[0]);
Assert.AreEqual(1, karaokeBeatmap.AvailableTranslationLanguages.Count);
Assert.AreEqual(new CultureInfo("zh-TW"), karaokeBeatmap.AvailableTranslationLanguages[0]);
});
}

[Test]
public void TestIsLanguageContainsTranslate()
public void TestIsLanguageContainsTranslation()
{
SetUpKaraokeBeatmap(karaokeBeatmap =>
{
karaokeBeatmap.AvailableTranslates = new List<CultureInfo>
karaokeBeatmap.AvailableTranslationLanguages = new List<CultureInfo>
{
new("zh-TW"),
new("Ja-jp"),
Expand All @@ -75,7 +75,7 @@ public void TestIsLanguageContainsTranslate()

PrepareHitObject(() => new Lyric
{
Translates = new Dictionary<CultureInfo, string>
Translations = new Dictionary<CultureInfo, string>
{
{
new("zh-TW"), "卡拉 OK"
Expand All @@ -85,16 +85,16 @@ public void TestIsLanguageContainsTranslate()

TriggerHandlerChanged(c =>
{
Assert.AreEqual(false, c.IsLanguageContainsTranslate(new CultureInfo("Ja-jp")));
Assert.AreEqual(true, c.IsLanguageContainsTranslate(new CultureInfo("zh-TW")));
Assert.AreEqual(false, c.IsLanguageContainsTranslation(new CultureInfo("Ja-jp")));
Assert.AreEqual(true, c.IsLanguageContainsTranslation(new CultureInfo("zh-TW")));
});
}

protected override void SetUpKaraokeBeatmap(Action<KaraokeBeatmap> action)
{
base.SetUpKaraokeBeatmap(karaokeBeatmap =>
{
karaokeBeatmap.AvailableTranslates = new List<CultureInfo>();
karaokeBeatmap.AvailableTranslationLanguages = new List<CultureInfo>();

action(karaokeBeatmap);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,83 +10,83 @@

namespace osu.Game.Rulesets.Karaoke.Tests.Editor.ChangeHandlers.Lyrics;

public partial class LyricTranslateChangeHandlerTest : LyricPropertyChangeHandlerTest<LyricTranslateChangeHandler>
public partial class LyricTranslationChangeHandlerTest : LyricPropertyChangeHandlerTest<LyricTranslationChangeHandler>
{
[Test]
public void TestUpdateTranslateWithNewLanguage()
public void TestUpdateTranslationWithNewLanguage()
{
PrepareHitObject(() => new Lyric
{
Text = "カラオケ",
});

TriggerHandlerChanged(c => c.UpdateTranslate(new CultureInfo(17), "からおけ"));
TriggerHandlerChanged(c => c.UpdateTranslation(new CultureInfo(17), "からおけ"));

AssertSelectedHitObject(h =>
{
Assert.AreEqual(1, h.Translates.Count);
Assert.AreEqual("からおけ", h.Translates[new CultureInfo(17)]);
Assert.AreEqual(1, h.Translations.Count);
Assert.AreEqual("からおけ", h.Translations[new CultureInfo(17)]);
});
}

[Test]
public void TestUpdateTranslateWithExistLanguage()
public void TestUpdateTranslationWithExistLanguage()
{
PrepareHitObject(() => new Lyric
{
Text = "カラオケ",
Translates = new Dictionary<CultureInfo, string>
Translations = new Dictionary<CultureInfo, string>
{
{ new CultureInfo(17), "からおけ" },
},
});

TriggerHandlerChanged(c => c.UpdateTranslate(new CultureInfo(17), "karaoke"));
TriggerHandlerChanged(c => c.UpdateTranslation(new CultureInfo(17), "karaoke"));

AssertSelectedHitObject(h =>
{
Assert.AreEqual(1, h.Translates.Count);
Assert.AreEqual("karaoke", h.Translates[new CultureInfo(17)]);
Assert.AreEqual(1, h.Translations.Count);
Assert.AreEqual("karaoke", h.Translations[new CultureInfo(17)]);
});
}

[Test]
public void TestUpdateTranslateWithEmptyText()
public void TestUpdateTranslationWithEmptyText()
{
PrepareHitObject(() => new Lyric
{
Text = "カラオケ",
Translates = new Dictionary<CultureInfo, string>
Translations = new Dictionary<CultureInfo, string>
{
{ new CultureInfo(17), "からおけ" },
},
});

TriggerHandlerChanged(c => c.UpdateTranslate(new CultureInfo(17), string.Empty));
TriggerHandlerChanged(c => c.UpdateTranslation(new CultureInfo(17), string.Empty));

AssertSelectedHitObject(h =>
{
Assert.IsEmpty(h.Translates);
Assert.IsEmpty(h.Translations);
});
}

[Test]
public void TestUpdateTranslateWithNullText()
public void TestUpdateTranslationWithNullText()
{
PrepareHitObject(() => new Lyric
{
Text = "カラオケ",
Translates = new Dictionary<CultureInfo, string>
Translations = new Dictionary<CultureInfo, string>
{
{ new CultureInfo(17), "からおけ" },
},
});

TriggerHandlerChanged(c => c.UpdateTranslate(new CultureInfo(17), string.Empty));
TriggerHandlerChanged(c => c.UpdateTranslation(new CultureInfo(17), string.Empty));

AssertSelectedHitObject(h =>
{
Assert.IsEmpty(h.Translates);
Assert.IsEmpty(h.Translations);
});
}

Expand All @@ -98,6 +98,6 @@ public void TestWithReferenceLyric()
Text = "カラオケ",
});

TriggerHandlerChangedWithException<ChangeForbiddenException>(c => c.UpdateTranslate(new CultureInfo(17), "からおけ"));
TriggerHandlerChangedWithException<ChangeForbiddenException>(c => c.UpdateTranslation(new CultureInfo(17), "からおけ"));
}
}
Loading

0 comments on commit 775b93d

Please sign in to comment.