From 380aa6fdcbc2aecab5e010557b4f899ae4d4d932 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 17 Sep 2011 16:53:23 +0200 Subject: [PATCH] Only verify entries not marked with fuzzy --- src/scripts/verify_format_srings_in_translations.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/scripts/verify_format_srings_in_translations.rb b/src/scripts/verify_format_srings_in_translations.rb index 1f9c40b59..fbff05758 100755 --- a/src/scripts/verify_format_srings_in_translations.rb +++ b/src/scripts/verify_format_srings_in_translations.rb @@ -4,12 +4,14 @@ require 'pp' def read_entries file_name entries = Array.new + flags = {} IO.readlines(file_name).each_with_index do |line, line_number| line.gsub! /[\r\n]/, '' if /^msgid/.match line - entries << { :id => line, :line_number => line_number + 1 } + entries << { :id => line, :line_number => line_number + 1, :flags => flags } + flags = {} elsif /^msgstr/.match line entries[-1][:str] = line @@ -18,6 +20,9 @@ def read_entries file_name entry = entries[-1] idx = entry[:str] ? :str : :id entry[idx] = entry[idx][0 .. entry[idx].length - 2] + line[1 .. line.length - 1] + + elsif /^#,/.match line + flags = Hash[ *line.gsub(/^#,\s*/, '').split(/,\s*/).map { |flag| [ flag.to_sym, true ] }.flatten ] end end @@ -32,7 +37,7 @@ def process_file file_name | [0-9]+%? )/ix - errors = read_entries(file_name).select { |entry| !entry[:id].nil? && (entry[:id] != 'msgid ""') && !entry[:str].nil? && (entry[:str] != 'msgstr ""') }.collect do |entry| + errors = read_entries(file_name).select { |entry| !entry[:flags][:fuzzy] && !entry[:id].nil? && (entry[:id] != 'msgid ""') && !entry[:str].nil? && (entry[:str] != 'msgstr ""') }.collect do |entry| formats = Hash[ *[:id, :str].collect { |idx| [idx, entry[idx].scan(matcher).uniq.sort ] }.flatten(1) ] missing = formats[:id] - formats[:str]