如何创建新的文化程序集WPF

时间:2022-03-31 12:49:54

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将用于替换主程序集中的默认值。

  1. Create normal WPF App, and use a ResourceDictionary for strings
  2. 创建普通的WPF应用程序,并使用ResourceDictionary作为字符串

  3. Use MergedDictionary in App.resources
  4. 在App.resources中使用MergedDictionary

  5. Make sure any localizable controls using a DynamicResource like <Label Content=”{DynamicResource label1}”/>
  6. 使用DynamicResource确保任何可本地化的控件,如

  7. Create a new culture assembly with a sensible name, such as Culture_fr-CA
  8. 创建一个具有合理名称的新文化程序集,例如Culture_fr-CA

  9. For assembly created in step 4, create mirror image ResourceDictionary that matches the original Assemblies ResourceDictionary. but with translated strings
  10. 对于在步骤4中创建的程序集,创建与原始Assemblies ResourceDictionary匹配的镜像ResourceDictionary。但翻译的字符串

  11. Compile the culture assembly to some folder under main Assemblies bin\debug folder. This demo assumes this folder is called “CultureFiles”
  12. 将文化程序集编译到主Assemblies bin \ debug文件夹下的某个文件夹。此演示假定此文件夹名为“CultureFiles”

  13. When main app runs, get current culture and Load the matching Assembly from disk
  14. 当主应用程序运行时,获取当前文化并从磁盘加载匹配的程序集

  15. From the currently loaded Culture Assembly, extract the ResourceDictionary
  16. 从当前加载的Culture Assembly中,提取ResourceDictionary

  17. Using the extracted ResourceDictionary, replace the current Application.MergedResources dictionary with the newly extracted culture ResourceDictionary
  18. 使用提取的ResourceDictionary,将当前的Application.MergedResources字典替换为新提取的文化ResourceDictionary

  19. All controls that refer to the Dynamic resources should be ok now with new cultural strings
  20. 现在,所有引用动态资源的控件都可以使用新的文化字符串

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项目。他们将文化名称添加到项目名称中。