Giter Club home page Giter Club logo

small_pp_localization_tool's Introduction

Small Pentapop Localization tool

Small Pentapop Localization tool is an export tool originally made for Pentapop, but has been expanded to be usable in other GameMaker projects like The Story Goes On and Wally and the FANTASTIC PREDATORS. While made for GameMaker, the files are easy to parse and can be used in any language.

The actual localization is not done inside the tool, but instead is handled inside a Google Sheet (or anything that can export a csv). This means you can have custom formatting rules, comments and multiple collaborators in the same place.
The tool relies on creating custom buffer formats thats made to be fast to load on phones, and seperates the languages into their own files so nothing unnecessary is loaded.

Getting started

To use the tool, first make a copy of this Google Sheet document:
Reference Google Sheet.
You then need to publish the document as a csv file to the web. You can do this by going to: File > Publish to the web > Link. And then selecting .csv in the drop down and then hitting publish. Make a copy of the result url.

The tool is run in the command line and needs two parameters, and can take an optional third one.
Usage: ./small_pp_localization_tool.exe -url <url> -target <target_directory> [-type <export_file_type>]
Replace <url> with your url you copied, and replace <target> with the folder where you want your language files to end up.
Optionally you can also specify the export file type, the available options are:

  • buffer - Custom binary buffer layout. The scripts I made are assuming this is what you're using.
  • base64 - Same buffer layout but in base64. Necessary for using the HTML5 export in GameMaker.
  • json - JSON format. The easiest to use if you're rolling your own scripts.

That's it! I recommend making a .bat file with the command so you in the future can export your languages with the press of a button.

Using the files in GameMaker

First make sure to grab this script file and add it to your project: file
This file contains all the functions you'll need. It has been typed using GMEdit types, giving you really useful static type information. These functions are made to be used together with the buffer type of language files.

Importing

To import a language, use the localization_import(folder, file_name, [default_file_name]) function.
The first argument is what folder to look in for your files.
The second argument is the name of language, for example "en-US" from the template.
The third argument lets you optionally specify a file to use as a default in case a translation is missing for a specific entry. For example you might wish to have English as a fallback language, so you'd put it there.

Using

localize(section, key)
This function will return a string with the entry located in the section given by the first argument, with the key of the second. Even on failure it will return a string with the entry and key it tried to look up.

localize_format(section, key, identifier, replacement)
This function works the same as localize, but will replace a part of the string with the last argument. For example your string might be: "damage: %dmg", you'd want to use localize_format(section, key, "%dmg", global.damage).

localize_format_many(section, key, ...)
Same as above, but has no limit on how many words you can replace

localize_count_in_section(section)
Returns how many entries exist in a section. This can be useful for dynamic content. For example you might show random loading screen messages from a long list. If the messages are in their own section you can return a random entry from it if their key is a number, which lets you have a variable amount of messages in different languages.

Resulting file layout

The resulting files are in a buffer format and can be parsed the following way

section_count = buffer.read_int_32() 
repeat (section_count)
  section_name = buffer.read_string() // uf8
  entry_count = buffer.read_int_32()
  repeat (entry_count)
    key = buffer.read_string() // utf8
    entry = buffer.read_string() // utf8
    // You can consume these values as you wish here

small_pp_localization_tool's People

Contributors

antonbergaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.