果园本地化 ResourceManifest SetCultures 覆盖路径模式

orchard localization ResourceManifest SetCultures override path pattern

我在 Orchard CMS 中删除了以下内容

public void BuildManifests(ResourceManifestBuilder builder)
    {
        var manifest = builder.Add();
        var currentCulture = _orchardServices.WorkContext.CurrentCulture;

        manifest.DefineScript("jQuery-Validate-Localization").SetUrl("localization/messages.js").SetCultures(currentCulture);

    }

如果 current="en-US",这将搜索文件“~/scripts/localization/messages.en-US.js”。我可以将模式和路径更改为 "~/scripts/localization/messages_en.js"

如何在 ResourceManifest class 中实现此目的?

10 倍

您可以尝试如下操作:

public void BuildManifests(ResourceManifestBuilder builder)
{
    var manifest = builder.Add();
    var currentCulture = _orchardServices.WorkContext.CurrentCulture;

    // split culture on '-' to get first part
    var url = "localization/messages_" + currentCulture.Split('-')[0] + ".js";

    manifest.DefineScript("jQuery-Validate-Localization").SetUrl(url);

}