vime-js / vime

Customizable, extensible, accessible and framework agnostic media player. Modern alternative to Video.js and Plyr. Supports HTML5, HLS, Dash, YouTube, Vimeo, Dailymotion...
https://vimejs.com
MIT License
2.75k stars 154 forks source link

i18n not working #298

Open Adrii77 opened 2 years ago

Adrii77 commented 2 years ago

Hello,

After reading the i18n's documentation, the (audio) player still contains english labels.

My code : Component's class :

const fr: Translation = {
  ... // some french translations
};

@Component({
  selector: 'app-player',
  templateUrl: './player.component.html',
  styleUrls: ['./player.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PlayerComponent {
  translations = { fr };
}

Component's template :

<vm-player
  language="fr"
  [translations]="translations">
  <vm-audio>
    <source
      [attr.data-src]="........."
      type="audio/mp3" />
  </vm-audio>

    <vm-default-ui></vm-default-ui>
</vm-player>

I also tried to use the second option with "extendLanguage" method, but same issue.

Versions : Angular : 13.2.5 "@vime/angular": "^5.3.1", "@vime/core": "^5.3.1",

Adrii77 commented 2 years ago

Ok, it works know, but I think there is a bug on player initialization. The issue is caused by the "language" input which ignores any assigned value from the template.

It finally worked by setting language inside my component's class, in the callback function call when "vmReady" emit.

<vm-player (vmReady)="ready()" [translations]="translations">
  <vm-audio>
    <source
      [attr.data-src]="........."
      type="audio/mp3" />
  </vm-audio>

    <vm-default-ui></vm-default-ui>
</vm-player>
export class PlayerComponent {
  @ViewChild(Player) private player!: Player;
  readonly translations = { fr };

  constructor(private readonly playerService: PlayerService) {}

  ready(): void {
    this.player.language = 'fr';
  }
} 

I didn't close the issue because the default language assignation from the template input should works.