Skip to content

Commit

Permalink
fix Korean script for NLLB: sillsdev/serval#290
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Jan 30, 2024
1 parent 1fa22b7 commit 5017802
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/SIL.Machine.AspNetCore/Services/LanguageTagService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ public class LanguageTagService : ILanguageTagService
private static readonly Dictionary<string, string> StandardLanguages =
new() { { "ar", "arb" }, { "ms", "zsm" }, { "lv", "lvs" }, { "ne", "npi" }, { "sw", "swh" }, { "cmn", "zh" } };

private static readonly Dictionary<string, string> StandardScripts = new() { { "Kore", "Hang" } };

private readonly Dictionary<string, string> _defaultScripts;

private readonly Dictionary<string, string> _flores200Languages;
Expand Down Expand Up @@ -127,6 +129,10 @@ private string ResolveLanguageTag(string languageTag)
else if (_defaultScripts.TryGetValue(languageSubtag, out string? tempScript))
script = tempScript;

// There are a few extra conversions not in SIL Writing Systems that we need to handle
if (script is not null && StandardScripts.TryGetValue(script, out string? tempScript3))
script = tempScript3;

if (script is not null)
return $"{iso639_3Code}_{script}";
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public LanguageTagServiceTests()
[TestCase("arb", "arb_Arab", Description = "Arabic")]
[TestCase("eng", "eng_Latn", Description = "InsteadOfISO639_1")]
[TestCase("eng-Latn", "eng_Latn", Description = "DashToUnderscore")]
[TestCase("kor", "kor_Hang", Description = "KoreanScript")]
[TestCase("kor_Kore", "kor_Hang", Description = "KoreanScriptCorrection")]
public void ConvertToFlores200CodeTest(string language, string internalCodeTruth)
{
_languageTagService.ConvertToFlores200Code(language, out string internalCode);
Expand Down

0 comments on commit 5017802

Please sign in to comment.