This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
namespace ShrinkTutorial
|
||||
{
|
||||
public interface IShrinkTutorialLocalizationProvider
|
||||
{
|
||||
bool TryResolve(string key, out string text);
|
||||
}
|
||||
|
||||
public static class ShrinkTutorialLocalization
|
||||
{
|
||||
public static IShrinkTutorialLocalizationProvider Provider { get; set; }
|
||||
|
||||
public static string Resolve(string key, string fallbackText)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(key) &&
|
||||
Provider != null &&
|
||||
Provider.TryResolve(key, out var localizedText) &&
|
||||
!string.IsNullOrWhiteSpace(localizedText))
|
||||
{
|
||||
return localizedText;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(fallbackText))
|
||||
return fallbackText;
|
||||
|
||||
return key ?? string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user