Internationalization (i18n)
Multi-language support for your addons.
Quick Start
-- Register language
cLib.Lang.Register("es", "Español", {
["welcome"] = "¡Bienvenido!",
["goodbye"] = "¡Adiós!"
})
-- Add to existing language
cLib.Lang.AddPhrases("en", {
["welcome"] = "Welcome!",
["goodbye"] = "Goodbye!"
})
-- Get translation
local text = cLib.L("welcome") -- Returns "Welcome!" or "¡Bienvenido!"Built-in Languages
cLib includes these languages with common phrases:
- English (en)
- Spanish (es)
- French (fr)
- German (de)
Built-in Phrases
cLib.L("common.yes") -- "Yes"
cLib.L("common.no") -- "No"
cLib.L("common.ok") -- "OK"
cLib.L("common.cancel") -- "Cancel"
cLib.L("common.save") -- "Save"
cLib.L("common.close") -- "Close"
cLib.L("common.confirm") -- "Confirm"
cLib.L("common.delete") -- "Delete"
cLib.L("common.edit") -- "Edit"
cLib.L("common.add") -- "Add"
cLib.L("common.remove") -- "Remove"
cLib.L("common.search") -- "Search"
cLib.L("common.loading") -- "Loading..."
cLib.L("common.error") -- "Error"
cLib.L("common.success") -- "Success"
cLib.L("common.warning") -- "Warning"Language Selection
-- Set language
cLib.Lang.SetLanguage("es")
-- Get current language
local lang = cLib.Lang.GetLanguage() -- "es"
-- Auto-detect from GMod settings
cLib.Lang.AutoDetect()
-- Get available languages
local langs = cLib.Lang.GetAvailable()
-- {{code = "en", name = "English"}, {code = "es", name = "Español"}, ...}