-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from ite-klass/ngettext
Replace NGettext dependency
- Loading branch information
Showing
8 changed files
with
60 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/FubarDev.FtpServer.Abstractions/Localization/EmptyLocalizationCatalog.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// <copyright file="EmptyLocalizationCatalog.cs" company="iT Engineering - Software Innovations"> | ||
// Copyright (c) Jan Klass. All rights reserved. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Globalization; | ||
|
||
namespace FubarDev.FtpServer.Localization | ||
{ | ||
/// <summary>A localization catalog that returns text as-is.</summary> | ||
/// <remarks> | ||
/// <para>The texts in-code are written in English, so the effectively serves as an English catalog by returning texts as-is.</para> | ||
/// <para>The culture formatting for values still applies though.</para> | ||
/// </remarks> | ||
public class EmptyLocalizationCatalog : ILocalizationCatalog | ||
{ | ||
public EmptyLocalizationCatalog(CultureInfo cultureInfo) | ||
{ | ||
CultureInfo = cultureInfo ?? throw new ArgumentNullException(nameof(cultureInfo)); | ||
FormatProvider = cultureInfo; | ||
} | ||
|
||
public CultureInfo CultureInfo { get; } | ||
|
||
public IFormatProvider FormatProvider { get; } | ||
|
||
public virtual string GetString(string text) => text; | ||
|
||
public virtual string GetString(string text, params object[] args) => string.Format(FormatProvider, text, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/FubarDev.FtpServer.Abstractions/Localization/ILocalizationCatalog.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// <copyright file="ILocalizationCatalog.cs" company="iT Engineering - Software Innovations"> | ||
// Copyright (c) Jan Klass. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FubarDev.FtpServer.Localization | ||
{ | ||
public interface ILocalizationCatalog | ||
{ | ||
/// <summary>Translate <paramref name="text"/>.</summary> | ||
/// <param name="text">The text to be translated.</param> | ||
/// <returns>The translated text.</returns> | ||
string GetString(string text); | ||
|
||
/// <summary>Translate <paramref name="text"/> with format values <paramref name="args"/>.</summary> | ||
/// <param name="text">The text to be translated.</param> | ||
/// <param name="args">The format arguments.</param> | ||
/// <returns>The translated text.</returns> | ||
string GetString(string text, params object[] args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters