public Translation GetTranslation(int phraseId, string languageCode) { TranslationTableAdapter adapter = new TranslationTableAdapter(); MultiLingualData.TranslationDataTable table = adapter.GetTranslationByPhraseId(phraseId, languageCode); if (table.Count == 0) { return(null); } return(MultiLingualHelper.ToTranslationDTO(table[0])); }
public Translation GetTranslation(int translationId) { TranslationTableAdapter adapter = new TranslationTableAdapter(); MultiLingualData.TranslationDataTable table = adapter.GetTranslation(translationId); if (table.Count == 0) { return(null); } return(MultiLingualHelper.ToTranslationDTO(table[0])); }
public List <Translation> GetAllTranslationsByLanguage(string languageCode) { List <Translation> translations = new List <Translation>(); TranslationTableAdapter adapter = new TranslationTableAdapter(); MultiLingualData.TranslationDataTable table = adapter.GetAllTranslationsByLanguage(languageCode); foreach (MultiLingualData.TranslationRow row in table) { translations.Add(MultiLingualHelper.ToTranslationDTO(row)); } return(translations); }
public Translation UpdateTranslation(int phraseId, string languageCode, string translationText, TranslationStatus status, string updatedBy) { TranslationTableAdapter adapter = new TranslationTableAdapter(); MultiLingualData.TranslationDataTable table = adapter.GetTranslationByPhraseId(phraseId, languageCode); if (table.Count == 0) { return(null); } MultiLingualData.TranslationRow row = table[0]; row.translationText = translationText; row.status = (int)status; row.lastEditedBy = updatedBy; adapter.Update(row); return(MultiLingualHelper.ToTranslationDTO(row)); }
public string GetPhraseTextByReferenceId(int referenceId, string languageCode) { TranslationTableAdapter adapter = new TranslationTableAdapter(); MultiLingualData.TranslationDataTable table = adapter.GetTranslationByReferenceId(referenceId, languageCode); if (table.Count > 0) { Translation tran = MultiLingualHelper.ToTranslationDTO(table[0]); return(tran.Text); } _logger.Error(this.GetType(), "MultiLingual error - could not find translation. referenceId=[{0}] language=[{1}]", referenceId, languageCode); //get phrase and default text Phrase phrase = GetPhraseByReferenceId(referenceId); if (phrase != null) { return(phrase.DefaultPhrase); } return(""); }
private Dictionary <string, string> BuildTranslationCache() { var items = new Dictionary <string, string>(); var translations = new TranslationTableAdapter().GetAllTranslations().Select(t => MultiLingualHelper.ToTranslationDTO(t)).ToArray(); foreach (var phraseReference in new PhraseReferenceTableAdapter().GetAllPhraseReferences()) { foreach (var phraseTranslation in translations.Where(t => t.PhraseId == phraseReference.phraseId)) { items.Add(phraseReference.id.ToString() + phraseTranslation.LanguageCode, phraseTranslation.Text); } } if (System.Web.HttpRuntime.Cache != null) { int cacheMinutes; if (!int.TryParse(System.Configuration.ConfigurationManager.AppSettings[""], out cacheMinutes)) { cacheMinutes = 15; } System.Web.HttpRuntime.Cache.Remove("Discover.MultiLingual.SQL.SqlMultiLingual.TranslatedPhrases"); System.Web.HttpRuntime.Cache.Add("Discover.MultiLingual.SQL.SqlMultiLingual.TranslatedPhrases", items, null, DateTime.Now.AddMinutes(cacheMinutes), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } return(items); }