Problem with localization extension with embedded keys

Hi folks :waving_hand:

I have a property editor that uses 2 keys for localization, so part of my package is localizations for those in two languages (Danish and English) - the documentation states that it’s possible to embed the keys in the meta section of the extension’s manifest if there’s only a few - but I can’t get this to work.

Here’s what my manifest looks like:

{
  "$schema": "../../umbraco-package-schema.json",
  "name": "My Property Editor",
  "version": "1.0.0",
  "extensions": [{
    "type": "propertyEditorUi",
    "alias": "My.Property.Editor",
    "name": "My Property Editor",
    "element": "/App_Plugins/MyPropertyEditor/my-property-editor.js",
    "elementName": "my-property-editor",
    "meta": { ... }
  },
  {
    "type": "localization",
    "alias": "My.Property.Editor.Localize.EnUs",
    "name": "English",
    "meta": {
      "culture": "en",
      "localizations": {
        "myprop": {
          "propName": "Name of this",
          "propKind": "Kind"
        }
      }
    }
  },
  {
    "type": "localization",
    "alias": "My.Property.Editor.Localize.DaDk",
    "name": "Danish",
    "meta": {
      "culture": "da-DK",
      "localizations": {
        "myprop": {
          "propName": "Navn på denne",
          "propKind": "Slags"
        }
      }
    }
  }]
}

When I install the package, all of the above extensions (the propertyEditorUi + 2 localizations) are listed in the package insights but when I use the keys in the property editor, I only get the fallback strings, e.g.:

<umb-localize key="myprop_propName">(fallback string)</umb-localize>

I haven’t tried the “long version” yet (extracting keys to separate JS files) but will probably, just to rule out any other problem…

Thanks,
/Chriztian

Hi Christian,

Don’t know your exact setup, but if I add theblocalization extension (as per the docs, with section and key1 and key2) to my umbraco-package.json, and consume it from my user profiel app extension, it works fine

{
  "id": "Umbraco.Community.Bookmarks",
  "name": "Umbraco.Community.Bookmarks",
  "version": "0.0.0",
  "allowTelemetry": true,
  "extensions": [
    {
      "name": "Umbraco Community Bookmarks Bundle",
      "alias": "Umbraco.Community.Bookmarks.Bundle",
      "type": "bundle",
      "js": "/App_Plugins/UmbracoCommunityBookmarks/umbraco-community-bookmarks.js"
    },
    {
      "type": "localization",
      "alias": "MyPackage.Localize.EnUS",
      "name": "English",
      "meta": {
        "culture": "en",
        "localizations": {
          "section": {
            "key1": "value1",
            "key2": "value2"
          }
        }
      }
    }
  ]
}

Thanks Dirk!

I had a look in the Backoffice language selector (on my user profile), and it seems to only use the “da” part of the “da-DK” ISO value, so tried changing the culture for my Danish keys and now it works…

Did you also try Dutch? Isn’t there like a few different ISOs for them?

Anyway, thank you checking my sanity :+1: :grin:

1 Like

Haven’t tried Dutch, who wants to use that language… :slight_smile: Jokes aside, I’ll see if it indeed makes a difference with those be-NL or be-FR iso’s or if I can only use be

1 Like

The Backoffice language is most likely only the “language” part (not the culture) of the language, so da it would be correct. In a few cases, we also have cultures such as Portuguese (pt) and Portuguese (Brazil) (pt-BR).

If you register a language, such as da-DK, it would effectively become a new culture (Danish (Denmark)) that you could select when editing your user profile settings.

In most cases, you probably don’t want to trouble yourself with writing seperate localizations for for instance US english and UK english.

So in my manifest I usually set the culture to the least specific culture, so only use en, dk, nl etc. Umbraco is designed to fall back to less specific cultures anyway, so if the culture in the backoffice is en-US, it will also work with a en localization culture.

1 Like

Absolutely correct.

It goes like this: language-region → language → “en” (the fallback language for Umbraco)

Example: nl-NL → nl → en

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.