Skip to content

Language panel

Filip Leitner edited this page Apr 30, 2024 · 5 revisions

Language switcher

The user can change the interface language of the application by selecting one of the available languages from the language list. The list of available languages is based on the languages listed in the HsConfig.enabledLanguages section. Currently, all UI texts from English (the default language, if not set otherwise) are translated into Czech (cs), Slovak (sk), Latvian (lv), as well as partly French (fr) and Dutch (nl).

Config parameters

List of useful config parameters for the language panel can be found here:

enabledLanguages

language

Set default language

this.HsConfig.update({
      language: 'lv',
});

Set enabled languages

this.HsConfig.update({
      enabledLanguages: 'cs, lv',
});

Enable/disable

import {HsConfig} from 'hslayers-ng/config';
@Component({
  selector: 'your-app-component',
  templateUrl: 'your-app-component.html',
})
export class YourAppComponent {
  constructor(hsConfig: HsConfig) {
    this.HsConfig.update({
      panelsEnabled: {
        language: true //(true by default)
      }
    });
  }
}

If not using HslayersModule containing all components

Add HsLanguageModule import:

import {HsLanguageModule} from 'hslayers-ng/components/language';
@NgModule({
  imports: [HsLanguageModule ],
})
export class YourAppModule {}

Add HsLanguageComponent component:

import {HsLayoutService } from 'hslayers-ng/core';
import {HsLanguageModule} from 'hslayers-ng/components/language';
@Component({
  selector: 'your-app-component',
  templateUrl: 'your-app-component.html',
})
export class YourAppComponent {
  constructor(hsLayoutService: HsLayoutService) {
    hsLayoutService.createPanel(HsLanguageComponent, {});
  }
}
Clone this wiki locally