Search code examples
asp.net-mvcglobalizationwestwindwestwind-globalization

Deploy new translations on production in ASP MVC with westwind globalization


I'm adding globalization using westwind globalization in my asp mvc app that is already running on production server (Git, TeamCity with continuous delivery).

What I want to achieve if flow as follow:

  • globalize a new view (create necessary translations)
  • send all changes to Git
  • get translated view - without worry about manual import of new translations in Localization Panel.

The only solution that came to my mind is to use EF Migrations (app is using EF Code First):

  • add Localizations table to Code First model and create migration
  • globalize the new view and create (some how automtically) a new migration which inserts a new records to Localizations table.

Any idea?


Solution

  • I ended up with different solution: I created a wrapper for DbRes.T method which creates initial translation.

    Edit: More details about solution.

    I created a static class Translations with a few methods used in views. After first call default values are added. One of them looks sth like that:

    public static string 
        Translate(string resourceSet, string key, string defaultEnglish)
        {
            var currentLang = GetValidCurrentCulture();
    
            var resourceValue = DbRes.TDefault(key, null, resourceSet, currentLang);
            if (resourceValue == null)
            {
                AddDefaultTranslations(resourceSet, key, defaultEnglish);
            }
    
            if (string.IsNullOrWhiteSpace(resourceValue))
            {
                return defaultEnglish;
            }
    
            return resourceValue;
        }