Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transifex integration (translation management) #479

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#########################
#### GENERAL or ROOT ####
#########################

# Transifex
.transifexrc

# Maven
target/

Expand Down
39 changes: 39 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[main]
host = https://www.transifex.com
minimum_perc = 50

[epubcheck.ErrorsWarnings]
file_filter = src/main/resources/com/adobe/epubcheck/messages/MessageBundle_<lang>.properties
source_file = src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties
source_lang = en
type = UNICODEPROPERTIES

[epubcheck.CommandlineMessages]
file_filter = src/main/resources/com/adobe/epubcheck/util/messages_<lang>.properties
source_file = src/main/resources/com/adobe/epubcheck/util/messages.properties
source_lang = en
type = UNICODEPROPERTIES

[epubcheck.CssParser]
file_filter = src/main/resources/org/idpf/epubcheck/util/css/messages_<lang>.properties
source_file = src/main/resources/org/idpf/epubcheck/util/css/messages.properties
source_lang = en
type = UNICODEPROPERTIES

[epubcheck.jing-xsd-validation]
file_filter = src/main/resources/com/thaiopensource/datatype/xsd/resources/Messages_<lang>.properties
source_file = src/main/resources/com/thaiopensource/datatype/xsd/resources/Messages.properties
source_lang = en
type = PROPERTIES

[epubcheck.jing-relaxng-validation]
file_filter = src/main/resources/com/thaiopensource/relaxng/pattern/resources/Messages_<lang>.properties
source_file = src/main/resources/com/thaiopensource/relaxng/pattern/resources/Messages.properties
source_lang = en
type = PROPERTIES

[epubcheck.jing-schematron-validation]
file_filter = src/main/resources/com/thaiopensource/validate/schematron/resources/Messages_<lang>.properties
source_file = src/main/resources/com/thaiopensource/validate/schematron/resources/Messages.properties
source_lang = en
type = PROPERTIES
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@
<directory>src/main/resources</directory>
<excludes>
<exclude>com/adobe/epubcheck/schema/30/*.sch</exclude>
<exclude>com/thaiopensource/relaxng/pattern/resources/Messages.properties</exclude>
<exclude>com/thaiopensource/datatype/xsd/resources/Messages.properties</exclude>
</excludes>
</resource>
<resource>
Expand Down
92 changes: 92 additions & 0 deletions src/build/transifex-pull.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

# bash script to update and normalize
# pulled transifex properties files
#
# Author: Tobias Fischer (https://github.com/tofi86)
# Project: IDPF/EpubCheck (https://github.com/IDPF/epubcheck)
#
# Date: 2015-10-09
# License: MIT License
#

param1=$1


function escapeISO88591() {
file=$1
echo "- Escaping ISO-8859-1 encodings with Unicode escapes"
native2ascii -encoding ISO-8859-1 ${file} ${file}
}

function removeJavaEscapes() {
file=$1

# replace \\ -> \, \` -> `, \= -> =, \: -> :, \! -> !
sed -E -i -- 's/\\([\\`=:!])/\1/g' ${file}

# make unicode escapes \u00fc uppercase \u00FC
perl -i -pe 's/\\u([0-9a-f]{4})/\\u\U\1/g' ${file}

# replace newlines in help_text
sed -E -i -- '/^help_text/s/((\\n)+)/\1\\\'$'\n /g' ${file}
sed -E -i -- 's/^( )([[:space:]]+)/\1\\\2/g' ${file}

# remove temp file
rm ${file}-- 2> /dev/null
}

function processFile() {
file=$1

echo ""
echo "Processing file '${file}'"
file ${file} | grep 'ISO-8859' > /dev/null
if [ $? -eq 0 ]; then
escapeISO88591 ${file}
fi

removeJavaEscapes ${file}
}


# Check if this is running from repo root dir near the .tx/ folder
if [ ! -d .tx/ ] ; then
echo "FATAL: You need to run this script from the repository's root directory!"
echo "e.g. ./src/build/transifex-pull.sh --all"
exit 1
fi


# Check for Transifex Commandline Client
if [ `which tx >/dev/null ; echo $?` -eq 1 ] ; then
echo "FATAL: You need to install the Transifex Commandline Client first in order to run this script!"
echo "Instructions: http://docs.transifex.com/client/setup/"
exit 1
fi


# Show help if no language parameter is passed to the script or --help
if [[ -z ${param1} || ${param1} == "--help" ]] ; then
echo "usage: transifex-pull.sh [--all | <2-digit-country-code>]"
echo "examples:"
echo " transifex-pull.sh --all"
echo " transifex-pull.sh de"

# Pull ALL translations
elif [ ${param1} == "--all" ] ; then
minimum_percent_translated=$(awk -F "=" '/minimum_perc/ {print $2}' .tx/config)
echo "Pulling ALL epubcheck translations (>${minimum_percent_translated}% done) from Transifex..."
echo ""
tx pull -f | tee /dev/stderr | grep "> [a-z][a-z]: " | awk '{print $3}' | while read f; do processFile ${f}; done

# Pull translations for a 2-digit-language-code
elif [ ${#param1} -eq 2 ] ; then
echo "Pulling epubcheck translation '${param1}' from Transifex..."
echo ""
tx pull -f -l ${param1} | tee /dev/stderr | grep "${param1}: " | awk '{print $3}' | while read f; do processFile ${f}; done

else
echo "FATAL: Couldn't recognize language code '${param1}'. Exit."
exit 1
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Properties file specifying messages
enumeration_param=\"enumeration\" facet is not allowed as a parameter: use \"value\" element instead
whiteSpace_param=\"whiteSpace\" facet is not allowed as a parameter
unrecognized_param=unrecognized parameter \"{0}\"
invalid_regex=invalid regular expression: {0}
not_ordered=parameter can only be applied to ordered datatype
invalid_limit=\"{0}\" is not allowed by the base type: {1}
no_length=base datatype does not define a units of length
scale_not_derived_from_decimal=\"scale\" parameter can only be applied to datatype derived from \"decimal\"
scale_not_non_negative_integer=\"scale\" parameter must be non negative integer
length_not_non_negative_integer=\"length\" parameter must be non negative integer
precision_not_derived_from_decimal=\"precision\" parameter can only be applied to datatype derived from \"decimal\"
precision_not_positive_integer=\"precision\" parameter must be positive integer
regex_impl_not_found=cannot find regular expression implementation; use JDK 1.4 or add Xerces2 to your classpath
regex_internal_error=internal error in regular expression for datatype {0}

# validation errors
length_violation=must be {0} with length equal to {1} (actual length was {2})
max_length_violation=must be {0} with length at most {1} (actual length was {2})
min_length_violation=must be {0} with length at least {1} (actual length was {2})
min_inclusive_violation=must be {0} greater than or equal to {1}
min_exclusive_violation=must be {0} greater than {1}
max_inclusive_violation=must be {0} less than or equal to {1}
max_exclusive_violation=must be {0} less than {1}
pattern_violation=must be {0} matching the regular expression \"{1}\"
entity_violation=must be a name declared in the DTD as an unparsed entity
undeclared_prefix=must be a QName whose prefix, if any, is declared (prefix \"{0}\" is not declared)
precision_violation=must be {0} with at most {1} significant digits (found {2} digits)
precision_1_violation=must be {0} with exactly one significant digit (found {1} digits)
# part of the point is to avoid ugly "digit(s)" in the error message
scale_violation=must be a decimal number with at most {0} significant digits after the decimal point (found {1} digits)
scale_0_violation=must be a decimal number without any significant digits after the decimal point
scale_1_violation=must be a decimal number with at most one significant digit after the decimal point (found {0} digits)
lexical_violation=must be {0}

# fragments substituted in above
lexical_space_string=a string
lexical_space_uri=a URI
lexical_space_boolean=a boolean
lexical_space_decimal=a decimal number
lexical_space_float=a floating-point number
lexical_space_duration=a duration
lexical_space_hex=a hexadecimal string
lexical_space_base64=a base64 string
lexical_space_integer=an integer
lexical_space_name=an XML name
lexical_space_ncname=an XML name without colons
lexical_space_nmtoken=an XML NMTOKEN
lexical_space_qname=an XML QName
lexical_space_list=a whitespace-delimited list
lexical_space_list_ncname=a list of XML names without colons
lexical_space_list_nmtoken=a list of XML NMTOKENs
lexical_space_date_y_m_d_time=an ISO date and time
lexical_space_time=an ISO time
lexical_space_date_y_m_d=an ISO date
lexical_space_date_y_m=an ISO year and month
lexical_space_date_y=a year
lexical_space_date_m_d=an ISO month and day (of the form --MM-DD)
lexical_space_date_m=an ISO month (of the form --MM)
lexical_space_date_d=an ISO day of the month (of the form ---DD)
lexical_space_language=an RFC 3066 language identifier
Loading