Module Mack::ViewHelpers::L10NHelpers
In: lib/localization/helpers/view_helpers/l10n_helpers.rb

Methods

Classes and Modules

Class Mack::ViewHelpers::L10NHelpers::Context

Public Instance methods

[Source]

    # File lib/localization/helpers/view_helpers/l10n_helpers.rb, line 34
34:       def l10n_context(view_sym, lang = session[:lang] || :en)
35:         ctx = Context.new(view_sym, lang)
36:         yield ctx
37:       end

View helper method to format the currency based on the given language code

params:

  amount - the amount of money
  lang   - language code

See:

  Mack::Localization::Formatter.currency_format

Example:

  l10n_currency(10000, :en) produces "$10,000.00"

Returns:

  the multibyte version of the formatted currency

[Source]

     # File lib/localization/helpers/view_helpers/l10n_helpers.rb, line 135
135:       def l10n_currency(amount, lang = session[:lang] || :en)
136:         return l10n_formatter.currency_format(amount, lang)
137:       end

View helper method to format the specified date based on the given language code

params:

  time   - the date to be formatted
  type   - :short, :medium, :long
  lang   - language code

See:

  Mack::Localization::Formatter.date_format

Example:

  aTime = Time.local(2008, "jan", 1)
  l10n_date(aTime, :short, :en) produces "Jan 01, 2008"

Returns:

  the multibyte version of the formatted date

[Source]

    # File lib/localization/helpers/view_helpers/l10n_helpers.rb, line 95
95:       def l10n_date(time, type, lang = session[:lang] || :en)
96:         return l10n_formatter.date_format(time, type, lang)
97:       end

View helper method to get the localized image path in the given view_sym path and language using the specified key.

params:

  key - lookup key
  view_sym - tell the system where to look for the content file
  lang - the language code

See:

  Mack::Localization::Translator.getimg

Returns:

  the multibyte version of the path to the localized image

[Source]

    # File lib/localization/helpers/view_helpers/l10n_helpers.rb, line 73
73:       def l10n_getimg(key, view_sym = controller.controller_name, lang = session[:lang] || :en)
74:         return l10n_translator.getimg(view_sym.to_sym, key, lang)
75:       end

View helper method to get the localized string in the given view_sym path and language using the specified key.

params:

  key - lookup key
  view_sym - tell the system where to look for the content file
  lang - the language code

See:

  Mack::Localization::Translator.getimg

Returns:

  the multibyte version of the localized string

[Source]

    # File lib/localization/helpers/view_helpers/l10n_helpers.rb, line 54
54:       def l10n_gets(key, view_sym = controller.controller_name, lang = session[:lang] || :en)
55:         return l10n_translator.gets(view_sym.to_sym, key, lang)
56:       end

View helper method to format the number based on the given language code

params:

  num  - the number to be formatted
  lang - language code

See:

  Mack::Localization::Formatter.number_format

Example:

  l10n_number(10000, :en) produces "10,000.00"

Returns:

  the multibyte version of the formatted number

[Source]

     # File lib/localization/helpers/view_helpers/l10n_helpers.rb, line 115
115:       def l10n_number(num, lang = session[:lang] || :en)
116:         return l10n_formatter.number_format(num, lang)
117:       end

[Validate]