Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Use this directive to render a button with a dropdown of alternative actions.

function ButtonGroupDirective() {

function controller($scope) {
function controller($scope, localizationService) {
$scope.toggleStyle = null;
$scope.blockElement = false;

Expand Down Expand Up @@ -121,6 +121,31 @@ Use this directive to render a button with a dropdown of alternative actions.
}
}
}

// As the <localize /> directive doesn't support Angular expressions as fallback, we instead listen for changes
// to the label key of the default button, and if detected, we update the button label with the localized value
// received from the localization service
$scope.$watch("defaultButton.labelKey", function () {
if (!$scope.defaultButton.labelKey) return;
localizationService.localize($scope.defaultButton.labelKey).then(value => {
if (value && value.indexOf("[") === 0) return;
$scope.defaultButton.label = value;
});
});

// In a similar way, we must listen for changes to the sub buttons (or their label keys), and if detected, update
// the label with the localized value received from the localization service
$scope.$watch("defaultButton.subButtons", function () {
if (!Array.isArray($scope.subButtons)) return;
$scope.subButtons.forEach(function (sub) {
if (!sub.labelKey) return;
localizationService.localize(sub.labelKey).then(value => {
if (value && value.indexOf("[") === 0) return;
sub.label = value;
});
});
}, true);

}

function link(scope) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
href-target="{{defaultButton.hrefTarget}}"
button-style="{{buttonStyle}}"
state="state"
label="{{defaultButton.labelKey}}"
label="{{defaultButton.label}}"
label-key="{{defaultButton.labelKey}}"
shortcut="{{defaultButton.hotKey}}"
shortcut-when-hidden="{{defaultButton.hotKeyWhenHidden}}"
Expand All @@ -29,7 +29,7 @@
ng-disabled="disabled">
<span class="caret">
<span class="sr-only">
<localize key="{{labelKey}}">{{label}}</localize>
{{defaultButton.label}}
</span>
</span>
</button>
Expand All @@ -48,8 +48,7 @@
hotkey="{{subButton.hotKey}}"
hotkey-when-hidden="{{subButton.hotKeyWhenHidden}}"
ng-disabled="disabled">
<localize ng-if="subButton.labelKey" key="{{subButton.labelKey}}">{{subButton.labelKey}}</localize>
<span ng-if="subButton.label">{{subButton.label}}</span>
<span>{{subButton.label}}</span>
<span ng-if="subButton.addEllipsis === 'true'">...</span>
</button>
</umb-dropdown-item>
Expand Down