Skip to content

i18n plugin not loaded in scene using TypeScript template: I18nScene.ts #43

@raimon-segura

Description

@raimon-segura

Hi!,

Expected Behavior

When I use this plugin with a TypeScript template it doesn't load the "i18n" in Scene and shows a console error, but the game works.

Current Behavior

It doesn't translate any text if I create a new text object usign: "this.add.text()" :
this.add
this.text(this.cameras.main.width - 15, 40, "word-hello-key")

, but it works if I extend the Phaser.GameObjects.Text class:

export default class FpsText extends Phaser.GameObjects.Text {
  constructor(scene: Phaser.Scene) {
    super(scene, 10, 10, "word-hello-key")
    scene.add.existing(this)
  }
}

TypeScript template:
https://github.com/yandeu/phaser-project-template

console error:
phaser3-template-typescript/src/scripts/scenes/mainScene.ts
./src/scripts/scenes/mainScene.ts
[tsl] ERROR in phaser3-template-typescript/src/scripts/scenes/mainScene.ts(13,10)
TS2339: Property 'i18n' does not exist on type 'MainScene'.

Possible Solution

Maybe I have to load in another way?

Steps to Reproduce (for bugs)

To reproduce just clone this template, https://github.com/yandeu/phaser-project-template , then follow the plugin steps:
1- install plugin npm i --save @koreez/phaser3-i18n
2- import & load plugin in game.ts (add import & plugins.scene into configuration)
3- initialize plugin in

Your Environment

Linux, Chrome Version 83.0.4103.61

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions