I am Following a tutorial on implementing localization in my Application.
我正在学习在我的应用程序中实现本地化的教程。
But i cant get my head around step 4, where he says to create a new culture assembly.
但我无法理解第4步,他说要创建一个新的文化大会。
The loaded Assemblies ResourceDictionaries will be used to replace the default one within the main Assembly.
加载的Assemblies ResourceDictionaries将用于替换主程序集中的默认值。
- Create normal WPF App, and use a
ResourceDictionary
for strings创建普通的WPF应用程序,并使用ResourceDictionary作为字符串
- Use
MergedDictionary
inApp.resources
在App.resources中使用MergedDictionary
- Make sure any localizable controls using a
DynamicResource
like<Label Content=”{DynamicResource label1}”/>
使用DynamicResource确保任何可本地化的控件,如
- Create a new culture assembly with a sensible name, such as Culture_fr-CA
创建一个具有合理名称的新文化程序集,例如Culture_fr-CA
- For assembly created in step 4, create mirror image
ResourceDictionary
that matches the original AssembliesResourceDictionary
. but with translated strings对于在步骤4中创建的程序集,创建与原始Assemblies ResourceDictionary匹配的镜像ResourceDictionary。但翻译的字符串
- Compile the culture assembly to some folder under main Assemblies bin\debug folder. This demo assumes this folder is called “CultureFiles”
将文化程序集编译到主Assemblies bin \ debug文件夹下的某个文件夹。此演示假定此文件夹名为“CultureFiles”
- When main app runs, get current culture and Load the matching Assembly from disk
当主应用程序运行时,获取当前文化并从磁盘加载匹配的程序集
- From the currently loaded Culture Assembly, extract the
ResourceDictionary
从当前加载的Culture Assembly中,提取ResourceDictionary
- Using the extracted
ResourceDictionary
, replace the currentApplication.MergedResources
dictionary with the newly extracted cultureResourceDictionary
使用提取的ResourceDictionary,将当前的Application.MergedResources字典替换为新提取的文化ResourceDictionary
- All controls that refer to the Dynamic resources should be ok now with new cultural strings
现在,所有引用动态资源的控件都可以使用新的文化字符串
1 个解决方案
#1
0
As far as I can tell it just means you add an extra WPF project to your solution. They add the name of the culture to the project's name.
据我所知,这只是意味着你在解决方案中添加了一个额外的WPF项目。他们将文化名称添加到项目名称中。
#1
0
As far as I can tell it just means you add an extra WPF project to your solution. They add the name of the culture to the project's name.
据我所知,这只是意味着你在解决方案中添加了一个额外的WPF项目。他们将文化名称添加到项目名称中。