From: Daniel Kolesa Date: Mon, 28 Apr 2014 13:41:58 +0000 (+0100) Subject: elua: support for default domain in gettext module X-Git-Tag: upstream/1.10.0+1149+ga3a15b1~644^2~150 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8056a854285afe1f52ec2ab000046586d28f5ac7;p=platform%2Fupstream%2Fefl.git elua: support for default domain in gettext module --- diff --git a/src/bin/elua/core/gettext.lua b/src/bin/elua/core/gettext.lua index 6192613..065cefd 100644 --- a/src/bin/elua/core/gettext.lua +++ b/src/bin/elua/core/gettext.lua @@ -15,6 +15,8 @@ end local domains = {} +local default_domain + M.register_domain = function(dom, dir) local d, err = bind_textdomain(dom, dir) if not d then @@ -28,10 +30,20 @@ M.get_domain = function(dom) return domains[dom] end +M.set_default_domain = function(dom) + if not domains[dom] then return false end + default_domain = dom + return true +end + local cast, ffistr = ffi.cast, ffi.string if dgettext then M.gettext = function(dom, msgid) + if not msgid then + msgid = dom + dom = default_domain + end if not domains[dom] or not msgid then return msgid end local cmsgid = cast("const char*", msgid) local lmsgid = dgettext(dom, cmsgid)