Module: ADIWG::Mdtranslator::Readers::MdJson::Locale

Defined in:
lib/adiwg/mdtranslator/readers/mdJson/modules/module_locale.rb

Class Method Summary collapse

Class Method Details

.unpack(hLocale, responseObj, inContext = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_locale.rb', line 16

def self.unpack(hLocale, responseObj, inContext = nil)

   @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson

   # return nil object if input is empty
   if hLocale.empty?
      @MessagePath.issueWarning(510, responseObj, inContext)
      return nil
   end

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intLocale = intMetadataClass.newLocale

   # locale - language (required)
   # return nil if no language code is provided
   if hLocale.has_key?('language')
      intLocale[:languageCode] = hLocale['language']
   end
   if intLocale[:languageCode].nil? || intLocale[:languageCode] == ''
      @MessagePath.issueError(511, responseObj, inContext)
   end

   # locale - country
   if hLocale.has_key?('country')
      unless hLocale['country'] == ''
         intLocale[:countryCode] = hLocale['country']
      end
   end

   # locale - character set (required)
   # return nil if no character set code is provided
   if hLocale.has_key?('characterSet')
      intLocale[:characterEncoding] = hLocale['characterSet']
   end
   if intLocale[:characterEncoding].nil? || intLocale[:characterEncoding] == ''
      @MessagePath.issueError(512, responseObj, inContext)
   end

   return intLocale

end