如何使用子目录中的RESX文件本地化WPF应用程序 [英] How to localize WPF Application with RESX files in subdirectories

查看:54
本文介绍了如何使用子目录中的RESX文件本地化WPF应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队有一些使用XAML编写的WPF项目.我们最近向每个项目添加了大量本地特定的RESX文件.为了使内容整洁,我被要求将这些文件存储在[Project]> Localization> [locale]

My team has some WPF projects written using XAML. We recently added a large number of local specific RESX files to each project. In order to keep things tidy, I was asked to store these files in [Project]>Localization>[locale]

现在,当我们在非美国语言环境中运行应用程序时,会从相应的RESX文件中提取字符串.我们试图更新RESX文件属性中的命名空间,并将它们设置为Public,以便创建结果设计器.使工作正常的唯一方法是将语言环境RESX文件直接移到项目的Properties目录中.

Now, when we run the application on a non en-US locale, strings are pulled from the appropriate RESX file. We've tried to update Namespaces in the properties of the RESX files, as well as setting them to Public so that a resulting Designer is created. The only way that we can get things to work is by moving the locale RESX files directly into the Project's Properties directory.

反正有没有更新XAML以在子目录中搜索语言环境RESX文件的情况?

Is there anyway to update the XAML to search for locale RESX files in a subdirectory?

编辑 XAML代码库和解决方案资源管理器

我已附上问题图片以进行澄清.

I've attached an image of the problem for clarification.

我们尝试过的一些代码更改:
1)我们尝试为xmlns:res ="clr-namespace:[PROJECT] .CoreUI. Localization "
设置命名空间.2)尝试将命名空间设置为xmlns:res ="clr-namespace:[PROJECT]. CoreUI "
3)我们还试图更改RESX文件的自定义工具命名空间,以匹配当前的命名空间 My.Properties CoreUI.Properties

Some code changes that we've tried:
1) We attempted to set the Namespace for xmlns:res="clr-namespace:[PROJECT].CoreUI.Localization"
2) Attempted to set the Namespace to xmlns:res="clr-namespace:[PROJECT].CoreUI"
3) We've also attempted to change the Custom Tool Namespace of the RESX file to match the current namespace My.Properties as well as CoreUI.Properties

我们还确认,例如,Resources.resx和Resources.ru.resx的访问修饰符均设置为Public,并且两个构建操作均显示嵌入式资源"

We've also confirmed that the Access Modifiers for both Resources.resx and Resources.ru.resx (for example) are set to Public and that both Build Actions show "Embedded Resource"

推荐答案

感谢您的帮助!

我的同事实际上在这里偶然发现了另一篇文章,在无数次搜索中我们以某种方式错过了它:

My colleague actually stumbled upon another post in here that we somehow missed during out countless searching:

将翻译后的resx文件放在不同的位置文件夹在Visual Studio中?

简而言之,我们正在考虑使项目搜索到RESX文件的子目录中.实际上,我们需要RESX文件来在链中进一步搜索已经创建的设计器.

In short, we were thinking about making the project search down into subdirectories for the RESX files. In actuality, we need the RESX file to search for the already created designer further up in the chain.

<ItemGroup>
<EmbeddedResource Include="Localization\ar\Resources.ar.resx" >
<ManifestResourceName>$(TargetName).Properties.%(Filename)</ManifestResourceName>
</EmbeddedResource>

出现ManifestResourceName似乎是在告诉RESX文件我们已经创建了一个Designer,而不要创建一个Designer.

Entering the ManifestResourceName appears to tell the RESX file that we already have a Designer created and not to make a new one.

再次感谢大家的帮助!

这篇关于如何使用子目录中的RESX文件本地化WPF应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆