-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Manifest Localization (Localize # in strings) #1556
Conversation
This reverts commit adedb64.
…braco/Umbraco.CMS.Backoffice into feature/localize-#-in-strings
I discussed with Jacob in slack whether we can add ${this.localize.stringOr('#general_something', 'Something'); I guess if it's a string with multiple translatable keys you could use args to replace by index ${this.localize.stringOr('#buttons_save some non translated content #more_translatedContent', 'Save', 'Something Else'); Or maybe even a dictionary option? ${this.localize.stringOr('#buttons_save some non translated content #more_translatedContent', {
buttons: {
save: "Save"
},
more: {
translatedContent: "Something Else"
}
}); |
Question, you give the example of |
Thanks for your perspective @mattbrailsford If it is something we want to do for My example with some parts of a string translated might be a bit weird, but it is mostly to ensure that we don't force ourselves to allow translation of the first word. I will leave it out of this PR though so we allow for translations of manifests in the first place. I must admit that I haven't tested whether this example actually works |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested out, all works as expected. 👍
Description
This PR adds the ability to localize parts of a string. The PR adds a new method on the localization controller, it will look for any words prefixed with a # in the string and replace them with the localized string.
I am a little unsure about the method name, so I am open to suggestions. This was the best I could come up with as it is just a regular string with magic characters.
The PR updates a lot of the current manifests, but I might have missed some here and there. We can update these when we find them.
Manifest
It is now possible to prefix values in manifests with a hash and they will be translated:
Most common use case in an UmbElement:
Is it also possible to do something like this. This is mostly to ensure that any word prefixed with a # will get translated if we invent some template language at some point.
If a translation can't be found for a ket it will return the key:
#unknown_key
Types of changes
Caution
Breaking Change
It is no longer possible to use the
labelKey
anddescriptionKey
props in the 'entityUserPermission' manifest. Instead, prefix the value in thelabel
anddescription
prop.