Skip to content

Commit

Permalink
CLUNL.Localization 0.0.6.0
Browse files Browse the repository at this point in the history
Added ILocalizable and LocalizedString to help build a localized application.
  • Loading branch information
creeperlv committed Jan 28, 2022
1 parent ec8a263 commit d2988f2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CLUNL.Localization/CLUNL.Localization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>0.0.5.0</Version>
<Version>0.0.6.0</Version>
<PackageLicenseExpression></PackageLicenseExpression>
<PackageProjectUrl>https://github.com/creeperlv/CLUNL</PackageProjectUrl>
<RepositoryUrl>https://github.com/creeperlv/CLUNL</RepositoryUrl>
<Description>Localization processing part of Creeper Lv's Universal dotNet Library</Description>
<Authors>Creeper Lv</Authors>
<Company>Creeper Lv</Company>
<Copyright>Copyright (C) 2020-2021 Creeper Lv</Copyright>
<Copyright>Copyright (C) 2020-2022 Creeper Lv</Copyright>
<PackageReleaseNotes>CLUNL.Localization, please see github for release note.</PackageReleaseNotes>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
Expand Down
13 changes: 13 additions & 0 deletions CLUNL.Localization/ILocalizable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace CLUNL.Localization
{
/// <summary>
/// Mark a class is localizable
/// </summary>
public interface ILocalizable
{
/// <summary>
///
/// </summary>
void ApplyLocalization();
}
}
43 changes: 43 additions & 0 deletions CLUNL.Localization/LocalizedString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;

namespace CLUNL.Localization
{
/// <summary>
/// Localized via Language.
/// </summary>
public class LocalizedString
{
/// <summary>
/// Initialize the string with LanguageID and fallback.
/// </summary>
/// <param name="ID"></param>
/// <param name="Fallback"></param>
public LocalizedString(string ID,string Fallback)
{
this.ID = ID;
this.Fallback = Fallback;
}
private string ID;
private string Fallback;
/// <summary>
/// Return the localized string.
/// </summary>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string ToString()
{
return Language.Find(ID, Fallback);
}
/// <summary>
/// Return the value from ToString();
/// </summary>
/// <param name="L"></param>
public static implicit operator string(LocalizedString L)
{
return L.ToString();
}
}
}

0 comments on commit d2988f2

Please sign in to comment.