init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
49
Framework/Localization/GenericLocalizer.cs
Normal file
49
Framework/Localization/GenericLocalizer.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Kreta.Framework.Localization
|
||||
{
|
||||
/// <summary>
|
||||
/// Általános <see cref="ILocalizer"/> megvalósítás.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Az általános megvalósítás egyenértékű az objektumon végrehajtott <see cref="object.ToString()"/> hívással,
|
||||
/// azzal a különbséggel, hogy figyelembe veszi, ha az objektum megvalósítja az <see cref="IFormattable"/>
|
||||
/// felületet.
|
||||
/// </remarks>
|
||||
internal sealed class GenericLocalizer : ILocalizer
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály alapértelmezett konstruktora.
|
||||
/// </summary>
|
||||
public GenericLocalizer()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lásd <see cref="ILocalizer.Localize"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Lásd <see cref="ILocalizer.Localize"/></param>
|
||||
/// <param name="cultureInfo">Lásd <see cref="ILocalizer.Localize"/></param>
|
||||
/// <returns>Lásd <see cref="ILocalizer.Localize"/></returns>
|
||||
public string Localize(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (value is IFormattable formattable)
|
||||
{
|
||||
if (cultureInfo.IsNeutralCulture)
|
||||
{
|
||||
return formattable.ToString(null, CultureInfo.CreateSpecificCulture(cultureInfo.Name));
|
||||
}
|
||||
|
||||
return formattable.ToString(null, cultureInfo);
|
||||
}
|
||||
|
||||
return value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue