#region S# License
/******************************************************************************************
NOTICE!!! This program and source code is owned and licensed by
StockSharp, LLC, www.stocksharp.com
Viewing or use of this code requires your acceptance of the license
agreement found at https://github.com/StockSharp/StockSharp/blob/master/LICENSE
Removal of this comment is a violation of the license agreement.
Project: StockSharp.Localization.Localization
File: LocalizedStrings.cs
Created: 2015, 11, 11, 2:32 PM
Copyright 2010 by StockSharp, LLC
*******************************************************************************************/
#endregion S# License
namespace StockSharp.Localization
{
using System;
using System.Diagnostics;
using System.IO;
using Ecng.Localization;
///
/// Extension for .
///
public static class LocalizedStringsExtension
{
///
///
///
public static Func GetResourceStream = () =>
{
var asmHolder = typeof(LocalizedStrings).Assembly;
return asmHolder.GetManifestResourceStream($"{asmHolder.GetName().Name}.{Path.GetFileName("text.csv")}");
};
}
///
/// Localized strings.
///
public static partial class LocalizedStrings
{
static LocalizedStrings()
{
try
{
LocalizationManager.Init(LocalizedStringsExtension.GetResourceStream());
}
catch (Exception ex)
{
Trace.WriteLine(ex);
}
}
///
/// Localization manager.
///
public static LocalizationManager LocalizationManager => LocalizationHelper.DefaultManager;
///
/// Error handler to track missed translations or resource keys.
///
public static event Action Missing
{
add => LocalizationManager.Missing += value;
remove => LocalizationManager.Missing -= value;
}
///
/// Current language.
///
public static Languages ActiveLanguage
{
get => LocalizationManager.ActiveLanguage;
set => LocalizationManager.ActiveLanguage = value;
}
///
/// Get localized string.
///
/// Resource unique key.
/// Language.
/// Localized string.
public static string GetString(string resourceId, Languages? language = null)
{
return LocalizationManager.GetString(resourceId, language);
}
///
/// Web site domain.
///
public static string Domain => ActiveLanguage == Languages.Russian ? "ru" : "com";
}
}