g36
g36

Reputation: 503

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:

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

Any idea?

Upvotes: 1

Views: 366

Answers (1)

g36
g36

Reputation: 503

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;
    }

Upvotes: 1

Related Questions