GithubHelp home page GithubHelp logo

bdr76 / multilanguage Goto Github PK

View Code? Open in Web Editor NEW
35.0 3.0 12.0 20 KB

JavaScript multi-language localisation using a json file to add UI translation to websites or games

JavaScript 100.00%
languages localisation localization multilanguage translation translation-management translations

multilanguage's Introduction

MultiLang.js

MultiLang.js is a JavaScript object to handle multilanguage, localisation, JSON file loading, detect default language, detect non-existing phrases etc.

It contains a working example page and a JSON example file with multiple languages. Initially created for Phaser.js games, but it can be applied to any JavaScript project or website.

How to use

Store two or more translations in a JSON file, for example languages.json like this:

{
    "en": {
        "Hello": "Hello World!",
        "SaveChanges": "Do you want to save the changes?",
        "Yes": "Yes",
        "No": "No"
    },
    "fr": {
        "Hello": "Bonjour à tous!",
        "SaveChanges": "Voulez-vous sauvegarder les modifications?",
        "Yes": "Oui",
        "No": "Non"
    },
    "zh": {
        "Hello": "大家好",
        "SaveChanges": "是否要保存更改?",
        "Yes": "要",
        "No": "不要"
    }
}

And then MultiLang.js can be used like this:

var multilang = new MultiLang('languages.json');
multilang.setLanguage('fr');
alert( multilang.get('Hello') );

Manage translations

Keeping track of all the translated strings can be a challenge, even for smaller projects. See this Excel spreadsheet to manage translations more easily. The translator(s) can fill the spreadsheet with translated texts and the JSON file can then be generated using a Excel VBA or LibreOffice macro. For more information see here.

Also see the Manage translations github page

spreadsheet --> macro --> JSON
                          XML strings
                          String.localization
                          resx

History

2016-oct-28 upload project on github

Send any questions or comments to Bas de Reuver - [email protected]

multilanguage's People

Contributors

bdr76 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

multilanguage's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.