mirror of https://github.com/abpframework/abp
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.
62 lines
1.6 KiB
62 lines
1.6 KiB
using System;
|
|
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 ShortDisplayName { 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;
|
|
|
|
var culture = new System.Globalization.CultureInfo(cultureName);
|
|
|
|
ShortDisplayName = culture.TwoLetterISOLanguageName;
|
|
}
|
|
}
|