From da26ea7cf8f15b5959fe27739f2687e0a738b693 Mon Sep 17 00:00:00 2001 From: BrunoMine Date: Sun, 16 Jul 2017 12:37:31 -0300 Subject: [PATCH] Add priority language for load_catalogs method --- gettext.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gettext.lua b/gettext.lua index 26a2d73..5f3c79f 100644 --- a/gettext.lua +++ b/gettext.lua @@ -209,9 +209,19 @@ local function load_catalog(filename) return data end -function M.load_catalogs(path) - local langs = intllib.get_detected_languages() - +function M.load_catalogs(path, first_lang) + + -- add selected first lang + if first_lang then + langs = {} + table.insert(langs, first_lang) + for _, lang in ipairs(intllib.get_detected_languages()) do + langs[#langs+1] = lang + end + else + langs = intllib.get_detected_languages() + end + local cats = { } for _, lang in ipairs(langs) do local cat = load_catalog(path.."/"..lang..".po")