Commit 93f22701 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add .po file header

Don't output duplicate strings in .po files
Don't output empty English strings in .po files
parent 69d38dc7
......@@ -26,6 +26,7 @@ TARBALLS=${DATA}/tarballs
CLEANCMD="/usr/bin/php ${SCRIPTS}/langpack.php"
SYNTAXCMD="/usr/bin/php -l"
UTF8CMD="/usr/bin/perl ${SCRIPTS}/check-utf8.pl"
POCMD="/usr/bin/perl ${SCRIPTS}/po-php.pl"
if [ ! -w ${DATA} ]; then
echo "${DATA} not writable"
......@@ -116,7 +117,7 @@ for lang in ${langs} ; do
fi
# Create langpack from .po file
output=`/usr/bin/perl ${SCRIPTS}/po-php.pl $pofile $cleanbranchdir "${lang}.utf8"`
output=`${POCMD} $pofile $cleanbranchdir "${lang}.utf8"`
if [ $? -ne 0 ]; then
echo "Failed to create langpack from .po file ${pofile}" >> ${log}
......
......@@ -98,7 +98,7 @@ function phptopo($en_strings, $fileid, $in, $pot) {
elseif ($state == L_SEMI && $t == ';') {
foreach ($keys as $key) {
eval('$k = ' . $key . ';');
if (isset($en_strings[$k])) {
if (isset($en_strings[$k]) && strlen($en_strings[$k]) > 0) {
$po .= "\n\n#: $fileid $k";
$po .= "\nmsgctxt \"$fileid $k\"";
$po .= "\nmsgid \"" . addcslashes($en_strings[$k], "\\\"\r\n") . '"';
......@@ -115,6 +115,7 @@ function phptopo($en_strings, $fileid, $in, $pot) {
}
}
$po .= '"';
unset($en_strings[$k]); // Avoid duplicates
}
if (isset($heredoc)) {
unset($heredoc);
......@@ -170,7 +171,31 @@ if (file_exists($destfile)) {
$sourcefiles = array();
get_langfile_list($sourcefiles, $source);
$pot = preg_match('/.pot$/', $destfile); // Create .pot template
if ($pot = preg_match('/.pot$/', $destfile)) {
// Create .pot template
$version = 'mahara';
if (preg_match('/master\.pot$/', $destfile)) {
$version .= '-trunk';
}
else if (preg_match('/(\d[0-9\.]+)_STABLE\.pot$/', $destfile, $matches)) {
$version .= '-' . $matches[1];
}
$header = '
msgid ""
msgstr ""
"Project-Id-Version: ' . $version . '\n"
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/mahara\n"
"POT-Creation-Date: ' . date('Y-m-d H:iO') . '\n"
"PO-Revision-Date: YYYY-MM-DD HH:MM+ZZZZ\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
';
file_put_contents($destfile, $header, FILE_APPEND);
}
if (!empty($sourcefiles)) {
foreach ($sourcefiles as $sourcefile) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment