Add feature to skip translations that are below a given completeness level.

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=890235
This commit is contained in:
Volker Lanz 2008-11-28 16:28:17 +00:00
parent 0b512b353e
commit c700994216
5 changed files with 186 additions and 34 deletions

View File

@ -50,9 +50,9 @@ public
FileUtils.rm_rf "#{@outputDir}.tar.bz2"
end
def run(protocol, user, createTarball, getTranslations, getDocs, createTag)
def run(protocol, user, createTarball, getTranslations, skipBelow, getDocs, createTag)
checkoutSource
translations = checkoutTranslations if getTranslations
translations = checkoutTranslations(skipBelow) if getTranslations
docs = checkoutDocumentation if getDocs
if createTag
@ -75,7 +75,7 @@ public
system "svn co #{@repository}/#{svnDir} #{@outputDir} >/dev/null 2>&1"
end
def checkoutTranslations
def checkoutTranslations(skipBelow)
Dir.chdir "#{@workingDir}/#{@outputDir}"
FileUtils.rm_rf 'l10n'
@ -95,6 +95,12 @@ public
system "svn co #{@repository}/l10n-kde4/#{lang}/messages/#{@app.component}-#{@app.section} l10n >/dev/null 2>&1"
next unless FileTest.exists? "l10n/#{@app.name}.po"
if skipBelow > 0
fuzzy, untranslated, per = TranslationStatsBuilder.fileStats("l10n/#{@app.name}.po")
puts "Language #{lang} is #{per} % complete."
next if per < skipBelow
end
puts "Adding translations for #{lang}..."
dest = "po/#{lang}"

View File

@ -36,6 +36,7 @@ where options are:
--no-get-docs (-D): do not get documentation
--get-translations (-r): also get translations (default)
--no-get-translations (-R): do not get translations
--skip-incomplete (-k): skip translations below a given percentage of completeness
--create-tag (-e): create a new tag
--no-create-tag (-E): do not create a new tag (default)
--create-tarball (-b): create a tarball (default)
@ -60,6 +61,7 @@ opts = GetoptLong.new(
[ '--no-get-docs', '-D', GetoptLong::NO_ARGUMENT ],
[ '--get-translations', '-r', GetoptLong::NO_ARGUMENT ],
[ '--no-get-translations', '-R', GetoptLong::NO_ARGUMENT ],
[ '--skip-incomplete', '-k', GetoptLong::REQUIRED_ARGUMENT ],
[ '--create-tag', '-e', GetoptLong::NO_ARGUMENT ],
[ '--no-create-tag', '-E', GetoptLong::NO_ARGUMENT ],
[ '--create-tarball', '-b', GetoptLong::NO_ARGUMENT ],
@ -76,6 +78,7 @@ protocol = 'anonsvn'
user = ''
getDocs = true
getTranslations = true
skipBelow = 0
createTag = false
createTarball = true
@ -92,6 +95,7 @@ opts.each do |opt, arg|
when '--no-get-docs' then getDocs = false
when '--get-translations' then getTranslations = true
when '--no-get-translations' then getTranslations = false
when '--skip-incomplete' then skipBelow = arg.to_i
when '--create-tag' then createTag = true
when '--no-create-tag' then createTag = false
when '--create-tarball' then createTarball = true
@ -129,5 +133,5 @@ end
repository = ReleaseBuilder.repository(app.product, protocol, user, checkoutFrom != 'tag' ? checkoutFrom : tag)
releaseBuilder = ReleaseBuilder.new(Dir.getwd, repository, app.product, version)
releaseBuilder.run(protocol, user, createTarball, getTranslations, getDocs, createTag)
releaseBuilder.run(protocol, user, createTarball, getTranslations, skipBelow, getDocs, createTag)

View File

@ -33,7 +33,8 @@ require 'releasebuilder.rb'
class ReleaseDialog < Qt::Dialog
slots 'on_comboAccess_currentIndexChanged(int)',
'on_comboCheckout_currentIndexChanged(int)',
'on_comboName_currentIndexChanged(int)'
'on_comboName_currentIndexChanged(int)',
'on_checkTranslations_toggled(bool)'
def initialize
super
@ -62,9 +63,10 @@ class ReleaseDialog < Qt::Dialog
return if not validate
repository = ReleaseBuilder.repository(@ui.comboName.currentText, @ui.comboAccess.currentText, @ui.editUser.text, @ui.comboCheckout.currentText != 'tag' ? @ui.comboCheckout.currentText : @ui.comboTag.currentText)
skipBelow = @ui.checkSkipTrans.isChecked ? @ui.spinSkipTrans.value : 0
releaseBuilder = ReleaseBuilder.new(Dir.getwd, repository, @ui.comboName.currentText, @ui.editVersion.text)
releaseBuilder.run(@ui.comboAccess.currentText, @ui.editUser.text, @ui.checkTarball.isChecked, @ui.checkTranslations.isChecked, @ui.checkDocs.isChecked, @ui.checkTag.isChecked)
releaseBuilder.run(@ui.comboAccess.currentText, @ui.editUser.text, @ui.checkTarball.isChecked, @ui.checkTranslations.isChecked, skipBelow, @ui.checkDocs.isChecked, @ui.checkTag.isChecked)
super
end
@ -83,6 +85,12 @@ private
updateTags or @ui.comboTag.setEnabled(false) if index == 2
end
def on_checkTranslations_toggled(state)
@ui.checkSkipTrans.setEnabled(state)
@ui.sliderSkipTrans.setEnabled(state && @ui.checkSkipTrans.isChecked)
@ui.spinSkipTrans.setEnabled(state && @ui.checkSkipTrans.isChecked)
end
def updateTags
@ui.comboTag.clear

View File

@ -5,10 +5,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>464</width>
<height>374</height>
<width>500</width>
<height>452</height>
</rect>
</property>
<property name="minimumSize" >
<size>
<width>500</width>
<height>0</height>
</size>
</property>
<property name="windowTitle" >
<string>KDE Release Builder</string>
</property>
@ -211,7 +217,7 @@
<string>Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="1" column="0" >
<item row="0" column="0" >
<widget class="QCheckBox" name="checkDocs" >
<property name="text" >
<string>Get &amp;Documentation</string>
@ -221,17 +227,7 @@
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QCheckBox" name="checkTarball" >
<property name="text" >
<string>Create Tar&amp;ball</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" >
<item row="0" column="1" >
<widget class="QCheckBox" name="checkTranslations" >
<property name="text" >
<string>Get &amp;Translations</string>
@ -241,13 +237,78 @@
</property>
</widget>
</item>
<item row="3" column="0" >
<item row="1" column="1" >
<widget class="QCheckBox" name="checkTarball" >
<property name="text" >
<string>Create Tar&amp;ball</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="checkTag" >
<property name="text" >
<string>C&amp;reate Tag</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QCheckBox" name="checkSkipTrans" >
<property name="text" >
<string>S&amp;kip translations below completion:</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="sliderSkipTrans" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="singleStep" >
<number>5</number>
</property>
<property name="value" >
<number>50</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition" >
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval" >
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinSkipTrans" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="suffix" >
<string> %</string>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="singleStep" >
<number>5</number>
</property>
<property name="value" >
<number>50</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -274,6 +335,9 @@
<tabstop>checkTranslations</tabstop>
<tabstop>checkTag</tabstop>
<tabstop>checkTarball</tabstop>
<tabstop>checkSkipTrans</tabstop>
<tabstop>sliderSkipTrans</tabstop>
<tabstop>spinSkipTrans</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
@ -285,8 +349,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>222</x>
<y>311</y>
<x>226</x>
<y>447</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
@ -301,8 +365,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>290</x>
<y>317</y>
<x>294</x>
<y>447</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
@ -310,5 +374,69 @@
</hint>
</hints>
</connection>
<connection>
<sender>sliderSkipTrans</sender>
<signal>valueChanged(int)</signal>
<receiver>spinSkipTrans</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>354</x>
<y>378</y>
</hint>
<hint type="destinationlabel" >
<x>489</x>
<y>383</y>
</hint>
</hints>
</connection>
<connection>
<sender>spinSkipTrans</sender>
<signal>valueChanged(int)</signal>
<receiver>sliderSkipTrans</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>492</x>
<y>397</y>
</hint>
<hint type="destinationlabel" >
<x>342</x>
<y>384</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkSkipTrans</sender>
<signal>toggled(bool)</signal>
<receiver>sliderSkipTrans</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>123</x>
<y>387</y>
</hint>
<hint type="destinationlabel" >
<x>288</x>
<y>396</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkSkipTrans</sender>
<signal>toggled(bool)</signal>
<receiver>spinSkipTrans</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>87</x>
<y>388</y>
</hint>
<hint type="destinationlabel" >
<x>486</x>
<y>391</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -89,12 +89,18 @@ END_OF_TEXT
END_OF_TEXT
end
def statsLine(file, langName, numLanguages, translatedPercent)
values = `msgfmt --statistics po/#{langName}/#{@appName}.po -o /dev/null 2>&1`.scan /[\d]+/
missing = values[1].to_i + values[2].to_i
def self.fileStats(filename)
values = `msgfmt --statistics #{filename} -o /dev/null 2>&1`.scan /[\d]+/
fuzzy = values[1].to_i
untranslated = values[2].to_i
total = values[0].to_i + values[1].to_i + values[2].to_i
percentage = (total - missing) * 100 / total
percentage = (total - fuzzy - untranslated) * 100 / total
return fuzzy, untranslated, percentage
end
def statsLine(file, langName, numLanguages, translatedPercent)
fuzzy, untranslated, percentage = TranslationStatsBuilder.fileStats("po/#{langName}/#{@appName}.po")
textColor = case percentage
when 0...70 then 'red'
when 70...100 then 'orange'
@ -104,9 +110,9 @@ END_OF_TEXT
file.print <<END_OF_TEXT
<tr>
<td style="text-align: left; color: #{textColor}">#{langName}</td>
<td style="text-align: center; color: #{textColor}">#{values[1].to_i}</td>
<td style="text-align: center; color: #{textColor}">#{values[2].to_i}</td>
<td style="text-align: center; color: #{textColor}">#{missing.to_i}</td>
<td style="text-align: center; color: #{textColor}">#{fuzzy}</td>
<td style="text-align: center; color: #{textColor}">#{untranslated}</td>
<td style="text-align: center; color: #{textColor}">#{fuzzy + untranslated}</td>
<td style="text-align: center; color: #{textColor}">#{percentage.to_s + " %"}</td>
</tr>
END_OF_TEXT