How can I load the translated name directly from my resources.resx file? [Display(Name:“Selection”, Description:“Description”)]
I thought I could just translate it like that, but unfortunately it doesn’t work. Is there a better way? [Display(Name: Resources.Selection, Description:“Description”)]
using OpenTap;
using System.Globalization;
using System.Security.AccessControl;
[Display(“MyStep”, Group: “Examples”, Description: “Ein Beispiel-Testschritt mit Übersetzung”)]
public class MyStep : TestStep
{
[Display(Name : “MyProperty_Name”)]
public string MyProperty { get; set; }
public override void Run()
{
var typeData = TypeData.GetTypeData(this);
var memberData = typeData.GetMember(nameof(MyProperty));
var translatedDisplay = memberData.GetTranslatedDisplayAttribute();
Console.WriteLine($"Anzeigename (übersetzt): {translatedDisplay.Name}");
}
}
If you have a package for your test steps, it should be easy enough to write translations. You can also add translations for packages that you did not author yourself.
There are some requirements to the naming inside the resx file, but if you do tap sdk translate OpenTAP and look at the result, i think you can get an idea of it. Here is an example: