Module: CustomersHelper

Defined in:
app/helpers/customers_helper.rb

Overview

The CustomersHelper module.

Class Method Summary (collapse)

Class Method Details

+ (Object) is_valid_language(language_code)

Check if the given language code is valid.

Parameters:

  • language_code (String)

    The language code to check.

Returns:

  • True or false.



10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/customers_helper.rb', line 10

def self.is_valid_language(language_code)
  if language_code.nil?
    return false
  end

  if supported_cms_languages.include?(language_code)
    return true
  end

  return false
end

+ (Object) name_from_language_code(language_code)

Get the name of the language via the given language code.

Parameters:

  • language_code (String)

    The language code.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/customers_helper.rb', line 39

def self.name_from_language_code(language_code)
  if language_code.nil?
    return ''
  end

  supported_cms_languages_with_names.each do |lang_array|
    if lang_array[1].eql? language_code
      return lang_array[0]
    end
  end

  unless name.nil?
    return name
  end

  return language_code
end

+ (Object) supported_cms_languages

Get all supported interface languages for the CMS.



24
25
26
27
# File 'app/helpers/customers_helper.rb', line 24

def self.supported_cms_languages
  # available languages
  %w(en de)
end

+ (Object) supported_cms_languages_with_names

Get all supported interface languages for the CMS including their names.



31
32
33
# File 'app/helpers/customers_helper.rb', line 31

def self.supported_cms_languages_with_names
  [%w(Deutsch de), %w(English en)]
end