简体   繁体   English

强制 .NET/C# UI 自动化使用特定的文化(土耳其语)

[英]Forcing .NET/C# UI Automation to use a specific culture (Turkish)

I have a UI Automation application that is written in C# and uses .NET(currently 3.5 but if 4 solves the issue I will gladly change).我有一个用 C# 编写并使用 .NET 的 UI 自动化应用程序(当前为 3.5,但如果 4 解决了问题,我很乐意更改)。 I am running in an English version of Windows 7. I want be able to run this application on any given UI, and have it behave as follows, regardless of how the given UI is setup or what the current system language is, as those things are generally beyond my control:我正在运行 Windows 7 的英文版。我希望能够在任何给定的 UI 上运行此应用程序,并且无论给定 UI 的设置方式或当前系统语言是什么,我都希望它的行为如下通常是我无法控制的:

I want to force an application using UI Automation to use the Turkish rules for capitalization.我想强制使用 UI 自动化的应用程序使用土耳其语规则进行大写。 Particularly, if the automation application was being run on a UI that contained the character 'i', I want the portions of UI automation that automatically convert a string/character to uppercase to convert that character to 'İ' not 'I'.特别是,如果自动化应用程序在包含字符“i”的 UI 上运行,我希望 UI 自动化部分自动将字符串/字符转换为大写以将该字符转换为“İ”而不是“I”。

This is particularly an issue with access and accelerator keys.对于访问键和加速键来说,这尤其是一个问题。 For example, if a button in a UI had 'i' as it's access key, then the AutomationElement in the UI automation application for that button would list its access key as 'I', which is incorrect in Turkish.例如,如果 UI 中的按钮将“i”作为访问键,则该按钮的 UI 自动化应用程序中的AutomationElement会将其访问键列为“I”,这在土耳其语中是不正确的。

I have tried setting the Thread culture and Thread ui culture to Turkish but that does not work.我尝试将 Thread 文化和 Thread ui 文化设置为土耳其语,但这不起作用。 I am unsure how else to go about forcing the AutomationElement class to do this.我不确定 go 如何强制AutomationElement class 执行此操作。 Any suggestions/help/examples would be greatly appreciated.任何建议/帮助/示例将不胜感激。

If this was unclear please let me know and I will try to explain it better.如果不清楚,请告诉我,我会尽力解释得更好。

If you want to just uppercase strings correctly, it is as easy as that:如果您只想正确地大写字符串,就这么简单:

string turkish = "iptal";
CultureInfo turkishCulture = new CultureInfo("tr-TR");
string upperCased = turkish.ToUpper(turkishCulture);

Unfortunately, you would have to do this for each string.不幸的是,您必须为每个字符串执行此操作。 Unfortunately, I don't quite know what is your use case, so my answer might be not very useful...不幸的是,我不太清楚你的用例是什么,所以我的回答可能不是很有用......

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

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