Jump to content

Bi18n


Bimbol
 Share

Recommended Posts

   Introduction

Bi18n - internationalization module for Gothic 2 Online.

Project links:
- Repository

Usage example

local messages = {
    en = {
        message = {
            hello = "Hello %s! Today is %d."
        }
    },
    pl = {
        message = {
            hello = "Witaj %s! Dzi jest %d."
        }
    }
}

local i18n = Bi18n("en", messages)
Bi18n_setupGlobal(i18n)

// Event triggered when locale are changed
addEventHandler("Bi18n:onLocaleChanged", function (locale) {
    print("Locale changed to: " + locale)

    if (locale == "en") {
        setKeyLayout(0)
    } else if (locale == "pl") {
        setKeyLayout(1)
    }
})

local t = _t("message.hello", "Bimbol", 25)

print(t)
// Hello Bimbol! Today is 25.
print(_t("message.hello", "Bimbol", 25))
// Hello Bimbol! Today is 25.
print(_f("Custom formatter %s Yey!", t))  // Support for i18n-string
// Custom formatter Hello Bimbol! Today is 25. Yey!

i18n.setLocale("pl")

print(t)
// Witaj Bimbol! Dzi jest 25.
print(_t("message.hello", "Bimbol", 25))
// Witaj Bimbol! Dzi jest 25.
print(_f("Custom formatter %s Yey!", t))  // Support for i18n-string
// Custom formatter Witaj Bimbol! Dzi jest 25. Yey!

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...