diff options
Diffstat (limited to 'markup/pod/live-manual/media/text/bin')
8 files changed, 561 insertions, 0 deletions
diff --git a/markup/pod/live-manual/media/text/bin/check-spelling.sh b/markup/pod/live-manual/media/text/bin/check-spelling.sh new file mode 100755 index 0000000..b11e2ae --- /dev/null +++ b/markup/pod/live-manual/media/text/bin/check-spelling.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +set -e + +# Script to check English spelling interactively in live-manual. + +# Check whether aspell is installed or not with English dictionaries. + +if [ ! -x "$(which aspell 2>/dev/null)" ] + then + echo "E: aspell - command not found!" + echo "I: aspell can be downloaded from ftp://ftp.gnu.org/gnu/aspell/" + echo "I: On debian based systems, aspell can be installed with 'apt-get install aspell'." + exit 1 +elif [ ! -e "/var/lib/dictionaries-common/aspell/aspell-en" ] + then + echo "E: No English dictionary found." + echo "I: Please do 'apt-get install aspell-en'." + exit 1 +fi + +echo "" +echo "This script can help you check the spelling of these English texts:" +echo "" + +# Functions + +Check_file () +{ +aspell --check "manual/en/${FILE}" --dont-backup --lang="en" +} + +List_files () +{ +ls manual/en | cat --number +printf "\tdebian/changelog" +} + +Select_files () +{ +echo "" +echo "Choose a number ['a' to see all] ['c' for changelog] or ['q' to quit]:" + +read NUMBER + +FILE=$(ls manual/en | cat --number | grep -w ${NUMBER} | sed -e 's|[0-9]*||g' -e 's|^[ \t]*||') + +case "$NUMBER" in + [[:digit:]]*) + Check_file + ;; + + a) + echo "Checking all files, one at a time..." + sleep 2 + for FILE in $(ls manual/en) + do + Check_file + done + ;; + + c) + echo "Checking spelling in debian/changelog" + sleep 2 + aspell --check "debian/changelog" --dont-backup --lang="en" + ;; + + q) + exit 0 + ;; + + *) + echo "Nothing to do! Exiting..." + ;; + +esac +} + +List_files +Select_files diff --git a/markup/pod/live-manual/media/text/bin/count-untranslated-strings.sh b/markup/pod/live-manual/media/text/bin/count-untranslated-strings.sh new file mode 100755 index 0000000..1087df1 --- /dev/null +++ b/markup/pod/live-manual/media/text/bin/count-untranslated-strings.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +# Count total number of untranslated strings in live-manual + +Count_untranslated_strings () +{ +for POFILE in manual/po/*/* + do + if [ "$(sed '$!d' ${POFILE})" = 'msgstr ""' ] + then + sed '$G' ${POFILE} | grep --extended-regexp --before-context=1 '^$' | grep --count '^msgstr ""$' || continue + else + grep --extended-regexp --before-context=1 '^$' ${POFILE} | grep --count '^msgstr ""$' || continue + fi + done +} + +Count_untranslated_strings | awk '{ sum += $1 } END { print sum }' diff --git a/markup/pod/live-manual/media/text/bin/find-fuzzy.sh b/markup/pod/live-manual/media/text/bin/find-fuzzy.sh new file mode 100755 index 0000000..fca86ce --- /dev/null +++ b/markup/pod/live-manual/media/text/bin/find-fuzzy.sh @@ -0,0 +1,105 @@ +#!/bin/sh + +set -e + +# Script to assist translators in finding and fixing fuzzy strings in live-manual. + +echo "" +echo "There are $(grep -w 'fuzzy' manual/po/*/* | wc -l) fuzzy strings altogether in live-manual." +echo "This script can help you find and fix them. What is your language?." +echo "Type: $(ls -C manual/po) ['a' to see all]['q' to quit]" + +# Editor defaults to vim unless otherwise specified in preferences. + +EDITOR="${EDITOR:-vim}" + +# Creating the function. Searches 'fuzzy' and offers to open editor to fix them. + +Find_fuzzy () +{ + echo "" + echo "There are $(grep -w 'fuzzy' manual/po/$ANSWER/* | wc -l) fuzzy strings in your language." + echo "" + + if [ "$(grep -w 'fuzzy' manual/po/$ANSWER/* | wc -l)" -eq "0" ] + then + echo "You may now proceed... please do:" + echo "" + echo " * git add ." + echo " * git commit -m \"Your commit message.\"" + echo " * git push " + echo "" + + exit 0 + else + grep -w 'fuzzy' manual/po/$ANSWER/* + + echo "" + echo "Do you want to launch your text editor to start fixing them? [yes/no]" + + read OPENEDITOR + + case "$OPENEDITOR" in + y*|Y*) + $EDITOR $(grep -w 'fuzzy' manual/po/$ANSWER/* | sed 's|:#, fuzzy.*||' | uniq) + ;; + + n*|N*) + exit 0 + ;; + + *) echo "You didn't type 'yes'. Exiting..." + exit 0 + ;; + esac + fi + + exit 0 +} + +# Languages menu. + +read ANSWER + +case "$ANSWER" in + en) + echo "Nothing to be done, really." + echo "Translation English-English not implemented yet!" + ;; + + ca|de|es|fr|it|ja|pl|pt_BR|ro) + Find_fuzzy + ;; + + a) + grep -w 'fuzzy' manual/po/*/* + + echo "" + echo "Do you want to launch your text editor to start fixing them? [yes/no]" + + read OPENEDITOR + + case "$OPENEDITOR" in + y*|Y*) + $EDITOR $(grep -w 'fuzzy' manual/po/*/* | sed 's|:#, fuzzy.*||' | uniq) + ;; + + n*|N*) + exit 0 + ;; + + *) + echo "You didn't type 'yes'. Exiting..." + exit 0 + ;; + esac + ;; + + q) + exit 0 + ;; + + *) + echo "No language chosen. Exiting..." + ;; +esac diff --git a/markup/pod/live-manual/media/text/bin/find-untranslated.sh b/markup/pod/live-manual/media/text/bin/find-untranslated.sh new file mode 100755 index 0000000..d39b6fe --- /dev/null +++ b/markup/pod/live-manual/media/text/bin/find-untranslated.sh @@ -0,0 +1,198 @@ +#!/bin/sh + +set -e + +# Script to assist translators in finding and fixing untranslated strings in live-manual. + +# First, we prepare to count the total number of untranslated strings. + +Count_untranslated_strings () +{ + for POFILE in manual/po/*/* + do + if [ "$(sed '$!d' ${POFILE})" = 'msgstr ""' ] + then + sed '$G' ${POFILE} | grep --extended-regexp --before-context=1 '^$' | grep --count '^msgstr ""$' || continue + else + grep --extended-regexp --before-context=1 '^$' ${POFILE} | grep --count '^msgstr ""$' || continue + fi + done +} + +# Then, if there is not any untranslated string the script exits. + +Check_untranslated_strings () +{ + if [ "$(Count_untranslated_strings | awk '{ sum += $1 } END { print sum }')" -eq "0" ] + then + echo "There are 0 untranslated strings." + exit 0 + fi +} + +Check_untranslated_strings + +# Creating other functions. + +# An untranslated string is an empty 'msgstr ""' followed by a blank line. We +# grep blank lines and ensure that the previous line only contains 'msgstr ""'. +# +# If the last string in a po file is not translated, there is no blank line at +# the end so we need to add one with "sed '$G''". +# + +Find_untranslated () +{ +echo "" +echo " * Searching for 'untranslated strings' in ${LANGUAGE} ..." +echo "" + +for POFILE in manual/po/"${LANGUAGE}"/* + do + echo "Untranslated strings in ${POFILE}" + + if [ "$(sed '$!d' ${POFILE})" = 'msgstr ""' ] + then + sed '$G' ${POFILE} | grep --extended-regexp --before-context=1 '^$' | grep --count '^msgstr ""$' || continue + else + grep --extended-regexp --before-context=1 '^$' ${POFILE} | grep --count '^msgstr ""$' || continue + fi + done +} + +# Showing *only* untranslated strings: +# pros: finer granularity, easier to read... +# cons: Some languages with accents and other similar stuff may greatly benefit +# from a quick glance at the translated strings, too. And then some... +# +# If there is not any untranslated string in the selected language, then exit. + +Show_strings () +{ +if [ "$(Find_untranslated | awk '{ sum += $1 } END { print sum }')" -eq "0" ] + then + echo "" + echo "There are 0 untranslated strings in language: ${LANGUAGE}" | grep --color ${LANGUAGE} + echo "" + + exit 0 +fi + +echo "" +echo "Do you want to see the $(Find_untranslated | awk '{ sum += $1 } END { print sum }') strings before starting work? [yes/no] ['q' to quit]" + +POFILES="$(Find_untranslated | grep --extended-regexp --before-context=1 '[1-9]'| sed -e 's|Untranslated strings in ||' -e 's|--||' -e 's|[0-9]*||g')" + +read ANSWER +case "${ANSWER}" in + y*|Y*) + for POFILE in ${POFILES} + do + echo "" + echo "Untranslated strings in $(basename ${POFILE})" | grep --color $(basename ${POFILE}) + echo "" + + msggrep --invert-match --msgstr --regexp='' ${POFILE} + done + + Open_editor + ;; + + n*|N*) + Open_editor + ;; + + q) + exit 0 + ;; + + *) + echo "You didn't type 'yes'. Exiting..." + exit 0 + ;; +esac +} + +# Searches untranslated strings and offers to open editor to fix them. +# +# Editor defaults to vim unless otherwise specified in the environment. + +EDITOR="${EDITOR:-vim}" + +Open_editor () +{ +echo "" +echo "Do you want to launch your text editor to start fixing them? [yes/no] ['q' to quit]" + +POFILESTOEDIT="$(Find_untranslated | grep --extended-regexp --before-context=1 '[1-9]'| sed -e 's|Untranslated strings in ||' -e 's|--||' -e 's|[0-9]*||g')" + +read OPENEDITOR + +case "$OPENEDITOR" in + y*|Y*) + if [ -z "${POFILESTOEDIT}" ] + then + echo "No po files to edit." + exit 0 + else + ${EDITOR} ${POFILESTOEDIT} + fi + ;; + + n*|N*) + echo "You typed 'no'. Exiting..." + exit 0 + ;; + + q) + exit 0 + ;; + + *) + echo "You didn't type 'yes'. Exiting..." + exit 0 + ;; +esac +} + +# Main menu. + +echo "Counting untranslated strings...please wait..." +echo "" +echo "There are $(Count_untranslated_strings | awk '{ sum += $1 } END { print sum }') untranslated strings in live-manual." +echo "This script can help you find and fix them. What is your language?." +echo "Type: $(ls -C manual/po) ['a' to see all]['q' to quit]" + +read LANGUAGE +case "$LANGUAGE" in + + ca|de|es|fr|it|ja|pl|pt_BR|ro) + Find_untranslated + Show_strings + ;; + + en) + echo "Nothing to be done, really." + echo "Translation English-English not implemented yet!" + ;; + + a) + for LANGUAGE in $(ls manual/po) + do + Find_untranslated + if [ "$(Find_untranslated | awk '{ sum += $1 } END { print sum }')" -eq "0" ] + then + echo "" + echo "There are 0 untranslated strings in language: ${LANGUAGE}" | grep --color ${LANGUAGE} + echo "" + fi + done + ;; + + q) + exit 0 + ;; + + *) + echo "No language chosen. Exiting..." +esac diff --git a/markup/pod/live-manual/media/text/bin/fix-sisu-html.rb b/markup/pod/live-manual/media/text/bin/fix-sisu-html.rb new file mode 100755 index 0000000..90bd695 --- /dev/null +++ b/markup/pod/live-manual/media/text/bin/fix-sisu-html.rb @@ -0,0 +1,28 @@ +#! /usr/bin/env ruby + +require 'nokogiri' + +output_file=ARGV.shift +input_file=output_file+"~" +debug=ARGV.shift.to_i + +File.rename(output_file,input_file) +doc=Nokogiri::HTML(open input_file) + +# Rewrite the input file so that comparison with the output will only +# show changes introduced by the filter, since Nokogiri parsed output +# introduces numerous subtle differences even without filtering. +File.open(input_file,"w") {|o| o.puts doc.to_html} if debug > 0 + +File.open(output_file,"w") do |o| + # CSS3 selectors don't support regexes, so we take a shotgun approach, + # removing all tables with summaries (OK for current sisu output). + # Change to use a custom pseudo class if anything more refined is needed. + doc.css(%[table[summary]]).remove + toc=doc.css(%[h2,h4[class$="toc"]]).each do |node| + node.remove if node.inner_text.match(/Metadata|Manifest|SiSU/) + end + o.puts doc.to_html +end + +File.delete(input_file) unless debug > 0 diff --git a/markup/pod/live-manual/media/text/bin/po-integrity-check.sh b/markup/pod/live-manual/media/text/bin/po-integrity-check.sh new file mode 100755 index 0000000..0dc23a2 --- /dev/null +++ b/markup/pod/live-manual/media/text/bin/po-integrity-check.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +set -e + +# Script to help translators to check the integrity of po files in live-manual. +# +# 'msgfmt' performs several checks and outputs some common errors: +# +# - Checks format +# - Checks header +# - ... +# +# We do not want to compile a .mo file so we use /dev/null. +# + +echo "" +echo "This script can help you check the integrity of po files." +echo "Select: $(ls -C manual/po) ['a' to see all] ['q' to quit] " + +# Creating function + +Integrity_check() +{ + echo "Checking the integrity of $(ls manual/po/${LANGUAGE}/* | wc -l) po files in ${LANGUAGE}." + echo "" + for POFILE in manual/po/${LANGUAGE}/* + do + echo "-$(basename ${POFILE})" + msgfmt --verbose --check --output-file=/dev/null ${POFILE} || { echo "-> This .po file might be 'BAD'. Please revise it."; echo ""; exit 1; } + if [ "$?" -eq "0" ] + then + echo "-> This .po file is 'GOOD'." + echo "" + fi + done +} + +# Menu. + +read LANGUAGE + +case "$LANGUAGE" in + en) echo "Nothing to be done, really!" + ;; + + ca|de|es|fr|it|ja|pl|pt_BR|ro) + Integrity_check + ;; + + a) for LANGUAGE in manual/po/* + do + for POFILE in ${LANGUAGE}/* + do + echo "-Checking the integrity of '$(basename ${POFILE})' in '$(basename ${LANGUAGE})'" + msgfmt --verbose --check --output-file=/dev/null ${POFILE} || { echo "-> This .po file might be 'BAD'. Please revise it."; echo ""; exit 1; } + if [ "$?" -eq "0" ] + then + echo "->This .po file is 'GOOD'." + echo "" + fi + done + done + ;; + + q) exit 0 + ;; + + *) echo "No language chosen. Exiting..." + ;; + +esac diff --git a/markup/pod/live-manual/media/text/bin/show-complete-languages.sh b/markup/pod/live-manual/media/text/bin/show-complete-languages.sh new file mode 100755 index 0000000..4682d0a --- /dev/null +++ b/markup/pod/live-manual/media/text/bin/show-complete-languages.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Find 100% translated languages in live-manual + +Find_untranslated () +{ +for POFILE in manual/po/"${LANGUAGE}"/* + do + + if [ "$(sed '$!d' ${POFILE})" = 'msgstr ""' ] + then + sed '$G' ${POFILE} | grep --extended-regexp --before-context=1 '^$' | grep --count '^msgstr ""$' || continue + else + grep --extended-regexp --before-context=1 '^$' ${POFILE} | grep --count '^msgstr ""$' || continue + fi + + done +} + + for LANGUAGE in $(ls manual/po) + do + if [ "$(Find_untranslated | awk '{ sum += $1 } END { print sum }')" -eq "0" ] + then + echo -n "${LANGUAGE}, " + fi + done diff --git a/markup/pod/live-manual/media/text/bin/update-version.sh b/markup/pod/live-manual/media/text/bin/update-version.sh new file mode 100755 index 0000000..3a9d2e4 --- /dev/null +++ b/markup/pod/live-manual/media/text/bin/update-version.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +VERSION="$(cat ../VERSION)" + +DAY="$(LC_ALL=C date +%d)" +MONTH="$(LC_ALL=C date +%m)" +YEAR="$(LC_ALL=C date +%Y)" + +echo "Updating version information..." +sed -i -e "s|^ :published:.*$| :published: ${YEAR}-${MONTH}-${DAY}|" \ + -e "s|(C) 2006-.*|(C) 2006-${YEAR} Live Systems Project|" \ +en/live-manual.ssm + +# European date format +for _LANGUAGE in ca de es fr it pl ro +do + if [ -e po/${_LANGUAGE}/live-manual.ssm.po ] + then + sed -i -e "s|:published: .*.${YEAR}|:published: ${DAY}.${MONTH}.${YEAR}|" \ + po/${_LANGUAGE}/live-manual.ssm.po + fi +done + +# Brazilian date format +if [ -e po/pt_BR/live-manual.ssm.po ] +then + sed -i -e "s|:published: .*-${YEAR}|:published: ${DAY}-${MONTH}-${YEAR}|" \ + po/pt_BR/live-manual.ssm.po +fi |