2021-03-21 22:34:17 +01:00

41 lines
1.1 KiB
C#

using System;
namespace GreenshotConfluencePlugin.Support {
public class TranslationManager {
private static TranslationManager _translationManager;
public event EventHandler LanguageChanged;
/*public CultureInfo CurrentLanguage {
get { return Thread.CurrentThread.CurrentUICulture; }
set {
if( value != Thread.CurrentThread.CurrentUICulture) {
Thread.CurrentThread.CurrentUICulture = value;
OnLanguageChanged();
}
}
}
public IEnumerable<CultureInfo> Languages {
get {
if( TranslationProvider != null) {
return TranslationProvider.Languages;
}
return Enumerable.Empty<CultureInfo>();
}
}*/
public static TranslationManager Instance => _translationManager ??= new TranslationManager();
public ITranslationProvider TranslationProvider { get; set; }
public object Translate(string key) {
object translatedValue = TranslationProvider?.Translate(key);
if( translatedValue != null) {
return translatedValue;
}
return $"!{key}!";
}
}
}