autoFields and i18n
how can i use autoFields with translations? i'm using now pascalprecht.translate.
for now i solve it in json:
property: 'password',
placeholder : $translate.instant('PASS'),
label : '',
type : 'password',
addons : [{icon : 'fa fa-lock'}],
attr: {
required: true,
ngMinlength:5 },
msgs: {
match: $translate.instant('PASSWORDSNOTMATCH')
},
and translation does not change on language change.
but my goal is to override defaultMsgs with $autofieldsProvider.settings.validation
Hey @voznik, this is something I'm going to need to look into. I haven't used autofields with i18n, so I'm not sure right now. Anyone else have any experience with this?
one more from me:
$scope.schema = [ {
property : 'org',
placeholder : '\{\{\'NAME\' | translate\}\}',
label : '',
type : 'text',
addons : [ {
icon : 'fa fa-suitcase'
} ],
attr : {
required : true,
ngMinlength : 2,
ngMaxlength : 100,
autofocus : 'autofocus',
capitalize : 'capitalize'
},
// msgs : {
// required : '\{\{\'ADDRESS\' | translate\}\}',
// minlength: '\{\{\'VALUESHORT\' | translate\}\}',
// maxlength: '\{\{\'VALUELONG\' | translate\}\}',
// pattern : '\{\{\'BADSIMBOLS\' | translate\}\}',
// }
},
so, when i mask braces - placeholder translation works. but for validation messages it crashes in console.
and i have errors when i was trying to add $translate.instant into $autofieldsProvider.settings.validation section
p.s.: your component is really, really good. such clean and powerfull.
for now i unerstand that i can not use $translate service in autofields.validation .config block
because of this is not allowed in angular, must use services in .run block
how can i intercept fieldElements.msgs in .run block
please, point me to the right direction with config defaultMsgs
The defaultMsgs can be set in a config block:
angular.module('app')
.config(function($autofieldsProvider){
$autofieldsProvider.settings.validation.defaultMsgs = {
//Replacements...
};
}
See all default messages here
yes, but i can not use translate provider (and other providers) in .config block. in which block can i translate defaultMsgs?
Currently you can do it at the controller level via options passed to autofields.
###Javascript
scope.options = {
validation: {
defaultMsgs: {
//Replaced messages here
}
}
}
###HTML
<auto-fields fields="fields" data="data" options="options"></auto-fields>
I understand that this isn't ideal and I'll look into a way to expose the global settings at the run block level.
Maybe, angular-translate could be included by default. One approach is how its done in JanStevens/angular-growl-2