UUI Library translation
# help-with-umbraco
a
Working in an project that's already using UUI elements:
Copy code
<uui-button type="button"
                            look="outline"
                            color="default"
                            label="Cancel"
                            ng-click="vm.closeModal()"></uui-button>
Which works like a charm, However I want to localize the label, but I can't seem to find any docs on it.. If anyone knows, i'll make a quick PR about it to the docs aswell 🙂 I see docs about it here, https://docs.umbraco.com/umbraco-cms/v/14.latest-rc/tutorials/creating-a-custom-dashboard/extending-the-dashboard-using-umbraco-ui-library But not when the button has properties declared
d
Are you doing this in Umbraco 14? Your link suggests that you are, but your message makes me think you might not.
I don't know about Umbraco 14, but I can share some insights in Umbraco 10 and 13, as I've been extensively using Lit and the umbraco UI library in 10 and 13.
In Umbraco 14, it appears that localization object is assigned to your element inside the
UmbElementMixin
, so if your element uses that mixin, it should be able to call
this.localize.term( /* arguments */ )
https://github.com/umbraco/Umbraco.CMS.Backoffice/blob/a31e74f090d989ede0be8c42d27b5d341c6c6793/src/libs/element-api/element.mixin.ts#L12 https://github.com/umbraco/Umbraco.CMS.Backoffice/blob/a31e74f090d989ede0be8c42d27b5d341c6c6793/src/packages/core/localization/localize.element.ts#L39
a
Ah sorry, no this is still in 13, was looking in 14 to find some information about how to do this
But I think I got a bit confused this afternoon as I already saw a UUI-button
Someone else's project, so assumptions were made
d
Ah well, the uui library is not attached to any localization engine as it is completely separate from the backoffice (you can use it in a non-umbraco project if you wanted), so you'll have to provide your own.
I personally do this by injecting Umbraco's angularjs localization service into my lit components and still use that, but Lit also has it's own localization framework, though I don't know how well that would work in the backoffice, I've never tried it
a
Yes somewhere I knew that.. Now im wondering what was used in that project.. if they installed the new backoffice already, or this is something already in 13 ?
I'll need to check 🙂
d
a
Well I've checked, and its umbraco 12, no extra's installed, so it isn't part of the new backoffice I guess 😄
So it has nothing to do with the new UUI, sorry about that
So it seems theyve used and criss cross
and supports the label-key parameter for the translation
I think they by accident added the UUI-button
which works, but isn't fully useable 😛
d
I wouldn't say it isn't fully usable, but it's more 'bring-your-own-translation-engine'
You can still use the translations service in angularjs, which is what the
<umb-button>
directive does internally as well
10 Views