翻译Visual Studio项目 [英] Translating a Visual Studio project

查看:104
本文介绍了翻译Visual Studio项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2012中用c#用我的母语(hun)编写了一个大项目.

I have a big project written in my native language (hun) in c# with Visual Studio 2012.

我想将其翻译成英文.

I'd like to translate it to english.

当然,如果我得到的文字是匈牙利文,我可以翻译它,所以重点不在于如何翻译文字,而在于如何使整个翻译更加容易.我不需要在运行时更改语言的软件,如果我获得了具有不同语言的其他项目,也可以.一种方法是遍历整个项目并更改所有标签,但这是很多工作,而且由于我修改了整个项目,因此必须重新做一遍.

Of course if I get a text in hungarian, I can translate it, so the point is not about how to translate a text, but how to make the whole translation easier. I don't need the software to change the language while runtime, it is also ok if I get a different project with a different language. One way is go go through the whole project and change all the labels, but that's a lot of work, and because I modify the whole project, I would have to do it all over again.

我编写了另一个程序,该程序在项目文件中找到标有"..."的标签(例如"Form1.cs"等),我可以翻译它们.这有很多错误.例如,Visual Studio拆分长文本,因此我将这些字符串分开,因此在整个翻译之后仍然需要大量工作.

I've written another program which finds labels marked with "..." in the project files (like 'Form1.cs', etc.), and I could translate those. This had a lot of mistakes. For example Visual Studio splits long text, so I got those strings seperated, so it was still a lot of work after the whole translation.

另一个想法是将所有字符串替换为数组内容,例如代替编写"Cancel" ,编写 t [201] 之类的东西,然后我可以仅翻译t变量.但这也是很多工作,如果我在文本中包含变量,就会出现问题.

Another idea was replacing all the strings with array things, like instead of writing "Cancel", writing t[201] or something like that, and then I could translate the t variable only. But that's also a lot of work and there's a problem if I include a variable in a text.

例如,在匈牙利语中,我可以写'2 masodperc maradt',但我应该将其翻译为'剩余秒数:2'或类似的内容.然后,我必须注意包含的变量.

For excample, in hungarian I might write '2 masodperc maradt', but I should translate that to 'Remaining seconds: 2', or something like that. Then I have to mind the included variables.

那么您认为最简单的方法是进行翻译,其他程序员如何做到这一点?

例如,TotalCommander可以在一秒钟内更改语言,而无需重新启动或进行任何操作.

For excample TotalCommander changes the language in a second, without restarting or anything.

推荐答案

.net中使用resx文件进行构建.

There is a build in way in .Net using resx files.

  • 您可以在此处找到简短的介绍.

有关程序员stackexchange

MSDN包含有关此主题的文档,内容非常丰富,是一本不错的书. MSDN

MSDN is quite extensive with it's documentation about this topic and it is a good read. MSDN

有很多工具可以帮助您进行基于.Net本地化的翻译,但是您也可以直接在VS中进行.

There are a lot of Tools out there helping with the translation based on .Net localization but you can also do it in VS directly.

  • Maybe ResXManager is of your taste

能够即时更改翻译的.Net应用程序通常使用定制的国际化版本,例如加载文本文件并刷新GUI.

The .Net applications able to change translations on the fly usually use custom made internationalization e.g. loading text files and refreshing the GUI.

如果您想自己做类似的事情,请注意,还必须调整控件的大小以使文本适合.

If you want to do something like that on your own be aware that you also have to resize controls so that the text fits.

对于使用#count文本文本和#text文本文本的问题,可以使用string.Format之类.

For your problem wiht #count text text and text text #count you can use string.Format like.

  1. 将Resx文件添加到您的项目中,例如Localized.resx
  2. 添加具有值为{0}文本的字符串属性"CountText".
  3. 添加第二个resx Localized.en.resx
  4. 添加带有值文本{0}的字符串属性"CountText".到Localized.en.resx
  5. 将进度写到GUI的地方使用string.Format(Localized.CountText,myCount);
  6. 如第一个链接中所示切换程序语言.
  7. .Net自动加载语言的相应资源.

要了解所有可能性,尤其是使用VS进行翻译,您确实应该阅读MSDN库文章.如果您错过了一些东西,翻译会变得很麻烦.

To learn about all the possibilities especially translating with VS you really should go through the MSDN library articles. Translation can get cumbersome if you miss something.

这篇关于翻译Visual Studio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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