I'm using an UI framework : SmartAdmin
This provide an internationalization feature with i18n
I'm trying to use it this Boostrap Validation Module.
If I put this, it's working :
<input type="text" class="form-control" name="firstname" data-bv-notempty="true"
data-bv-notempty-message="The first name is required and cannot be empty"
data-bv-stringlength-max="50" data-bv-stringlength-message="The first name must be less than 50 characters long"/>
But I I try to use a pipe :
<input type="text" class="form-control" name="firstname" data-bv-notempty="true"
data-bv-notempty-message="{{'The first name is required and cannot be empty' | i18n}}"
data-bv-stringlength-max="50" data-bv-stringlength-message="The first name must be less than 50 characters long" />
I get this error :
Can't bind to 'data-bv-notempty-message' since it isn't a known property of 'input'. ("ut type="text" class="form-control" name="firstname" data-bv-notempty="true" [ERROR ->][data-bv-notempty-message]="'The first name is required' | i18n" data-bv-stri"): ng:///UserModule/UserAccountComponent.html@66:22
Question : How can use pipe in an input attribut?
EDIT : Add code pipe :
import { Pipe, PipeTransform } from '@angular/core';
import {I18nService} from "./i18n.service";
@Pipe({
name: 'i18n',
pure: false
})
export class I18nPipe implements PipeTransform {
constructor(public i18nService: I18nService){}
transform(phrase: any, args?: any): any {
//console.log(phrase)
return this.i18nService.getTranslation(phrase);
}
}
Method : getTranslation()
public getTranslation(phrase:string):string {
return this.data && this.data[phrase] ? this.data[phrase] : phrase;
}