add_po.rb: fix support for Qt translation files that aren't named *base*

This commit is contained in:
Moritz Bunkus 2015-11-25 21:14:59 +01:00
parent 734faa1921
commit 11ae3660a2

View File

@ -72,6 +72,7 @@ module AddPo
readlines(file_name).
map(&:chomp)
base = nil
language = content.
map { |line| /<TS [^>]* language="([a-z_@]+)"/ix.match(line) ? $1 : nil }.
compact.
@ -79,15 +80,16 @@ module AddPo
if !language
language = ENV['TS'] if ENV['TS'] && !ENV['TS'].empty?
language = $1 if !language && /qtbase_([a-zA-Z_@]+)/.match(file_name)
base, language = $1, $2 if !language && /qt(base)?_([a-zA-Z_@]+)/.match(file_name)
end
fail "Unknown language for Qt TS file #{file_name} (set TS)" if !language
target = "#{$po_dir}/qt/qtbase_#{language}.ts"
base ||= ''
target = "#{$po_dir}/qt/qt#{base}_#{language}.ts"
if !FileTest.exists?(target) && /^([a-z]+)_[a-z]+/i.match(language)
target = "#{$po_dir}/qt/qtbase_#{$1}.ts"
target = "#{$po_dir}/qt/qt#{base}_#{$1}.ts"
end
fail "target file does not exist yet: #{target} (wrong language?)" if !FileTest.exists?(target)