保存最好的方法/使用多种语言

编程入门 行业动态 更新时间:2024-10-24 12:23:30
本文介绍了保存最好的方法/使用多种语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果我想创建一个支持多国语言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.

更多推荐

保存最好的方法/使用多种语言

本文发布于:2023-11-01 20:28:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550331.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最好的   多种   语言   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!