Module GLoc::InstanceMethods
In: lib/gloc.rb

This module will be included in both instances and classes of GLoc includees. It is also included as class methods in the GLoc module itself.

Methods

l   l_has_string?   ll   ltry   lwr   lwr_   set_language   set_language_if_valid  

Included Modules

Helpers

Public Instance methods

Returns a localized string.

[Source]

    # File lib/gloc.rb, line 18
18:     def l(symbol, *arguments)
19:       return GLoc._l(symbol,current_language,*arguments)
20:     end

Returns true if a localized string with the specified key exists.

[Source]

    # File lib/gloc.rb, line 48
48:     def l_has_string?(symbol)
49:       return GLoc._l_has_string?(symbol,current_language)
50:     end

Returns a localized string in a specified language. This does not effect current_language.

[Source]

    # File lib/gloc.rb, line 24
24:     def ll(lang, symbol, *arguments)
25:       return GLoc._l(symbol,lang.to_sym,*arguments)
26:     end

Returns a localized string if the argument is a Symbol, else just returns the argument.

[Source]

    # File lib/gloc.rb, line 29
29:     def ltry(possible_key)
30:       possible_key.is_a?(Symbol) ? l(possible_key) : possible_key
31:     end

Uses the default GLoc rule to return a localized string. See lwr_() for more info.

[Source]

    # File lib/gloc.rb, line 35
35:     def lwr(symbol, *arguments)
36:       lwr_(:default, symbol, *arguments)
37:     end

Uses a rule to return a localized string. A rule is a function that uses specified arguments to return a localization key prefix. The prefix is appended to the localization key originally specified, to create a new key which is then used to lookup a localized string.

[Source]

    # File lib/gloc.rb, line 43
43:     def lwr_(rule, symbol, *arguments)
44:       GLoc._l("#{symbol}#{GLoc::_l_rule(rule,current_language).call(*arguments)}",current_language,*arguments)
45:     end

Sets the current language for this instance/class. Setting the language of a class effects all instances unless the instance has its own language defined.

[Source]

    # File lib/gloc.rb, line 54
54:     def set_language(language)
55:       @gloc_language= language.nil? ? nil : language.to_sym
56:     end

Sets the current language if the language passed is a valid language. If the language was valid, this method returns true else it will return false. Note that nil is not a valid language. See set_language(language) for more info.

[Source]

    # File lib/gloc.rb, line 62
62:     def set_language_if_valid(language)
63:       if GLoc.valid_language?(language)
64:         set_language(language)
65:         true
66:       else
67:         false
68:       end
69:     end

[Validate]