Translate Display[] attribute

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”)]

Hi @fauser,

This is possible with reflection, but why do you need to get the translated Display attribute?

Here is how this can be done (although I suspect you actually want something else):

var translatedName = TypeData.GetTypeData(myObject).GetMember("myMember").GetTranslatedDisplayAttribute().Name;

But how do I then link that to my resource file?

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}");
}

}

Did you see the documentation topic relating to translation? Translating Packages | OpenTAP

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.

Yes, but the documentation only applies if you have a TapPackage.

However, I want a central resource file for all my custom test steps in Visual Studio (as shown in the previous screenshot).

So basically, I’m creating an .exe file, not a .TapPackage.

I want my TestStep to be directly linked to the “Resource File” from my project, so I don’t have to create it first with tap sdk translate.

If you put the resx file inside: [TAP folder]/Languages/Resource.de.resx

Then inside the Engine settings you will get the following option:

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:

 <data name="OpenTap.Plugins.BasicSteps.DelayStep.DelaySecs.Name" xml:space="preserve">
    <value>Time Delay</value>
  </data>