Class Language
In: app/models/language.rb
Parent: ActiveRecord::Base

Methods

Public Class methods

[Source]

    # File app/models/language.rb, line 22
22:   def self.convert_to_iso_639_code(two_letter_code)
23:     case two_letter_code
24:     when 'en', '', ' '
25:       return 'eng'
26:     when 'ja', 'jp'
27:       return 'jpn'
28:     when 'de', 'ge'
29:       return 'ger'
30:     when 'fr'
31:       return 'fre'
32:     when 'zh'
33:       return 'chi'
34:     when 'es'
35:       return 'spa'
36:     when 'he'
37:       return 'heb'
38:     when 'it'
39:       return 'ita'
40:     when 'ko'
41:       return 'kor'
42:     when 'pt'
43:       return 'por'
44:     when 'ru'
45:       return 'rus'
46:     when 'vn', 'vi'
47:       return 'vie'
48:     else
49:       return 'eng'
50:     end
51:   end

[Source]

    # File app/models/language.rb, line 84
84:   def self.get_by_iso_639_code(iso_639_code)
85:     existing_language                = Language.find_by_iso_639_code(iso_639_code)
86:     unless existing_language
87:       existing_language              = Language.new
88:       existing_language.language     = iso_639_code
89:       existing_language.iso_639_code = iso_639_code
90:       existing_language.save!
91:     end
92:     return existing_language
93:   end

[Source]

    # File app/models/language.rb, line 80
80:   def self.get_english
81:     return Language.get_by_iso_639_code('eng')
82:   end

[Source]

    # File app/models/language.rb, line 76
76:   def self.get_german
77:     return Language.get_by_iso_639_code('ger')
78:   end

[Source]

    # File app/models/language.rb, line 72
72:   def self.get_japanese
73:     return Language.get_by_iso_639_code('jpn')
74:   end

[Source]

    # File app/models/language.rb, line 53
53:   def self.get_language(iso_code)
54:     language = self.find_by_iso_639_code(iso_code)
55:     unless language
56:       language = self.find_by_iso_639_code(self.convert_to_iso_639_code(iso_code))
57:     end
58:     return language
59:   end

[Source]

    # File app/models/language.rb, line 65
65:   def self.translated
66:     supported_languages = Array.new
67:     supported_languages << self.get_japanese
68:     supported_languages << self.get_english
69:     return supported_languages    
70:   end

Public Instance methods

[Source]

    # File app/models/language.rb, line 61
61:   def to_label
62:     language.capitalize
63:   end

Protected Instance methods

[Source]

    # File app/models/language.rb, line 97
97:   def authorized_for_create?
98:     return Authorize.is_role_allowed_for_user?(current_user, UserRole::USER_ROLE_ROOT)
99:   end

[Source]

     # File app/models/language.rb, line 105
105:   def authorized_for_destroy?
106:     return Authorize.is_role_allowed_for_user?(current_user, UserRole::USER_ROLE_ROOT)
107:   end

[Source]

     # File app/models/language.rb, line 109
109:   def authorized_for_read?
110:     return Authorize.is_role_allowed_for_user?(current_user, UserRole::USER_ROLE_USER)
111:   end

[Source]

     # File app/models/language.rb, line 101
101:   def authorized_for_update?
102:     return Authorize.is_role_allowed_for_user?(current_user, UserRole::USER_ROLE_ROOT)
103:   end

[Validate]