lib/xcres/analyzer/strings_analyzer.rb
# Read a file and collect all its keys
#
# @param  [Pathname] path
#         the path to the .strings file to read
#
# @return [Hash{String => Hash}]
#
Read a file and collect all its keys
Read a file and collect all its keys
def keys_by_file(path)
      begin
        strings = read_strings_file(path)
        strings.reject! { |key, _| /^[a-zA-Z0-9]{3}-[a-zA-Z0-9]{2,3}-[a-zA-Z0-9]{3}/.match(key) }
        keys = Hash[strings.map do |key, value|
          [key, { value: key, comment: value.gsub(/[\r\n]/, ' ') }]
        end]
        log 'Found %s keys in file %s', keys.count, path
        keys
      rescue ArgumentError => error
        raise ArgumentError, 'Error while reading %s: %s' % [path, error]
      end
    end
def keys_by_file ( path ) begin strings = read_strings_file ( path ) strings . reject! { | key , _ | / ^[a-zA-Z0-9]{3}-[a-zA-Z0-9]{2,3}-[a-zA-Z0-9]{3} / . match ( key ) } keys = Hash [ strings . map do | key , value | [ key , { value : key , comment : value . gsub ( / [ \r \n ] / , ' ' ) } ] end ] log 'Found %s keys in file %s' , keys . count , path keys rescue ArgumentError => error raise ArgumentError , 'Error while reading %s: %s' % [ path , error ] end end
Read a file and collect all its keys
Read a file and collect all its keys
# Load strings file contents # Reject generated identifiers used by Interface Builder
None
Hash{String => Hash}
path
path the path to the .strings file to read
path the path to the . strings file to read