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

superpowers-game-flang-plugin

v0.4.0

Published

Easy localization for the Superpowers Game system for Superpowers, the extensible HTML5 2D+3D game engine.

Downloads

2

Readme

Superpowers Game fLang plugin

Ths plugin allows for easy localization of any in-game strings in the Superpowers Game system for Superpowers, the extensible HTML5 2D+3D game engine.

It expose the fLang namespace to the TypeScript API.

Documentation

http://florentpoujol.github.io/superpowers-game-flang-plugin

You can also access it offline in Superpowers' client with the Plugins documentation plugin, or find it directly in the plugin's public/docs folder.

Installation

Download the latest release, unzip it, rename the folder to flang, move it inside app/systems/supGame/plugins/florentpoujol/ then restart your server.

Advanced:

Get it via npm:

cd app/systems/supGame/plugins
npm install superpowers-game-flang-plugin

The name of the vendors or plugins in the app/systems/supGame/plugins/ folder don't matter.
So you can leave the plugin path as node_modules/superpowers-game-flang-plugin.

Quick reference

Set the dictionaries with the setDictionary(language: string, dictionary: Object|string) function :

let en: any = {
  localeName: "English",

  greetings: { // you may nest the keys
    welcome: "Welcome {{player_name}}!"
  }
};
fLang.setDictionary("en", en);

fLang.setDictionary("fr", {
  greetings: {
    welcome: "Bienvenu {{player_name}} !"
  }
});

Retrieve a localized string in the current locale:

var text = fLang.get( "localName" ); // returns "English"

Chain keys with a dot notation :

var text = fLang.get( "greetings.welcome" ); // Welcome {{player_name}}!

Specify a locale at the begining of the key to override the current locale:

var text = fLang.get( "fr.greetings.welcome" ); // Bienvenu {{player_name}}!

Keys not found in a locale may still return a value if they exists in the default locale :

var text = fLang.get( "fr.localName" ); // English

Pass a dictionary of placeholders/replacements as second argument to personalize elements in the localized strings:

var text = fLang.get( "greetings.welcome", { player_name: "Florent" } );
// Welcome Florent!

Update the current locale with the update() function.

var text = fLang.get( "greetings.welcome" ); // Welcome {{player_name}}!

fLang.udpate("fr");

var text = fLang.get( "greetings.welcome" ); // Bienvenu {{player_name}} !

The update() function makes the module's event emitter (fLang.emitter) emit the "fLangUpdate" event.

fLang.emitter.on("fLangUpdate", (locale: string) => {
  console.log("The new current locale is "+locale);
});

fLang.udpate( "fr" ); // prints "The new current locale is fr"

The listeners receive the new current locale as their first and only arguments.
You can use this to automaticaly update texts when the user changes the locale.

Test project

The project folder contains a test project.

To run it, put the project folder fLang in Superpowers' projects folder, start the server, access the project then run it and open the console.

On Window, Superpowers' projects folder is typically in C:\Users\[Your user name]\AppData\Roaming\Superpowers.

Note that this project depends on the fText asset plugin, as well as this plugin (obviously).