Rendering Localized Content

Rendering localized sprites and text or listening to language change events for custom rendering or logic is easy in Cultured.

Composite Fonts

Cultured supports Composite Fonts which allow you to easily map multiple Game Maker Font Assets to a different language. When using a Composite font you have an option to allow Cultured to use your games translated text to automatically generate glyph ranges which can help reduce texture pages and allow you to support languages with an unfair amount of glyphs. Add composite fonts to your game in the Cultured Dashboard -> Composite Fonts tab.

The Composite Font tab in the Cultured Dashboard

/// create event
text1 = cultured("hello");
header_font = cultured_get_font("header");

/// draw event
draw_set_font(header_font.font);

draw_text(x, y, text1.str); // prints "hello"
cultured_set_current_language("fr");
draw_text(x, y, text1.str); // prints "bonjour"

Using a composite font allows you to render the correct glyphs without having to do any manual language checking.

Composite Sprites

Cultured supports Composite Sprites which allow you to easily map multiple Game Maker Sprite Assets to a different language.

The Composite Sprites tab in the Cultured Dashboard

/// create 
// look up the cultured sprite by the native sprite asset
banner = cultured_get_sprite(spr_banner_en);

// or look up the cultured sprite by the native sprite assets name
banner = cultured_get_sprite("spr_banner_en");

/// draw
// remember to use the .spr property
cultured_set_current_language("en");
draw_sprite(banner.spr, 0, x, y);

cultured_set_current_language("ko");
draw_sprite(banner.spr, 0, x, y + 300);

Manually Polling The Language

For uses beyond Cultures design or support you can manually poll the language and do anything you'd like with custom logic in your games own gml code.


font = undefined;
switch (cultured_get_current_language())
{
  case "fr":
    font = fnt_french;
    break;
  default:
    font = fnt_english;
    break;
}

draw_set_font(font)
draw_text(x, y, my_string);

Subscribing to language changed events

You are in control of when the language changes, but if you need an event for that Cultured has one.

cultured_on_language_changed(function(_new_lang, _old_lang) {
  do_something(_new_lang);
});