Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Language Localization Integration Test #1419

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Localization;
using Content.Shared.Language;
using System.Linq;
using System.Collections.Generic;

namespace Content.IntegrationTests.Tests.Traits;

/// <summary>
/// Checks if every language has a valid name, chatname, and description localization string.
/// </summary>
[TestFixture]
[TestOf(typeof(LanguagePrototype))]
public sealed class LanguageLocalizationTest
{
[Test]
public async Task TestLanguageLocalization()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var locale = server.ResolveDependency<ILocalizationManager>();
var proto = server.ResolveDependency<IPrototypeManager>();

await server.WaitAssertion(() =>
{
var missingStrings = new List<string>();

foreach (var langProto in proto.EnumeratePrototypes<LanguagePrototype>().OrderBy(a => a.ID))
foreach (var locString in new List<string> { $"language-{langProto.ID}-name", $"chat-language-{langProto.ID}-name", $"language-{langProto.ID}-description" })
if (!locale.HasString(locString))
missingStrings.Add($"\"{langProto.ID}\", \"{locString}\"");

Assert.That(!missingStrings.Any(), Is.True, $"The following languages are missing localization strings:\n {string.Join("\n ", missingStrings)}");
});

await pair.CleanReturnAsync();
}
}
Loading