Method: Apstrings::Validator.validate_special_characters

Defined in:
lib/apstrings/strings_validator.rb

.validate_special_characters(sf) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/apstrings/strings_validator.rb', line 148

def self.validate_special_characters(sf)
	# puts "apstrings: checking syntax for #{file}..."
	variables_regex = /%[hlqLztj]?[@%dDuUxXoOfeEgGcCsSpaAF]/
	mismatchs = []
	sf.key_values.each {
		|e|  e.each_pair {
			|key,value|	
			fixed_key = Validator::value_in_master(key)	
			if fixed_key != nil
				striped_key =  fixed_key.gsub(/%\d\$/,'%') # Strip numbered format placeholders , e.g. %1$@ --> %@ 
				striped_value = value.gsub(/%\d\$/,'%')   
				key_variables = striped_key.scan(variables_regex) 
				value_variables = striped_value.scan(variables_regex) 
				if !(key_variables.sort == value_variables.sort)
					mismatchs << {key => value}   
				end
			else
				# key in slavor file but does not exist in master file .
				Log.warn("There is missing key in master file comparing to slavor. As we only check  missing  keys in slavor file, just ignore. \n ");
			end
		}
	}
	mismatchs
end