HTML5 game publishing

Localize Your Game Menu With PlayKovo SDK getLanguage

The documented supported-list-plus-fallback pattern, handling regional codes, a manual language switch, text length, fonts and plurals.

PlayKovo Team3 min read
Games currently available on PlayKovo. Open a title to see its current listing.

If your game has text in it, players who read another language will notice. The PlayKovo SDK gives you one small helper for this: getLanguage(), which returns the browser language. This post shows the pattern from the SDK documentation, explains what to do with a language you have not translated and lists the details that make a menu feel finished: fallbacks, plurals, text length and saved choice.

What getLanguage returns

According to the SDK reference, getLanguage returns the browser language. It does not guess the player's country and it does not know which languages your game supports. That part is up to you. A browser can report values such as en, tr or a regional form such as en-US, so do not compare the whole string without looking at what you get.

The documented pattern

const supported = ["en", "tr", "es", "de"];
const detected = window.PlayKovoSDK.getLanguage();
const language = supported.includes(detected) ? detected : "en";
renderMenu(translations[language]);

Two ideas are in these four lines. First, list your supported languages explicitly. Second, fall back to a default, here English, when the detected language is not on the list. A game with a missing translation should show readable text, not empty buttons or the word undefined.

Handling regional variants

If the call returns a value like pt-BR and you support only pt, the exact comparison fails. A small helper solves it:

function pickLanguage(detected, supported, fallback = "en") {
  const code = String(detected || "").toLowerCase();
  if (supported.includes(code)) return code;
  const base = code.split("-")[0];
  return supported.includes(base) ? base : fallback;
}

Test it with an empty value too. If the call fails or returns nothing, the helper still gives you the fallback.

Let the player override

The browser language is a guess. A player may use a computer in one language and want to play in another. Add a language option in your settings, and save the choice with the SDK's storage; see cloud save with a local fallback. On the next visit, a saved choice wins over the detected language.

What breaks when you translate

ProblemWhy it happensFix
Text overflows buttonsGerman and Turkish words can be longer than English onesDesign buttons that grow, or test with the longest language
Squares or missing lettersThe font has no glyphs for accented or non-Latin lettersChoose a font with full coverage, and check each language
Wrong plurals"1 coins", "2 coin"Use a function per language instead of adding an s
Text baked into imagesIt cannot change with the languageKeep text out of images, or make one image per language
Mixed languages on one screenA string was missedKeep all strings in one table and log keys that have no translation

Fonts and licences

If you add fonts for extra languages, remember that they are assets in your ZIP and need the right to be used. See clearing art, audio and fonts. Font files also add to your download size; our post on what goes in a ZIP covers the limits.

Translate the store text too

The language inside your game is one part. The title, description, instructions and controls that appear on the game's page are another. Write those clearly in English first, since that is how the site presents games; translate in-game text for the languages you can maintain well. A badly machine-translated menu is worse than a clear English one.

A short checklist

  1. List the languages you support and a fallback.
  2. Handle regional codes and empty values.
  3. Give the player a manual language switch and remember it.
  4. Test the longest language on the smallest screen.
  5. Check fonts for every language.
  6. Keep all text in one place.

The helper is described in the JavaScript SDK reference. If your game runs without the SDK, you can still use the browser's own language value, but then you lose the consistent behaviour inside PlayKovo.

We use optional cookies for site analytics and site advertising. You can change your choice later. Privacy policy.