使用 westwind globalization 在 ASP MVC 中部署新的生产翻译
Deploy new translations on production in ASP MVC with westwind globalization
我正在我的 asp mvc 应用程序中使用 westwind globalization 添加全球化,该应用程序已经 运行 在生产服务器上(Git,具有持续交付功能的 TeamCity)。
如果流程如下我想达到的效果:
- 全球化新视图(创建必要的翻译)
- 将所有更改发送至 Git
- 获取翻译视图 - 无需担心在本地化面板中手动导入新翻译。
我想到的唯一解决方案是使用 EF 迁移(应用程序首先使用 EF 代码):
- 将本地化 table 添加到 Code First 模型并创建迁移
- 将新视图全球化并创建(某种程度上是自动的)新迁移,将新记录插入 Localizations table。
有什么想法吗?
我最终得到了不同的解决方案:
我为创建初始翻译的 DbRes.T 方法创建了一个包装器。
编辑:
有关解决方案的更多详细信息。
我创建了一个静态 class 翻译,其中包含视图中使用的一些方法。
第一次调用默认值后添加。
其中一个看起来像这样:
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;
}
我正在我的 asp mvc 应用程序中使用 westwind globalization 添加全球化,该应用程序已经 运行 在生产服务器上(Git,具有持续交付功能的 TeamCity)。
如果流程如下我想达到的效果:
- 全球化新视图(创建必要的翻译)
- 将所有更改发送至 Git
- 获取翻译视图 - 无需担心在本地化面板中手动导入新翻译。
我想到的唯一解决方案是使用 EF 迁移(应用程序首先使用 EF 代码):
- 将本地化 table 添加到 Code First 模型并创建迁移
- 将新视图全球化并创建(某种程度上是自动的)新迁移,将新记录插入 Localizations table。
有什么想法吗?
我最终得到了不同的解决方案: 我为创建初始翻译的 DbRes.T 方法创建了一个包装器。
编辑: 有关解决方案的更多详细信息。
我创建了一个静态 class 翻译,其中包含视图中使用的一些方法。 第一次调用默认值后添加。 其中一个看起来像这样:
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;
}