Skip to content
Merged
Show file tree
Hide file tree
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
41 changes: 41 additions & 0 deletions Translator.Tests/Services/ManifestGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,45 @@ await File.WriteAllTextAsync(translationFile, """
Assert.Equal("alice|https://github.com/alice", entry.Maintainer);
Assert.Equal(ComputeSha256(translationFile), entry.Sha);
Assert.Matches("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$", entry.Updated);
Assert.False(entry.Rtl);
}
finally
{
if (Directory.Exists(tempDir))
{
Directory.Delete(tempDir, recursive: true);
}
}
}

[Fact]
public async Task GenerateManifest_SetsRtlTrue_ForRightToLeftLanguage()
{
var tempDir = CreateTempDirectory();
var translationsDir = Path.Combine(tempDir, "translations");
Directory.CreateDirectory(translationsDir);
var translationFile = Path.Combine(translationsDir, "Arabic.json");
var manifestPath = Path.Combine(tempDir, "manifest.json");

try
{
await File.WriteAllTextAsync(translationFile, """
{
"_maintainer": "omar|https://github.com/omar",
"hello": "مرحبا"
}
""");

var sut = CreateSut();
var result = await sut.GenerateManifest(translationsDir, manifestPath);

Assert.True(result);
var manifest = await ReadManifest(manifestPath);
var entry = Assert.Single(manifest.Languages);

Assert.Equal("ar", entry.Code);
Assert.Equal("Arabic", entry.Name);
Assert.True(entry.Rtl);
}
finally
{
Expand Down Expand Up @@ -118,6 +157,7 @@ await File.WriteAllTextAsync(translationFile, """
Bcp47: "fr-FR",
Name: "French",
Native: "Français",
Rtl: false,
File: "translations/French.json",
Sha: existingSha,
Maintainer: "old",
Expand Down Expand Up @@ -171,6 +211,7 @@ await File.WriteAllTextAsync(translationFile, """
Bcp47: "fr-FR",
Name: "French",
Native: "Français",
Rtl: false,
File: "translations/French.json",
Sha: "deadbeef",
Maintainer: "old",
Expand Down
1 change: 1 addition & 0 deletions Translator/Models/ManifestEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public record ManifestEntry(
string Bcp47, // "fr-FR"
string Name, // "French"
string Native, // "Français"
bool Rtl, // right-to-left indicator
string File, // "translations/french.json"
string Sha, // "abc123..."
string? Maintainer, // "teamssUTXO|https://github.com/teamssUTXO"
Expand Down
1 change: 1 addition & 0 deletions Translator/Services/ManifestGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private async Task<ManifestEntry> BuildEntry(string filePath, ManifestEntry? exi
Bcp47: langInfo.Code,
Name: langInfo.Name,
Native: langInfo.NativeName,
Rtl: langInfo.IsRightToLeft,
File: "translations/" + fileName + ".json",
Sha: hashedFile,
Maintainer: maintainer,
Expand Down
Loading