public ActionResult ClearCache(int?lang = null)
        {
            TranslationHelper.ClearCache();
            ViewBag.CacheCleared = true;

            return(Index(lang));
        }
Beispiel #2
0
        public static void ImportTranslationsCsv(DataContext db, CsvReader csv, TranslationArea area)
        {
            while (csv.Read())
            {
                var code  = csv.GetField <string>(0);
                var key   = csv.GetField <string>(1);
                var value = csv.GetField <string>(2);

                // ToList is called on purpose for case sensitive search
                var translation =
                    db.Translations.ToList().FirstOrDefault(
                        t => t.LanguageCode == code && t.Key == key && t.Area == area);

                if (translation == null)
                {
                    translation = new Translation
                    {
                        LanguageCode = code,
                        Key          = key,
                        Value        = value,
                        Area         = area
                    };
                    db.Translations.Add(translation);
                }
                else
                {
                    translation.Value = value;
                }
            }

            db.SaveChanges();

            TranslationHelper.ClearCache();
        }