public DataTable getTable()
        {
            var languages = ILanguages.GetAll().Select(x => x.LanguageCode).Distinct();
            var query     = from r in ITranslation.GetAll().Where(x => x.OfficialBoolean == true)
                            group r by r.TextId into nameGroup
                            select new
            {
                Name   = nameGroup.Key,
                Values = from lang in languages
                         join ng in nameGroup
                         on lang equals ng.LanguageCode into languageGroup
                         select new
                {
                    Column = lang,
                    Value  = languageGroup.Any() ?
                             languageGroup.First().Translated_Text : null
                }
            };

            DataTable table         = new DataTable();
            var       languagesList = ILanguages.GetAll().Select(x => x.LanguageName).Distinct();

            table.Columns.Add("TextId");              // first column
            foreach (var language in languagesList)
            {
                table.Columns.Add(language);                 // columns for each language
            }
            List <string> items = new List <string>();

            foreach (var key in query)
            {
                var row = table.NewRow();
                items = key.Values.Select(v => v.Value).ToList(); // data for columns
                items.Insert(0, key.Name);                        // data for first column
                row.ItemArray = items.ToArray();
                table.Rows.Add(row);
            }
            return(table);
        }
        public void GetTranslationRecord(string TextId, string Text, string LanguageCode)
        {
            var Translations = ITranslation.GetAll().Where(x => x.TextId == TextId && x.OfficialBoolean == true && x.LanguageCode == LanguageCode).FirstOrDefault();

            if (Translations == null)
            {
                sbPo.Append("\r\n#: " + TextId + "\r\nmsgid \"" + Text + "\"\r\nmsgstr \"" + "\"\r\n");
            }
            else
            {
                sbPo.Append("\r\n#: " + TextId + "\r\nmsgid \"" + Text + "\"\r\nmsgstr \"" + Translations.Translated_Text + "\"\r\n");
            }
        }
Exemple #3
0
        public ActionResult Edit(int id)
        {
            var language      = Ilanguages.GetLanguageID(id);
            var languageExist = ITranslation.GetAll().Where(x => x.LanguageCode == language.LanguageCode).FirstOrDefault();

            if (languageExist != null)
            {
                ViewBag.languageExist = true;
            }

            return(PartialView(
                       "Create",
                       new LanguageInput
            {
                Id = language.Id.ToString(),
                LanguageCode = language.LanguageCode,
                LanguageName = language.LanguageName
            }));
        }