保存最好的方法/使用多种语言 [英] best way to store/use multiple languages

查看:118
本文介绍了保存最好的方法/使用多种语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想创建一个支持多国语言C#应用程序,我应该怎么保存呢?

If I would want to create a c# application that support multiple languages, how should I store them?

我可能会使用常量在应用程序持有价值

I'd probably use constants in the application as value holders.

如:
Console.Write(FILE_NOT_FOUND);

Such as: Console.Write(FILE_NOT_FOUND);

在编译时,它会改变到由语言确定的字符串。
我可能会坚持到3种语言(丹麦语,英语,德语),不是,我认为它虽然很重要。

When compiled, it would change into the string determined by the language. I'll probably stick to 3 languages (Danish, English, Deutsch), not that I think it matters though.

这似乎是一种浪费对每种语言,其中当应用程序被编译一切都处理的类文件。这也意味着,你不得不重新编译,你想改变一个字符串每次重新分配整个程序。
据我所知,硬编码字符串是一件坏事。

It seems to be a waste to have a class file for each language, which all is processed when the application is compiled. It would also mean that you'd have to re-compile and re-distribute the whole program every time you want to change a string. As far as I know, hardcoded strings is a bad thing.

也许一个文本文件?
English.txt
线路1:FILE_NOT_FOUND =文件未找到。再试一次
2号线
3号线

Maybe a text file? English.txt Line1: FILE_NOT_FOUND=File Not Found. Try Again Line2 Line3 etc.

Danish.txt
线路1:FILE_NOT_FOUND = Filen blev IKKE fundet。省IGEN
2号线
3号线
等。

Danish.txt Line1: FILE_NOT_FOUND=Filen blev ikke fundet. Prøv igen Line2 Line3 etc.

等。
如果用户选择了英语,它读取该文本文件,并设置不同的恒定值。

and so on. If the user selects English, it reads the text file and set the different constant values.

最后一个我能想到的是把它放在一个SQL数据库。

The last one I can think of is placing it in a SQL database.

你能不能给我一些输入? :)

Could you give me some input? :)

另外,我试着写文件_不_ FOUND(不含空格,但是文本编辑器不会让我

Also, I tried writing FILE _ NOT _ FOUND (without spaces, but the text editor wouldn't let me

推荐答案

使用的资源文件。这是处理本地化的标准方式。

Use a resource file. That's the standard way to handle localization.

有关详细信息,的请参见本教程

- - 编辑 -

--- EDIT ---

这是另一种教程的可在这里的这一个使用更好的命名方式,因此它可能会更清楚它是如何工作的。

An alternative tutorial is available here. This one uses much better naming, so it may be more clear how it works.

这篇关于保存最好的方法/使用多种语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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