Skip to content

Commit

Permalink
Ensure to get information when length > 0 to avoid errors - related t…
Browse files Browse the repository at this point in the history
…o previous commit.

Signed-off-by: Lionel DUCHATEAU <lionel.duchateau@free.fr>
  • Loading branch information
Kurtnoise-zeus committed Jul 12, 2024
1 parent da43c77 commit 5e79b17
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions core/util/LanguageSelectionContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,18 +494,21 @@ public static string LookupISOCode(string code)
{
// we may have language information w/ more than ISO Codes e.g "en-US/English (US)"
int position = code.IndexOf("-");
string ncode = code.Substring(0, position);
if (ncode.Length == 2)
if ( position >= 0)
{
if (languagesReverseISO2.ContainsKey(ncode))
return languagesReverseISO2[ncode];
}
else if (ncode.Length == 3)
{
if (languagesReverseBibliographic.ContainsKey(ncode))
return languagesReverseBibliographic[ncode];
else if (languagesReverseTerminology.ContainsKey(ncode))
return languagesReverseTerminology[ncode];
string ncode = code.Substring(0, position);
if (ncode.Length == 2)
{
if (languagesReverseISO2.ContainsKey(ncode))
return languagesReverseISO2[ncode];
}
else if (ncode.Length == 3)
{
if (languagesReverseBibliographic.ContainsKey(ncode))
return languagesReverseBibliographic[ncode];
else if (languagesReverseTerminology.ContainsKey(ncode))
return languagesReverseTerminology[ncode];
}
}
else return "";
}
Expand Down

0 comments on commit 5e79b17

Please sign in to comment.