Home

Awesome

gms2-mofile

MoFile loader for Gamemaker Studio 2.3+

Table of Contents

  1. Requirements
  2. Download
  3. Maintainers & Contribution
  4. Samples
  5. Setup
  6. Configuration
  7. Pulling Translation Strings From Code
  8. API

Requirements

Release VersionGamemaker Version
1.0.xv2.3.0.x+
1.1.xv2022.09.x.y+

Download

  1. Download the exported local package
  2. Select Tools > Import Local Package
  3. Navigate to the saved package and select import
  4. Import all resources

Maintainers & Contribution

This package is maintained by Paige Marincak. To contribute, please fork the repo and make pull requests.

Samples

Samples can be viewed here.

Setup

PoEdit Files

  1. Create a folder in your datafiles called TranslationFiles.
  2. Copy the sample.po and sample.mo files from the sample to the new folder.

GML

  1. Add MofileGameStart() to the GameStart of an object that is created at the start of the game.
  2. Add MofileGameEnd() to the GameEnd of an object that is destroyed at the end of the game.
  3. Load your mofile at any point after MofileGameStart using MofileLoadLanguageFile("sample.mo")

Configuration

GML

Variable NameDefault ValueDescription
MOFILE_INCLUDED_FILES_SUBDIRECTORY"TranslationFiles"Path to datafiles subdirectory where the mofiles are stored at runtime.
MOFILE_USE_WORKING_DIRECTORYtrueWhether to preface MOFILE_INCLUDED_FILES_SUBDIRECTORY with the working_directory or not.

Translation Functions

If you would like to rename _ or _MofileMarkTranslation:

  1. Rename the functions as preferred in the code. Example: TL and TL_Marker.
  2. Open your Po File. (i.e. sample.po) Recommend using PoEdit.
  3. Translation > Properties > Sources keywords
  4. Change "_" to "TL" and "_MofileMarkTranslation" to "TL_Marker"
  5. Press Ok.

PoEdit

If you would like to use PoEdit to pull translation strings from your code, you will need to create a custom extractor as follows:

  1. Open PoEdit.
  2. File > Preferences > Extractors
  3. Click the + at the bottom.
  4. Create the Extractor with the following configuration and click OK:
NameValue
LanguageGML
Extensions*.gml
Extraction Commandxgettext --language=C --add-comments=TRANSLATORS: --force-po -o %o %C %K %F
Keywords List-k%k
Input File List%f
Charset--from-code=%c

Pulling Translation Strings From Code

  1. Open your Po File. (i.e. sample.po) Recommend using PoEdit.
  2. Press Update From Code
  3. New strings added and removed will be visible
  4. Save to generate a new MoFile.

API

MofileGameStart

Sets up the linkage between GML and the MoFile DLL. Should be called once at GameStart.

MofileGameEnd

Frees the MoFile DLL. Should be called once at GameEnd.

_

Marks the provided value as a translatable string and returns the translation from the loaded MoFile. Feel free to rename this function to whatever shorthand makes the most sense. Be aware that you will need to update PoEdit grep configurations.

@param {String} value

_MofileMarkTranslation

Marks the provided value as a translatable string and returns the original value. Feel free to rename this function to whatever shorthand makes the most sense. Be aware that you will need to update PoEdit grep configurations.

@param {String} value

MofileLoadLanguageFile

Loads the localization file represented by the provided filename and returns whether it was successful or not.

@param {String} filename