Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 843 Bytes

locale.md

File metadata and controls

44 lines (33 loc) · 843 Bytes

shard.locale

Locale / translation system for Lua or Love2D

local Locale = require("shard.locale")

Locale.useLove2D(value)

If you are using Love2D then default is true otherwise false

Locale.load(filename)

Loads new locale .lua config file

Config file structure

return {
  id = "en",
  strings = {
    sample_text = "Welcome"
  }
}

Locale.setFallbackLocale(id)

Sets locale to use when string cannot be translated in current locale

Locale.setLocale(id)

Sets locale to use

Locale.translate(string) / Locale(string)

Translates string to currently set locale or if cannot be translated then to fallback locale

Locale.constainsLocale(id)

Checks if locale is loaded

Example

local Locale = require("shard/locale")

Locale.load("en.lua")
Locale.setLocale("en")

print(Locale("test"))