为什么不能当设计师改变企业文化中自动创建本地化的资源文件?企业文化、设计师、文件、资源

2023-09-03 15:36:23 作者:゛﹏日久见人心°

我目前工作的一个本地化形式。不过我有些困惑,怎么一正确地做到这一点。

I am currently working on localizing a Form. However I am somewhat confused as to how one correctly does this.

我认为这将有可能控制属性导出到自动的资源文件,但似乎这是一个手工任务。

I thought it would be possible to export control properties to a resource file automatically, but it seems this is a manual task.

我目前的做法是将所有添加控件属性这是String类型的和可写的资源文件。这通过递归枚举所有的控件和子控件的形式和反思的属性。

My current approach is to add all the Control Properties which are of type String and are writable to the resource file. This by recursively enumerating all the controls and child controls on the form and Reflecting the properties.

不过,这似乎有点复杂,我不知道其他人是如何做到这一点。

But this seems somewhat complicated, and I wonder how other people do this.

所以我的问题: 什么是最好的实践中使用的控制文字本地化的资源文件的条款?

编辑:我明白我在做什么错。我以为Displaytext将自动复制到每个资源文件。然而,似乎只有已更改被复制的字段。

I see what I am doing wrong. I thought the Displaytext would automatically be copied into each resource file. However it seems only the fields that have changed are copied.

因此​​,基本上,我将语言设置为某个设置,改变DisplayText的所有控件,当我更改语言回(默认),更改的保存。

So basically, I set the language to a certain setting, change the DisplayText for all the controls, and when I change the language back to (default), the changed are saved.

感谢任何/所有的意见。

Thanks for any/all comments.

推荐答案

嗯,其实本地化形式并不难。您可以设置本地化属性设置为真。这将导致控件的窗体上的所有本地化属性被迁移到一个资源文件。目前的资源文件是独立于区域设置之一。然后,您可以选择在窗体的属性另一种语言,并更换所有的控制标题和文字与翻译的变种。这会导致创建适当的区域设置相关的资源文件和使用。

Well, actually localizing a form is not that hard. You set the "Localizable" property to "true". This causes all localizable properties of controls on the form to be migrated into a resource file. The current resource file is the locale-independent one. You can then select another language in the Form's properties and replace all control captions and texts with their translated variants. This causes the appropriate locale-dependent resource file to be created and used.

您可以选择在该接口通过Thread.CurrentThread设置的CurrentCulture和的CurrentUICulture属性显示的语言:

You can select the language in which the interface is displayed by setting the CurrentCulture and CurrentUICulture properties on Thread.CurrentThread:

Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-GB");

接口西港岛线相应调整。

The interface wil adapt accordingly.