I used the Config/Lang/nl_NL.user.xml to translate several BO action buttons.
Those translations are applied on all buttons, but I want to change one translation for one specific button.
I sometimes change the text of a button or a label or other element by using an angular interceptor to catch the view html and simply replace it the output-html via javascript.
For example:
angular.module('umbraco.services').config([
'$httpProvider',
function ($httpProvider) {
$httpProvider.interceptors.push(function ($q) {
return {
'response': function (response) {
if (response.config.url.indexOf("views/propertyeditors/listview/listview.html") === 0) {
response.data = response.data.replace('current-button-text', 'new-button-text');
}
return response;
}
};
});
}]);
When the text is not in a view but in a directive, than it's a lot more difficult to change it because, as far as i know, an directive can not be intercepted.
Just out of curiosity - What is the exact version number of Umbraco 8 where you're doing this? The reason I'm asking is that since Umbraco 8.1.0 the interceptor approach should not really work anymore according to Nathan's post here https://nathanw.com.au/post/replacing-interceptors-with-directive-injection/
But of course if it's an earlier release of v8 then no problem :-) Just be aware that this approach might stop working if the solution is ever upgraded.
Interesting - I recently did a content app where the interceptors approach would have been very useful but ran into the issue Nathan mentioned but I guess it depends what you're doing whether the approach still works or not.
The only way i can think of is extracting it from the url. As far as I know there is no (easy) way to inject an editorState.
Perhaps something like this?
var nodeId = (window.location.href.match(/edit\/(\d+)$/) || []).pop();
if (nodeId) {
// Do something with the node id
}
Can you give some more context what you want to do with it?
In the Umbraco backend there are lots of document types with child nodes, inside the list view there is a button to create new nodes, the 'action_create' button.
I want to override the default 'New' localization in the button for only one single document type.
The interceptor is changing the text for all of them, I also played a bit with JS there to get the ID extracted from the URL, but it failed in the angular.js, some issue with a angular promises and didn't figure it out yet.
Umbraco localize one button in BO
Hi,
I used the Config/Lang/nl_NL.user.xml to translate several BO action buttons. Those translations are applied on all buttons, but I want to change one translation for one specific button.
How can I do that?
Hi Peter,
I sometimes change the text of a button or a label or other element by using an angular interceptor to catch the view html and simply replace it the output-html via javascript.
For example:
When the text is not in a view but in a directive, than it's a lot more difficult to change it because, as far as i know, an directive can not be intercepted.
Best regards,
iNETZO
Hi iNETZO,
I got it all working, thanks for the reply.
For others: I created a 'Tweaks' folder inside the App_Plugins folder, with a package.manifest and tweaks.js. (here I pasted the code of iNETZO)
Find more info here: https://24days.in/umbraco-cms/2015/umbraco-7-back-office-tweaks/
One little question, inside the response I am not able to read the ID of the current content I am editing, is this possible some way?
Hi Peter
Just out of curiosity - What is the exact version number of Umbraco 8 where you're doing this? The reason I'm asking is that since Umbraco 8.1.0 the interceptor approach should not really work anymore according to Nathan's post here https://nathanw.com.au/post/replacing-interceptors-with-directive-injection/
But of course if it's an earlier release of v8 then no problem :-) Just be aware that this approach might stop working if the solution is ever upgraded.
/Jan
Hi Jan,
Thanks for this tip. While I'm still succesfully using interceptors in 8.6.3, i will take a look if it's possible to convert mines to directives.
Cheers
Interesting - I recently did a content app where the interceptors approach would have been very useful but ran into the issue Nathan mentioned but I guess it depends what you're doing whether the approach still works or not.
Good to know :-)
Cheers!
Hi Jan,
The Umbraco version is on 8.6.2 and its working ok it seems!
The only way i can think of is extracting it from the url. As far as I know there is no (easy) way to inject an editorState. Perhaps something like this?
Can you give some more context what you want to do with it?
Cheers
Hi iNTENSO,
I will give it a try tomorrow!
In the Umbraco backend there are lots of document types with child nodes, inside the list view there is a button to create new nodes, the 'action_create' button.
I want to override the default 'New' localization in the button for only one single document type.
The interceptor is changing the text for all of them, I also played a bit with JS there to get the ID extracted from the URL, but it failed in the angular.js, some issue with a angular promises and didn't figure it out yet.
is working on a reply...