检测UICulture [英] Detecting UICulture

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

问题描述

大家好,

我正在Visual Studio中为一个类本地化一个VB项目,我对如何在代码中实现某些东西有疑问.我没有任何编程背景,因此,如果答案似乎很明显,我深表歉意,并且感谢您的帮助!

I'm localizing a VB project in Visual Studio for a class and I have a question on how to implement something in the code. I don't have any kind of programming background so I apologize if the answer seems painfully obvious and I appreciate any help!

因此,该应用程序是一个简单的子手游戏,该游戏在单人游戏模式下从文本文件中随机选择一个单词.我有该文件的版本,其中包含我要本地化的语言以及需要做的事情(这是我自己提出的解决方案 至少)是让程序检测到CurrentUICulture并访问与该语言相对应的文本文件,例如,如果UICulture是ru,则从words_RU.txt中抓取一个单词;如果是fr-FR,则从words_FR中抓取一个单词,等等. 

So the application is a simple hangman game, which in one-player mode selects a word at random from a text file. I have versions of that file for the languages I'm localizing into, and what I need to do (this is the solution I have come up with myself at least) is have the program detect the CurrentUICulture and access the text file that corresponds to that language, for example grab a word from words_RU.txt if the UICulture is ru or words_FR if it's fr-FR, etc. 

这是当前从txt中选择单词的代码:

This is the code that currently chooses a word from the txt:

我已经尝试过使用一些If语句并查看示例,但是正如我所说的,我在黑暗中摸索着,所以我希望将这个问题提交给经验更丰富的小组,因为我很确定所需的代码将非常简单.有什么想法吗? 再次感谢!

I've tried playing with some If statements and looking at examples but I'm pretty much groping in the dark as I said, so I was hoping to present the question to a more experienced group, as I'm pretty sure the code needed would be very simple. Thoughts? Thanks again!

推荐答案

因此,该应用程序是一个简单的子手游戏,该游戏在单人游戏模式下从文本文件中随机选择一个单词.我有该文件的版本,其中包含我要本地化的语言以及需要做的事情(这是我自己提出的解决方案 至少)是让程序检测到CurrentUICulture并访问与该语言相对应的文本文件,例如,如果UICulture是ru,则从words_RU.txt中抓取一个单词,如果是fr-FR,则是words_FR,等等.

So the application is a simple hangman game, which in one-player mode selects a word at random from a text file. I have versions of that file for the languages I'm localizing into, and what I need to do (this is the solution I have come up with myself at least) is have the program detect the CurrentUICulture and access the text file that corresponds to that language, for example grab a word from words_RU.txt if the UICulture is ru or words_FR if it's fr-FR, etc.

当前区域性是与当前线程相关联的cultureinfo对象的属性.参见:
https://msdn.microsoft.com/en -us/library/system.globalization.cultureinfo.defaultthreadcurrentculture(v = vs.110).aspx

The current culture is a property of the cultureinfo object associated with the current thread.  See:
https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.defaultthreadcurrentculture(v=vs.110).aspx


这篇关于检测UICulture的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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