import { Component, OnInit, Input } from '@angular/core';
import { ButtonModel } from '../../../models/button/button.model';
import { InputModel } from '../../../models/input/input.model';
import { WeatherComponentModel } from '../../../models/weather/weather-component.model';
import { I18NService } from '../../../services/i18n-service/i18n.service';
@Component({
selector: 'cf-demo-core-2',
template: "
Messages, tooltips and dates internationalization
{{ locale.title }}
{{ moneyFormatted }} Component internationalization
",
styles: [""]
})
export class CfDemoCore2 implements OnInit {
themeName: string = '';
title = "DemoCore";
myTooltip = {
message: "My Test Tooltip",
position: "above"
};
money:number = 10000;
moneyFormatted: string;
enabledI18N = true;
localeName = "";
locales = [{
"value": "en-US",
"title": "USA"
}, {
"value": "fr-FR",
"title": "France"
}];
button1= new ButtonModel ();
button2 = new ButtonModel ({
label: new Date().toString(),
iconPosition:"right"
});
input1 = new InputModel ({
type : "text",
placeholder: "current date",
maxlength : "10",
hint : {
text : "",
align : "start"
}
});
demoWeather = new WeatherComponentModel ({
defaultCity: "Paris"
});
constructor(private i18nService: I18NService) {}
ngOnInit() {
this.internationalize();
}
setLocale(): void {
this.i18nService.setLocale(this.localeName)
.then(() => {
// after resetting locale, we have to reset localized messages from new current dictionary
this.internationalize();
});
}
internationalize(): void {
// get localized messages from current dictionary
this.myTooltip.message = this.i18nService.lookup('customer.form.tooltip.message');
this.button1.label = this.i18nService.lookup('customer.form.validate');
this.input1.value = this.i18nService.formatDateWithTokens(new Date().toString(), 'L');
//this.input1.value = this.i18nService.formatDate(new Date());
this.moneyFormatted = this.i18nService.formatCurrency(this.money);
}
}