Module ArkanisDevelopment::SimpleLocalization::LocalizedDateAndTime
In: lib/features/localized_date_and_time.rb

Methods

Public Class methods

Just a little helper to handle the language file data more easily. Converts arrays into hashes with the array values as keys and their indexes as values. Takes and optional start index which defaults to 0.

  convert_to_name_indexed_hash ['Son', 'Mon', 'Din', 'Mit', 'Don', 'Fri', 'Sam'], 1
  # => {"Son" => 1, "Mon" => 2, "Din" => 3, "Mit" => 4, "Don" => 5, "Fri" => 6, "Sam" => 7}

[Source]

    # File lib/features/localized_date_and_time.rb, line 51
51:     def self.convert_to_name_indexed_hash(array, start_index = 0)
52:       array.inject({}) do |memo, element|
53:         memo[element] = array.index(element) + start_index
54:         memo
55:       end
56:     end

Relace format sequences in a specified strftime format string with localized formats from the language file.

[Source]

    # File lib/features/localized_date_and_time.rb, line 60
60:     def self.overwrite_formats(original_format)
61:       localized_format = ' ' + original_format
62:       (Language.entry(:dates, :strftime_overwrites) || {}).each do |original, replacement|
63:         localized_format.gsub!(/([^%])%#{original}/) {$1 + replacement}
64:       end
65:       localized_format[1, localized_format.length]
66:     end

[Validate]