Skip to content

Commit

Permalink
Fixed getting language name.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-kondratov committed Aug 19, 2024
1 parent 42605de commit ae90bb9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public AzureOpenAIMessageProvider(IOptions<PillsBotOptions> options,

_languages = options.Value.AI.Languages
.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)
.Select(input => (code: input, name: GetISOLanguageName(input)))
.Select(input => (code: input, name: GetLanguageName(input)))
.Where(pair => pair.name is not null)
.ToDictionary(pair => pair.code, pair => pair.name!)
.AsReadOnly();
Expand Down Expand Up @@ -151,12 +151,12 @@ private string GetPrompt(string language)
return message;
}

private string? GetISOLanguageName(string input)
private string? GetLanguageName(string input)
{
try
{
var culture = CultureInfo.GetCultureInfo(input, true);
return culture.TwoLetterISOLanguageName;
return culture.DisplayName;
}
catch (CultureNotFoundException exception)
{
Expand Down

0 comments on commit ae90bb9

Please sign in to comment.