简体   繁体   English

C#本地化快捷方式

[英]C# Localization Shortcuts

I don´t know how i should explain what i want to do. 我不知道该怎么解释我想做什么。

In my Project are basicly 3 Sub-Projects. 在我的项目中,基本上有3个子项目。

  • First Project: Holds all Properties and Localizations. 第一个项目:拥有所有属性和本地化。
  • Second Project is an Console Project, using the Properties from the First Project and some Localized Strings. 第二个项目是一个控制台项目,使用第一个项目中的属性和一些本地化字符串。
  • Third Project is an Windows Forms Project, using all Properties and Localized Strings from the First Project. 第三项目是Windows窗体项目,使用第一项目中的所有属性和本地化字符串。

The Localization is working without trouble, i can start both Projects and when i change the Culture, it changes the Strings. 本地化工作没有问题,我可以启动两个项目,当我更改文化时,它也会更改字符串。

But: I have to Write the whole Path to the String everywhere. 但是:我必须在各处编写整个String路径。 Example: 例:

Label.Text = Config.Localization.MyString

With the Settings, i can use an "Shortcut" by setting it to an new variable: 通过设置,我可以通过将其设置为新变量来使用“快捷方式”:

private Settings settings = Config.Properties.Settings.Default;

But with the Localization i cant to that to shorten it up. 但是有了本地化,我不能缩短它。 Try´d the following: 尝试以下操作:

    private Type locals = CodepackConfig.Localization;
    Label.Text = locals.MyString

Does somebody have hint for me how i can set a Variable to "Config.Localization"? 有人给我提示如何将变量设置为“ Config.Localization”吗? And yes, i just code C# for 1 Month now, looks like a stupidly easy error :) 是的,我现在只用C#编写了1个月的代码,看起来像是一个非常简单的错误:)

Check out the using directive's documentation. 查看using指令的文档。

I assume you're interested in something like 我认为您对类似的东西感兴趣

using Localization = Config.Properties.Localization;

1: https://msdn.microsoft.com/en-us/library/sf0df423.aspx?f=255&MSPPError=-2147217396 1: https//msdn.microsoft.com/zh-CN/library/sf0df423.aspx?f = 255&MSPPError = -2147217396

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM