使用资源文件在 ASP.NET 中进行本地化

发布于 2024-12-25 04:14:57 字数 260 浏览 0 评论 0原文

我正在 asp.net 中开发一个双语 Web 应用程序,在尝试使用资源文件实现双语系统时遇到了拦截器。我在“asp.net特殊文件夹App_GlobalResources”中有三四个资源文件,即

common.resx 页面.resx reports.resx

所有文件都包含我在应用程序中使用的相应键值对。现在,我在同一文件夹中还有另一组法语资源文件,后缀为“_fr”。

当用户单击页面中的更改语言时,我希望应用程序使用 _fr 后缀资源文件。这可行吗?

I am developing a bilingual web application in asp.net and ive ran into a blocker while trying to implement the bilingual system using a resource file. I have three four resource files in the "asp.net special folder App_GlobalResources" namely

common.resx
pages.resx
reports.resx

All the files contains respective key value pairs which i ve used in my application. Now i also have another set of resource files in the same folder for french with suffix "_fr".

When a user clicks change language in the page i want the application to use the _fr suffix resource files. Is this doable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

落日海湾 2025-01-01 04:14:57

将自动选择具有给定文化的资源文件。您只需重写 InitializeCulture() 页面方法即可。

protected override void InitializeCulture()
    {
        base.InitializeCulture();
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");
        System.Threading.Thread.CurrentThread.CurrentUICulture  = new System.Globalization.CultureInfo("fr-FR");
    }

Resource file with given culture will be selected automatically. You just have to override the InitializeCulture() page method.

protected override void InitializeCulture()
    {
        base.InitializeCulture();
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");
        System.Threading.Thread.CurrentThread.CurrentUICulture  = new System.Globalization.CultureInfo("fr-FR");
    }
情未る 2025-01-01 04:14:57

检查一次。它可能对你有帮助
全球化和本地化网站

Check this once. It may help u
Globalizating and localizing WebSite

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文