/*
 * Copyright (C) 2019 Robert Bosch GmbH Copyright (C) 2019 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { Component } from '@angular/core';
import { BciPicklistIntl } from '@bci-web-core/core';

import { fruits } from '../picklist-demo-model';
import { PicklistIntlDemo } from './picklist-intl-demo';

/** This demo shows how to translate the picklist. */
@Component({
  selector: 'bci-internationalization',
  templateUrl: './internationalization.component.html',
  styleUrls: ['./internationalization.component.scss'],
  providers: [{ provide: BciPicklistIntl, useClass: PicklistIntlDemo }],
})
export class InternationalizationComponent {
  /** Whether the picklist's labels have already been translated. */
  translated = false;

  fruitNamesList = fruits.map((fruit) => fruit.name);

  constructor(private picklistIntl: BciPicklistIntl) {}

  /** Update translations button click handler. */
  onClick(): void {
    (<PicklistIntlDemo>this.picklistIntl).updateIntl();
    this.translated = true;
  }
}
