Skip to content

i18n Module

This page explains how to access the current platform-injected language using the Playol SDK, enabling your game to support seamless multi-language experiences worldwide. The goal is to ensure consistency between platform and game languages for a better localized experience for global users.


📌 1. Use Cases

  • Display multi-language UI for global players (e.g., English, Thai, Indonesian, etc.)
  • Keep your game language in sync with the platform language
  • Render localized UI elements such as labels, tooltips, menus, dialogs
  • Allow backend systems to serve localized data based on user language

🌐 2. Get Current Language

Access via: window.playolSDK.i18n.language

The platform automatically injects the current language code at game initialization. The game can read this during the first load.

js
const lang = window.playolSDK.i18n.language
console.log('Current language:', lang) // Example: 'zh', 'en', 'th'

📌 Supported language codes:

CodeLanguage Name
enEnglish
idBahasa Indonesia
msBahasa Melayu
thThai
viVietnamese
zhSimplified Chinese

Supported languages may expand over time based on platform configuration.


🔁 3. Language Switch Behavior

Platform Behavior

  • When users change language on the platform, the game iframe is automatically reloaded
  • This guarantees consistent language updates without requiring manual listeners or hot-reloading
  • Read the language field during game initialization and pass it to your i18n handler
  • Bind localized resources to language maps to ensure correct rendering after reload
  • If platform supports hot language switching in the future, this interface will remain compatible

🔧 4. Example: Initialize Custom i18n Module

js
import i18n from './i18n-lib' // Your game’s custom i18n module

const lang = window.playolSDK.i18n.language || 'en'
i18n.setLanguage(lang)

🗂️ 5. Suggested Language Map Structure

ts
// Example language dictionary
const langMap = {
  en: {
    start: 'Start',
    pause: 'Pause',
    reward: 'Reward Unlocked!',
  },
  zh: {
    start: '开始',
    pause: '暂停',
    reward: '获得奖励!',
  },
  th: { ... },
  id: { ... },
  vi: { ... },
  ms: { ... },
}

❓ 6. FAQ

Q: Do I need to handle language changes dynamically?

A: No. The platform refreshes the iframe upon language change. The game will reload with the updated language context.

Q: Will the SDK always provide the language field?

A: Yes. It is injected during SDK initialization. In rare edge cases, use 'en' as a default fallback.

Q: Can I use custom language codes?

A: Not recommended. Please use the official codes provided by the platform to ensure compatibility.


👉 User ModulePayment ModuleData ModuleGame Module

Released under the MIT License