npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@koreez/phaser3-i18n

v2.0.6

Published

Internationalization for phaser done right. Using the i18next i18n ecosystem.

Downloads

28

Readme

Phaser3 i18n Plugin

GitHub license Build Status codebeat badge Test Coverage npm version Greenkeeper badge styled with prettier

Phaser3 i18n is a plugin for Phaser 3 that allows you to have seamless translations in your game. It uses i18next as it's source for translations management, which is widely adopted by the JS community in other projects as well.

Key features:

  • Support for translations namespaces
  • Simple key/value JSON
  • Seamless switching of languages
  • No extra function calls for translating strings, directly build into Phaser's Text object

Getting Started

Installation

npm

$ npm i -g npm
$ npm i --save  @koreez/phaser3-i18n

Usage

Import the plugin

import { I18nPlugin } from "@koreez/phaser3-i18n";

Load the plugin

You need to load the plugin in your game. This is done just like any other plugin in Phaser 3. So, to load the plugin, include it in plugins config.

const config = {
    type: Phaser.AUTO,
    parent: "phaser-example",
    width: 800,
    height: 600,
    plugins: {
        scene: [
            {
                key: "i18nPlugin",
                plugin: I18nPlugin,
                mapping: "i18n"
            }
        ]
    },
    scene: {
        create: create
    }
};

Initialize the plugin

After plugin has been loaded you need to initialize it.

create () {
  this.i18n.initialize(
    {
      fallbackLng: 'en',
      loadPath: 'assets/i18n/{{lng}}/{{ns}}.json',
      debug: false,
    },
    function () {
      console.log('I18nPlugin initialized!')
    },
  )
}

The plugin will patch add.text, add.bitmapText and add.dynamicBitmapText / make.text, make.bitmapText and make.dynamicBitmapText methods with additional functionality.

Create localized texts

// x - any
// y - any
// font - bitmap font
// text - should be translation key
// size - font size
// interpolations - interpolation for translation (for example { 0: "value0", 1: "value1" }), note this is not required parameter
this.add.bitmapText(x, y, font, text, size, interpolations);
or via config
var config = {
    x: 100,
    y: 100,
    text: "translationKey",
    font: "atari-classic",
    size: 64,
    interpolations: { 0: "value0", 1: "value1" }
};
this.make.dynamicBitmapText(config);

Manage translations

When you're all done and set up for translations and have your key value file, next up is starting to translate them. For smaller games this is fairly simple and still manageable by editing your translations in a text file. But when you start with bigger games and more translations (and translation namespaces) you want to manage your translations better, and maybe even use external translator services.

Two of those service you could use are locize and/or Poeditor. Both these services allow you to online edit key value JSON translations that are used in i18next. The advantage of using such tools is that it's easier to allow external people work on your translations and they aggregate the statistics of your projects (translation completion, languages managed, etc.)

Credits

Big thanks to this great repo:

https://github.com/orange-games/phaser-i18next

License

MIT