Open Source Web Application Framework for ASP.NET Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
1.6 KiB

using System;
using System.Globalization;
using JetBrains.Annotations;
namespace Volo.Abp.Localization;
[Serializable]
public class LanguageInfo : ILanguageInfo
{
[NotNull]
public virtual string CultureName { get; protected set; }
[NotNull]
public virtual string UiCultureName { get; protected set; }
[NotNull]
public virtual string DisplayName { get; protected set; }
[NotNull]
public virtual string TwoLetterISOLanguageName { get; protected set; }
[CanBeNull]
public virtual string FlagIcon { get; set; }
protected LanguageInfo()
{
}
public LanguageInfo(
string cultureName,
string uiCultureName = null,
string displayName = null,
string flagIcon = null)
{
ChangeCultureInternal(cultureName, uiCultureName, displayName);
FlagIcon = flagIcon;
}
public virtual void ChangeCulture(string cultureName, string uiCultureName = null, string displayName = null)
{
ChangeCultureInternal(cultureName, uiCultureName, displayName);
}
private void ChangeCultureInternal(string cultureName, string uiCultureName, string displayName)
{
CultureName = Check.NotNullOrWhiteSpace(cultureName, nameof(cultureName));
UiCultureName = !uiCultureName.IsNullOrWhiteSpace()
? uiCultureName
: cultureName;
DisplayName = !displayName.IsNullOrWhiteSpace()
? displayName
: cultureName;
TwoLetterISOLanguageName = new CultureInfo(cultureName)
.TwoLetterISOLanguageName;
}
}