import { Aurelia } from 'aurelia-framework' ; import { I18N } from 'aurelia-i18n' ; import { ValidationMessageProvider } from 'aurelia-validation' ; import environment from './environment' ; import * as Backend from 'i18next-xhr-backend' ; export function configure ( aurelia ) { aurelia . use . standardConfiguration ( ) . feature ( 'elements' ) ; if ( environment . debug ) { aurelia . use . developmentLogging ( ) ; } if ( environment . testing ) { aurelia . use . plugin ( 'aurelia-testing' ) ; } aurelia . use . plugin ( 'aurelia-validation' ) ; aurelia . use . plugin ( 'aurelia-i18n' , ( instance ) => { instance . i18next . use ( Backend ) ; return instance . setup ( { backend : { loadPath : './locales/{{lng}}/{{ns}}.json' } , attributes : [ 't' , 'i18n' ] , fallbackLng : 'en' , debug : true } ) ; } ) ; const i18n = aurelia . container . get ( I18N ) ; ValidationMessageProvider . prototype . getMessage = function ( key ) { const translation = i18n . tr ( `errorMessages.${ key }` ) ; return this . parser . parseMessage ( translation ) ; } ; ValidationMessageProvider . prototype . getDisplayName = function ( propertyName ) { return i18n . tr ( propertyName ) ; } ; aurelia . start ( ) . then ( ( ) => { return aurelia . setRoot ( ) ; } ) ; }