Sha256: c28e4699a7ac0412b44411d7513fd12cd7bda75a53f0fa1ed98c344641f4a2e2
Contents?: true
Size: 1007 Bytes
Versions: 8
Compression:
Stored size: 1007 Bytes
Contents
class Knjappserver def trans(obj, key, args = {}) args[:locale] = self.trans_locale if !args[:locale] trans_val = @translations.get(obj, key, args).to_s if trans_val.length <= 0 trans_val = @events.call(:trans_no_str, {:obj => obj, :key => key, :args => args}) end return trans_val end def trans_locale(args = {}) if args.is_a?(Hash) and args[:locale] return args[:locale] elsif _session and _session[:locale] return _session[:locale] elsif _httpsession and _httpsession.data[:locale] return _httpsession.data[:locale] elsif Thread.current[:locale] return Thread.current[:locale] elsif @config[:locale_default] return @config[:locale_default] end raise "Could not figure out locale." end def trans_set(obj, values, args = {}) args[:locale] = self.trans_locale if !args[:locale] @translations.set(obj, values, args) end def trans_del(obj) @translations.delete(obj) end end
Version data entries
8 entries across 8 versions & 1 rubygems