Skip to content

Commit

Permalink
CLUNL.Localization 0.0.7.0
Browse files Browse the repository at this point in the history
LocalizedString now support String.Format by receiving `params object[] arguments`.
  • Loading branch information
creeperlv committed Feb 24, 2022
1 parent 31ee03f commit eb28655
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CLUNL.Localization/CLUNL.Localization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>0.0.6.0</Version>
<Version>0.0.7.0</Version>
<PackageLicenseExpression></PackageLicenseExpression>
<PackageProjectUrl>https://github.com/creeperlv/CLUNL</PackageProjectUrl>
<RepositoryUrl>https://github.com/creeperlv/CLUNL</RepositoryUrl>
Expand Down
10 changes: 8 additions & 2 deletions CLUNL.Localization/LocalizedString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ namespace CLUNL.Localization
/// </summary>
public class LocalizedString
{
object[] arguments;
/// <summary>
/// Initialize the string with LanguageID and fallback.
/// </summary>
/// <param name="ID"></param>
/// <param name="Fallback"></param>
public LocalizedString(string ID,string Fallback)
/// <param name="arguments"></param>
public LocalizedString(string ID, string Fallback, params object[] arguments)
{
this.ID = ID;
this.Fallback = Fallback;
this.arguments = arguments;
}
private string ID;
private string Fallback;
Expand All @@ -29,12 +32,15 @@ public LocalizedString(string ID,string Fallback)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string ToString()
{
return Language.Find(ID, Fallback);
if (arguments != null)
return String.Format(Language.Find(ID, Fallback), arguments);
else return Language.Find(ID, Fallback);
}
/// <summary>
/// Return the value from ToString();
/// </summary>
/// <param name="L"></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator string(LocalizedString L)
{
return L.ToString();
Expand Down

0 comments on commit eb28655

Please sign in to comment.