mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
3153326be6
(fix problems with Mono/Wine)
29 lines
1.1 KiB
C#
29 lines
1.1 KiB
C#
using System.Globalization;
|
|
|
|
namespace Nikse.SubtitleEdit.Core
|
|
{
|
|
public static class CultureExtensions
|
|
{
|
|
/// <summary>
|
|
/// Get three letter ISO code from CultureInfo object (three letter ISO code seems to be blank sometimes on Mono/Wine).
|
|
/// </summary>
|
|
/// <param name="cultureInfo">CultureInfo object</param>
|
|
/// <returns>Three letter ISO language code, if failure then string.Empty is returned.</returns>
|
|
public static string GetThreeLetterIsoLanguageName(this CultureInfo cultureInfo)
|
|
{
|
|
if (cultureInfo == null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var cultureThreeLetterIsoLanguageName = cultureInfo.ThreeLetterISOLanguageName;
|
|
if (string.IsNullOrEmpty(cultureThreeLetterIsoLanguageName))
|
|
{
|
|
cultureThreeLetterIsoLanguageName = Iso639Dash2LanguageCode.GetThreeLetterCodeFromTwoLetterCode(cultureInfo.TwoLetterISOLanguageName);
|
|
}
|
|
|
|
return cultureThreeLetterIsoLanguageName;
|
|
}
|
|
}
|
|
}
|