gpt4 book ai didi

Asp.net 本地化 - 覆盖页面将使用的 resx 文件

转载 作者:行者123 更新时间:2023-12-03 23:30:34 24 4
gpt4 key购买 nike

试图结合主题和本地化......我在做什么:

本地化 A.aspx,创建:

  • App_Localresources\a.aspx.resx
  • App_Localresources\a.aspx.resx.fr
    ...

  • 但是,我想添加更多选项。我希望有:
  • App_Localresources\a_theme1.aspx.resx
  • App_Localresources\a_theme1.aspx.resx.fr
  • App_Localresources\a_theme2.aspx.resx
  • App_Localresources\a_theme2.aspx.resx.fr

  • 因此,如果我在 Theme1 中,我希望使用主题 1 集资源。

    有没有办法可以覆盖 A.aspx 加载时将使用的 resx 文件?

    即,当它尝试加载 a.aspx.resx.fr 时,我想用 a_theme1.resx.fr 替换它

    非常感谢您的任何想法! :)

    最佳答案

    看看这里:

    ResourceManager.GetResourceFileName Method

    This method uses CultureInfo 's Name property as part of the file name for all cultures other than the invariant culture. This method does not look in an assembly's manifest or touch the disk, and is used only to construct what a resource file name (suitable for passing to the ResourceReader constructor) or a manifest resource blob name should be.

    A derived class can override this method to look for a different extension, such as ".ResX", or a completely different scheme for naming files.



    我认为你想做的是这样的:
    public class ResxResourceManager : ResourceManager
    {
    protected override string GetResourceFileName(
    System.Globalization.CultureInfo culture)
    {
    return base.GetResourceFileName(culture);
    }

    public string GetResxFileName(System.Globalization.CultureInfo culture)
    {
    return GetResourceFileName(culture).Replace(".resources", ".resx");
    }
    }

    有关更多信息:

    Creating a custom Resource Provider

    Under the Hood of BuildManager and Resource Handling

    关于Asp.net 本地化 - 覆盖页面将使用的 resx 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5889938/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com