Azure / opendigitaltwins-dtdl

Digital Twins Definition Language
Creative Commons Attribution 4.0 International
462 stars 160 forks source link

Question: declare Property as localizable string? #136

Closed ruthoferroman closed 1 year ago

ruthoferroman commented 1 year ago

Is there a way to declare a property as a localizeable string like the models 'displayName'?

rido-min commented 1 year ago

Hi @ruthoferroman

Not sure I understand this request, displayName is already a localizable string. Can you elaborate?

ruthoferroman commented 1 year ago

Hi @rido-min

What i want to do is to define a custom property "myProperty..." in my model which is a localizable string.

rido-min commented 1 year ago

@ruthoferroman what property elements do you want to localize in the example below?

{
    "@context" : "dtmi:dtdl:context;2",
    "@type": "Interface",
    "@id": "dtmi:sample:property;1",
    "contents": [
      {
        "@type": "Property",
        "name": "myProperty",
        "schema": "string"
      }
    ]
}
ruthoferroman commented 1 year ago

@rido-min I'd like to define a property in a model like:

{
  "@id": "dtmi:AutomationApps:Devices:Blinds:Blind;1",
  "@type": "Interface",
  "@context": "dtmi:dtdl:context;2",
  "displayName": "Blind",
  "contents": [
    {
      "@type": "Property",
      "name": "LocProperty",
      "schema": "LOCALIZABLESTRING"
    },
...

so that i can use it in twins somehow like

"LocProperty": {
        "de": "keine Verbindung zum Gerät",
        "en": "No Connection to Device!",
        "es": "¡Sin conexión con el dispositivo!"
      }

hope this makes it a little more clear

jrdouceur commented 1 year ago

You can do this:

{
  "@context": "dtmi:dtdl:context;2",
  "@id": "dtmi:AutomationApps:Devices:Blinds:Blind;1",
  "@type": "Interface",
  "displayName": "Blind",
  "schemas": [
    {
      "@id": "dtmi:AutomationApps:schema:localizableString;1",
      "@type": "Map",
      "mapKey": {
        "name": "languageCode",
        "schema": "string"
      },
      "mapValue": {
        "name": "localizedString",
        "schema": "string"
      }
    }
  ],
  "contents": [
    {
      "@type": "Property",
      "name": "LocProperty",
      "schema": "dtmi:AutomationApps:schema:localizableString;1"
    }
  ]
}
ruthoferroman commented 1 year ago

@jrdouceur That's what I was looking for

Thx!