I'm using angular-translate and angular-xeditable. I have the following field:
<a href="#"
       editable-text="name"
       onbeforesave="validate($data)"
       onaftersave="save(name)">
       {{ name }}
</a>
In the validate function I'm validating the name field and if everything is correct I'm saving the data through the save method. However, if the name field is not correct, I should return a validation message. There's an example in the documentation of angular-xeditable of such a scenario.
$scope.validate = function(name) {
    if (name.length > 10) {
        return "Validation Message that doesn't need multiple languages";
    }
}
Now, if the name field is more than 10 characters long, a message will be display to the user and the data won't be saved. However, I'm using angular-translate in my app and I want to show a message that is translated in the appropriate language. Moreover, I want to customize my messages for different scenarios so that I won't need to have thousands of different messages for all of my fields.
For example:
var translationsEN = {
    STRING_LENGTH_MESSAGE: '{{ fieldName }} should be between {{ min }} and {{ max }}',
    REQUIRED: '{{ fieldName }} is required.'
}
var translationsDE = {
    // The same messages in German.
}
Now the best thing that I could think of is changing the code in the validate function to this:
$scope.validate = function(name) {
    if (name.length > 10) {
        $translate('VALIDATION_MESSAGE', { fieldName: 'name', min: 0, max: 10 })
            .then(function(translation) {
                $scope.message = translation;
            }
        );
        return $scope.message;
    }
}
Of course, at the time of showing the error message, the error message is not translated yet and the message that is shown to the user is not correct.
How can I achieve the desired result - to show translated validation messages to the user?
Here's a JSFiddle of my example.
 
     
    