需要帮助本地化 [英] need help with localization

查看:78
本文介绍了需要帮助本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力进行本地化。似乎我读的越多,我就越困惑。我从这个文件中的一个资源文件strings.resx开始,我做了我的英文字符串分配。



从VS2012内部,我无法添加另一个字符串资源文件并让它以我期望的方式出现在编辑器中(换句话说,我无法为新语言添加字符串常量)。



因此,从文件系统中,我复制了原始resx以创建2个新的字符串资源文件。 strings.fr.resx和strings.es.resx。然后我将这两个文件添加到我的解决方案中并添加了相应的翻译字符串以匹配默认资源文件。



我在每个文件上设置了访问修饰符 内部并生成了designer.cs文件。



我在解决方案资源管理器中看到的一件事是我创建的第一个有资源管理器的字符串类,文化和枚举的字符串常量。其他人没有。



一切都编译得很好,但是当我将strings.resourceCulture设置为法语时,我仍然得到返回的英文字符串值。



我假设我的方法是复制和重命名资源文件可能是我出错的地方。请帮我回到正确的课程。

I'm struggling with localization. It seems the more I read the more confused I get. I started with a single resource file "strings.resx" in this file, I made my English string assignments.

From inside of VS2012, I couldn't add another string resource file and have it appear in the editor the way I was expecting (in other words, I couldn't add the string constants for the new language).

So, from the filesystem, I copied the original resx to create 2 new string resource files. "strings.fr.resx" and "strings.es.resx". I then added these 2 files to my solution and added the appropriate translation strings to match up to the default resource file.

I set the "Access Modifier" on each to "Internal" and generated the designer.cs files.

One thing that I see different in solution explorer is that the first one I created has a strings class with resource manager, culture and the string constants enumerated. The others do not.

Everything compiles fine, but when I set the strings.resourceCulture to French, I still get the English string value returned.

I'm assuming my approach to copying and renaming the resource file was probably where I went wrong. Please help me get back on the right course.

推荐答案

这种全球化和本地化基于附属程序集后备的。基本思想是:您只需使用一种基础文化,使用资源,使UI流畅,从而使产品全球化,因此字符串长度的更改不会搞砸布局,考虑到不同的日期/时间/货币格式, 等等。当您的产品准备就绪时,您可以通过添加每个包含相同资源集但仅包含资源的附属程序集来添加本地化,​​因此本地化可以由其他人或团队编写,即使他们无法访问原始源代码,除了那些资源。



系统根据您可以动态切换的当前线程文化自动选择需要本地化。如果某些文化不存在于卫星中,则后备机制会自动选择最接近的实施文化。



有关详细信息,请参阅我过去的答案:

如何使用单身3种语言的resx文件 [ ^ ],

winforms中的全球化 [ ^ ],

winform .net 中的全球化/本地化问题[ ^ ]。



见还有:复选框的全球化 [ ^ ]。



-SA
This kind of globalization and localization is based on satellite assemblies and fallback. The basic idea is: you globalize the product starting with just one, base culture, using resources, make the UI fluid, so the change of the string lengths won't screw up the layout, take into account different date/time/currency formats, and so on. When your product is ready, you can add localizations by adding satellite assemblies each containing the same set of resources, but only resources, so the localization can be written by another person or a team, even if they have no access to original source code, except those resources.

The system automatically chooses requires localization based on the current thread culture, which you can dynamically switch. If some culture absent from satellites, the fallback mechanism automatically chooses the closest implemented culture.

For further detail, please see my past answers:
How to use a Single resx file for 3 languages[^],
globalization in winforms[^],
globalization/localization problem in winform .net[^].

See also: Globalization of Checkboxes[^].

—SA


Windows Universal Apps中的本地化 [ ^ ]


这篇关于需要帮助本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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