gpt4 book ai didi

c# - 非字符串的 .net 本地化

转载 作者:太空狗 更新时间:2023-10-29 19:43:00 24 4
gpt4 key购买 nike

我正在使用 .resx 文件本地化 WPF 应用程序。我创建了主要资源文件的副本,例如 Resources.en-US.resx 或 Resources.cs-CZ.resx。适用于字符串。但是,我不知道如何本地化资源文件中的图像或文档等其他文件。

当我将新图像添加到资源文件(Resources.en-US.resx 或 Resources.cs-CZ.resx)时,该文件的副本总是复制到/Resources 目录。所以一个文件不能有多种语言的多个版本,因为在一个目录中只能有一个同名文件。

理想的解决方案是将来自本地化资源的图像复制到/Resources/en-Us 等子目录中。在当前情况下,我无法使用 .resx 文件对图像和文档进行本地化。有什么想法可以实现吗?谢谢。

最佳答案

以下 MSDN 帖子 Resources and Localization in ASP.NET 2.0 - Displaying Localized Images状态:

While ASP.NET 2.0 doesn't directly support localizing image files, it doesn't require too much custom code to achieve the desired effect.

并提供以下解决方法:

You can start by adding the localized versions of an image file to localized versions of a global resource file. For example, the English version of LitwareSlogan.png has been added to the global resource file named Litware.resx while the French version of LitwareSlogan.fr.png has been added to Litware.fr.resx. The resources in both resource files have been given the same name of LitwareSlogan.

网站提供了完整的示例代码。

关于c# - 非字符串的 .net 本地化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10655962/

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