Closed ronaldo971 closed 9 years ago
There's nothing specific to this module that handles internationalization. Given you have full control over the data in the modal, you are responsible managing translations. What are you currently doing in your application now?
Yes i'm using https://angular-translate.github.io/ to handle internationalization.
I can define ok and cancel every time I'm using $confirm service in controller but i want to define this by defaults instead.
Ok so what problems are you having doing so? Can't you inject the translation service into the run function and assign with that?
If you want the translation to be dynamic (to change when you change the language, you'll have to override the default template to include the translate filter
Sorry for delay
You are right. I've managed to handle internationalization with a custom default template
//===============================
// Angular Confirm Configuration
//===============================
.run(function($confirmModalDefaults) {
$confirmModalDefaults.templateUrl = '.../templates/confirm_template.html';
})
And the confirm_template.html looks like this
<div class="modal-header">
<h3 class="modal-title">{{data.title}}</h3>
</div>
<div class="modal-body">{{data.text}}</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">{{'common.yes' | translate}}</button>
<button class="btn btn-default" ng-click="cancel()">{{'common.no' | translate}}</button>
</div>
Never mind this issue
It's possible to define default settings with the following
.run(function($confirmModalDefaults) { $confirmModalDefaults.templateUrl = 'path/to/your/template'; $confirmModalDefaults.defaultLabels.title = 'Modal Title'; $confirmModalDefaults.defaultLabels.ok = 'Yes'; $confirmModalDefaults.defaultLabels.cancel = 'No'; })
How to handle internationalization ( $confirmModalDefaults.defaultLabels.ok = 'Oui' for french for instance)