本文整理汇总了C#中Translation.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Translation.Get方法的具体用法?C# Translation.Get怎么用?C# Translation.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public static string Get(string screen, string key, Bm2s.Poco.Common.Parameter.Language language, string defaultValue, params string[] parameters)
{
string result = (string)HttpContext.Current.Session[TranslationUtils.TranslationSessionKey + "_" + screen + "_" + key + "_" + language.Id];
if (string.IsNullOrWhiteSpace(result))
{
Translation translation = new Translation();
translation.Request.Application = TranslationUtils.ApplicationName;
translation.Request.LanguageId = language.Id;
translation.Request.Screen = screen;
translation.Request.Key = key;
translation.Get();
if (!translation.Response.Translations.Any())
{
translation.Request.Translation = new Bm2s.Poco.Common.Parameter.Translation()
{
Application = TranslationUtils.ApplicationName,
Key = key,
Language = language,
Screen = screen,
Value = defaultValue
};
translation.Post();
}
result = translation.Response.Translations.FirstOrDefault().Value;
HttpContext.Current.Session[TranslationUtils.TranslationSessionKey + "_" + screen + "_" + key + "_" + language.Id] = result;
}
return string.Format(result, parameters);
}
示例2: GetValues
public HtmlString GetValues()
{
Language language = new Language();
language.Get();
Translation translation = new Translation();
translation.Request.PageSize = 0;
translation.Get();
var result = translation.Response.Translations.Where(tran => tran.Application == TranslationUtils.ApplicationName).Select(tran=> new { Screen= tran.Screen, Key = tran.Key }).Distinct().Select(tran => new { Screen = tran.Screen, Key = tran.Key, Languages = language.Response.Languages.Select(lang => new { Code = lang.Code, Translation = TranslationUtils.Get(tran.Screen, tran.Key, lang, string.Empty) }) });
return result.ToHtmlJson();
}
示例3: Set
public static int Set(string screen, string key, Bm2s.Poco.Common.Parameter.Language language, string value)
{
Translation translation = new Translation();
translation.Request.Application = TranslationUtils.ApplicationName;
translation.Request.Screen = screen;
translation.Request.Key = key;
translation.Request.LanguageId = language.Id;
translation.Get();
Bm2s.Poco.Common.Parameter.Translation tran = translation.Response.Translations.FirstOrDefault();
translation.Request.Translation = new Bm2s.Poco.Common.Parameter.Translation();
translation.Request.Translation.Application = TranslationUtils.ApplicationName;
translation.Request.Translation.Screen = screen;
translation.Request.Translation.Key = key;
translation.Request.Translation.Language = language;
translation.Request.Translation.Value = value;
if (tran != null)
{
translation.Request.Translation.Id = tran.Id;
}
translation.Post();
HttpContext.Current.Session[TranslationUtils.TranslationSessionKey + "_" + screen + "_" + key + "_" + translation.Request.LanguageId] = value;
return translation.Response.Translations.FirstOrDefault().Id;
}