Page 1 of 1

i18n support for Mudlet scripts

Posted: Fri Oct 04, 2019 2:05 am
by demonnic
I have been working on a website in lua, and needed an internationalization library. I found and decided others might find it useful, so I repackaged it in a mudlet mpackage. All credit goes to the original author. The full details are available on the github page but a basic rundown:

If you install this package, then given:
Code: [show] | [select all] lua
local translations = {
  en = {
    test = "This is a test",
    emergency = "emergency",
  de = {
    test = "Das ist ein Test",
    emergency = "Notfall",

Then you can run
Code: [show] | [select all] lua
cecho(string.format("<blue>(<red>%s<blue>)<reset> %s\n", i18n('emergency'), i18n('test')))
And it will look like this:
Screenshot from 2019-10-03 21-56-13.png
Screenshot from 2019-10-03 21-56-13.png (5.94 KiB) Viewed 4256 times
If you do i18n.setLocale("de") and do it again, it will look like:
Screenshot from 2019-10-03 22-01-29.png
Screenshot from 2019-10-03 22-01-29.png (5.79 KiB) Viewed 4256 times