Beispiel #1
0
        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]));
        }
Beispiel #2
0
        public Phrase GetPhraseByText(string text)
        {
            PhraseTableAdapter adapter = new PhraseTableAdapter();

            MultiLingualData.PhraseDataTable table = adapter.GetPhraseByText(text);
            if (table.Count == 0)
            {
                return(null);
            }
            return(MultiLingualHelper.ToPhraseDTO(table[0], DefaultLanguageCode));
        }
Beispiel #3
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]));
        }
Beispiel #4
0
        public Phrase GetPhraseByReferenceId(int referenceId)
        {
            PhraseTableAdapter adapter = new PhraseTableAdapter();

            MultiLingualData.PhraseDataTable table = adapter.GetPhraseByReferenceId(referenceId);
            if (table.Count == 0)
            {
                return(null);
            }
            return(MultiLingualHelper.ToPhraseDTO(table[0], DefaultLanguageCode));
        }
Beispiel #5
0
        public Language GetLanguageByName(string name)
        {
            LanguageTableAdapter adapter = new LanguageTableAdapter();

            MultiLingualData.LanguageDataTable table = adapter.GetLanguageByName(name);
            if (table.Count == 0)
            {
                return(null);
            }
            return(MultiLingualHelper.ToLanguageDTO(table[0]));
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public List <Region> GetAllRegions()
        {
            List <Region>      regions = new List <Region>();
            RegionTableAdapter adapter = new RegionTableAdapter();

            MultiLingualData.RegionDataTable table = adapter.GetAllRegions();
            foreach (MultiLingualData.RegionRow row in table)
            {
                regions.Add(MultiLingualHelper.ToRegionDTO(row));
            }
            return(regions);
        }
Beispiel #8
0
        public List <Language> GetAllLanguages()
        {
            List <Language>      langs   = new List <Language>();
            LanguageTableAdapter adapter = new LanguageTableAdapter();

            MultiLingualData.LanguageDataTable table = adapter.GetAllLanguages();
            foreach (MultiLingualData.LanguageRow row in table)
            {
                langs.Add(MultiLingualHelper.ToLanguageDTO(row));
            }
            return(langs);
        }
Beispiel #9
0
        public Region GetRegion(string regionCode)
        {
            if (string.IsNullOrEmpty(regionCode))
            {
                return(new Region());
            }
            RegionTableAdapter adapter = new RegionTableAdapter();

            MultiLingualData.RegionDataTable table = adapter.GetRegion(regionCode);
            if (table.Count == 0)
            {
                return(new Region());
            }
            return(MultiLingualHelper.ToRegionDTO(table[0]));
        }
Beispiel #10
0
        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));
        }
Beispiel #11
0
        public Phrase UpdatePhraseText(int phraseId, string text, string updatedBy)
        {
            PhraseTableAdapter adapter = new PhraseTableAdapter();

            MultiLingualData.PhraseDataTable table = adapter.GetPhrase(phraseId);
            if (table.Count == 0)
            {
                return(null);
            }
            MultiLingualData.PhraseRow row = table[0];
            row.defaultPhrase = text;
            row.lastEditedBy  = updatedBy;
            adapter.Update(row);
            UpdateTranslation(row.id, DefaultLanguageCode, text, TranslationStatus.Translated, updatedBy);
            return(MultiLingualHelper.ToPhraseDTO(row, DefaultLanguageCode));
        }
Beispiel #12
0
        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("");
        }
Beispiel #13
0
        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);
        }