如何使用3种语言的单个resx文件 [英] How to use a Single resx file for 3 languages

查看:164
本文介绍了如何使用3种语言的单个resx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有一个应用程序,在该应用程序中,用户将在第一页中选择语言,而表单的其余部分应显示相同的语言.

我必须为此应用程序发送一个exe文件.
我确实使用过通过更改language属性来设置每个控件的语言和值的方法,但是它创建了单独的文件夹,而当我仅运行exe时,它就没有运行,这意味着我需要这些语言文件夹. br/> 我不需要这个.
请需要您的人员帮助以选择最佳的方法.

Hi all

I have an application where in the first page user will select the language and rest of the form should display the same language.

i have to send a single exe file for this application.
i did using like setting the language and value for each control by changing the language property, but it''s creating separate folders and when i am running only the exe, it''s not running, means i need those language folders.
i don''t need this.
Please need help from you people to select the best way to do that.

推荐答案

您想要的不是应该怎么做.

这是通过使用卫星组件完成的.这个想法是:如果找不到更近的本地化资源,则用一种语言开发所有代码,以用于 fallback .通常,即使代码不是在说英语的地方开发的,也使用英语.您可以使开发全球化,但可以将取决于文化的一切都放在RESX资源中(嵌入到某些程序集的某些可执行模块中).粗略地说,它是按照常规"方式完成的,就好像没有任何本地化一样.稍后,您可以通过添加新的附属程序集(仅限资源的程序集)来开始本地化.您只需将资源(资源使用的所有源文件)从主机中复制到一个单独的项目中,然后将其翻译成某种文化即可.

通过将项目的输出目录设置为特殊的卫星"位置中的卫星程序集,一切工作正常.这些应该是主项目输出目录的子目录,并根据完整或部分区域性名称来命名.在运行时,您要做的就是将UI线程(可能还有其他一些线程)的区域性和UI区域性设置为所需的区域性.可以在应用程序配置文件中完成此操作,但可以在运行时进行切换-UI将立即自动切换.这是这样的:
http://msdn.microsoft.com/zh-cn/library/system.threading.thread.currentculture%28v = vs.110%29.aspx [ http://msdn.microsoft.com/zh-cn/library/system.threading.thread.currentuiculture%28v = vs.110%29.aspx [ http://msdn.microsoft.com/en-us/library/21a15yht%28v=vs.110%29.aspx [
What you want is not how it should be done.

This is done via the use of satellite assemblies. The idea is: you develop all the code in one language which is used for fallback in case no closer localized resources can be found. Usually, English is used, even if the code is developed in not an English-speaking place. You globalize development but putting everything what can be depend on culture, in RESX resource (to be embedded in some executable module of some assembly). Roughly speaking, it is done the "usual" way, as if there was no any localization. Later on, you start localization by adding new satellite assemblies, resource-only ones. You simply copy resources, all source files used by resources, from main assembly to a separate project and do the translation to some culture.

Everything works by setting the output directory of the projects building into satellite assembly in a special "satellite" locations. These should be the sub-directories of the output directory of the main project, named according to full or partial culture names. During runtime, all you do is setting the culture and UI culture of the UI thread (and possibly some other threads) to required culture. It can be done in an application configuration files, but can be switched during runtime — the UI will be automatically switched immediately. This is how:
http://msdn.microsoft.com/en-us/library/system.threading.thread.currentculture%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.threading.thread.currentuiculture%28v=vs.110%29.aspx[^].

It is possible that requested culture is not implemented. Nevertheless, the application will work in some reasonable way. The fallback mechanism will automatically find the closest culture implemented in satellites. If not, it may fallback to the original language of the main product, but in no way will you get empty strings.

Note that you can have a separate team doing just the localization. Everything works out the way which does not requires you to pass them the full source code. You can only provide the installation of existing project and part of project, with resource only, and documentation. This can be enough to complete localization, with minimal supervision by the team developing the main product. For example, you can collaborate with your customers and representatives in a country of different culture, with the language you almost unfamiliar with. Still, you will be able to outsource just the localization to them.

You can find further detail on creation of satellite assemblies in MSDN: http://msdn.microsoft.com/en-us/library/21a15yht%28v=vs.110%29.aspx[^].

—SA


这篇关于如何使用3种语言的单个resx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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