aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorThomas Backlund <tmb@mageia.org>2014-10-12 12:27:45 +0300
committerThomas Backlund <tmb@mageia.org>2014-10-12 12:27:45 +0300
commit9ce6d646ff718cd62f6434c9a4c94e450436612a (patch)
tree3ee82e5db7c0aee44a5573d9d17035c6ecac697d /tools
parenta0b2d09125d7911656fe4cb286f20643c4432281 (diff)
downloadwww-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar
www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar.gz
www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar.bz2
www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar.xz
www-9ce6d646ff718cd62f6434c9a4c94e450436612a.zip
Revert "Updated Estonian translation"
Diffstat (limited to 'tools')
-rw-r--r--tools/README17
-rw-r--r--tools/extract2gettext.php139
-rw-r--r--tools/extract2lang.php105
-rw-r--r--tools/lookup_for_second_argument.php61
-rwxr-xr-xtools/lookup_for_second_argument.sh18
-rw-r--r--tools/pa2lang.php108
-rwxr-xr-xtools/rebuild_gettext_catalogs.sh149
-rw-r--r--tools/translated_converter.py107
-rw-r--r--tools/update-mirrors-list.php8
-rw-r--r--tools/web_projects.dat25
10 files changed, 737 insertions, 0 deletions
diff --git a/tools/README b/tools/README
new file mode 100644
index 000000000..9b10f0a8b
--- /dev/null
+++ b/tools/README
@@ -0,0 +1,17 @@
+REBUILDING A GETTEXT DICTIONARIES
+
+To rebuild a gettext dictionaries and refresing the po files you need to run rebuild_gettext_catalogs.sh script in the root of main web server:
+
+It cals extract2gettext.php for every translatable resource. It picks the database for that from web_projects.dat file.
+
+Python script translated_converter.py is used in conversion of lang files to gettext po files.
+It comes from http://gitweb.mageia.org/software/i18n/tools/tree/websites where you can find it's license and some other informations.
+
+
+LEGACY UTILITIES
+1. There is also useful script lookup_for_second_argument.sh used as a preparation for transition.
+It cals lookup_for_second_argument.php for every translatable resource. It picks the database for that from web_projects.dat file.
+
+2. File extract2lang.php is used for old lang l10n system.
+
+3. In the transition from php arrays to lang l10n system file pa2lang.php was used.
diff --git a/tools/extract2gettext.php b/tools/extract2gettext.php
new file mode 100644
index 000000000..73e873333
--- /dev/null
+++ b/tools/extract2gettext.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Lookup for _g() and _r() in php source code and build a gettext catalog (pot file)
+ *
+ * PHP 5.3
+ *
+ * @license MIT
+ * @author Filip (transformation to build a gettext catalog)
+ * @copyright 2014/02
+ * based on extract2lang.php by author Romain d'Alverny, rdalverny, rda
+*/
+
+if (php_sapi_name() !== 'cli') {
+ echo "CLI only.\n";
+ exit(1);
+}
+
+if (version_compare(PHP_VERSION, '5.3.0') < 0) {
+ echo "PHP 5.3 needed.\n";
+ exit(1);
+}
+
+define('APP_ROOT', realpath(__DIR__ . '/..'));
+
+$php_source = isset($argv[1]) ? $argv[1] : null;
+$domain = isset($argv[2]) ? $argv[2] : null;
+$quiet = isset($argv[3]) ? $argv[3] : false;
+
+if (is_null($php_source) || is_null($domain)) {
+ echo <<<U
+Usage:
+ php tools/extract2gettext.php path/to/source.php domain_name
+
+ Example:
+ php tools/extract2gettext.php en/index.php index
+
+ You can join multiple sources with apostrophe - single quote (') like this:
+ 'en/3/download_index.php en/for-pc/index.php en/for-server/index.php en/3/index.php en/3/nav.php'
+
+U;
+ exit(1);
+}
+
+date_default_timezone_set(@date_default_timezone_get());
+
+if(!$quiet) { echo "ohay!\n";}
+
+$cmd = sprintf('grep -HrnEi "_(g|r|t)\([^$](.*)" %s', $php_source);
+if(!$quiet) { echo $cmd, "\n"; }
+exec($cmd, $out);
+
+$strings = array();
+$f = array();
+$error = 0;
+
+if(count($out) == 0) {
+ if(!$quiet) { echo "No strings to save from $php_source.\n"; }
+ $error = 10;
+}
+
+foreach ($out as $str) {
+ $arr = explode(':', $str);
+ $file = array_shift($arr);
+ $file = str_replace(APP_ROOT, '', $file);
+ $files[] = $file;
+ $line = array_shift($arr);
+ $arr = implode(':', $arr);
+ $arr = str_replace('\\\'', '_apostrophe_', $arr);
+
+ if (preg_match_all('/\_(g|r|t)\(\'(.+)\'/imU', $arr, $reg)) { // i=PCRE_CASELESS, m=PCRE_MULTILINE, U=PCRE_UNGREEDY
+ foreach ($reg[2] as $found) {
+ $found = str_replace('_apostrophe_', '\'', $found);
+ $strings[$domain][$found][] = '/web/' . $file . ' +' . $line;
+ }
+ } else {
+ $parse_error = "\n\n!!!! Could not find string in $file, line $line: $str\n";
+ $parse_error .= "!!!! Parse error, please fix $file before using $domain.pot file!!!\n\n";
+ if(!$quiet) { echo $parse_error; }
+ $error = 20;
+ }
+}
+
+foreach ($strings as $domain => $strs) {
+ $f[] = '# gettext catalog for ' . $domain . ' web page(s)';
+ $f[] = '# Copyright (C) 2014 - ' . date('Y') . ' Mageia';
+ $f[] = '# This file is distributed under the same license as';
+ $f[] = '# the content of the corresponding web page(s).';
+ $f[] = '#';
+ $cur_date = date('Y-m-d H:i:sO');
+ $f[] = '# Generated by extract2gettext.php';
+ $f[] = sprintf('# Domain: %s', $domain);
+ $f[] = '#';
+ $f[] = '# include translation strings from:';
+ $files = array_unique($files);
+ foreach ($files as $source) {
+ $f[] = sprintf('# %s', $source);
+ }
+ $f[] = '#';
+ $f[] = 'msgid ""';
+ $f[] = 'msgstr ""';
+ $f[] = '"Project-Id-Version: ' . $domain . '\n"';
+ $f[] = '"Report-Msgid-Bugs-To: mageia-i18n@mageia.org\n"';
+ $f[] = '"POT-Creation-Date: ' . $cur_date . '\n"';
+ $f[] = '"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"';
+ $f[] = '"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"';
+ $f[] = '"Language-Team: LANGUAGE <LL@li.org>\n"';
+ $f[] = '"Language: \n"';
+ $f[] = '"MIME-Version: 1.0\n"';
+ $f[] = '"Content-Type: text/plain; charset=UTF-8\n"'; // CHARSET
+ $f[] = '"Content-Transfer-Encoding: 8bit\n"';
+ $f[] = '';
+
+ foreach ($strs as $str => $info) {
+ $str = str_replace(array("\'", '"'), array("'", '\"'), $str);
+ $f[] = sprintf('#: "%s"', $info[0]); // location of string in the source (#: reference...)
+ $f[] = 'msgid "' . $str . '"';
+ $f[] = 'msgstr ""';
+ $f[] = '';
+ }
+ $f = implode("\n", $f);
+ if ($domain == 'mognase') {
+ $dest = sprintf('%s/_nav/langs/en.pot', APP_ROOT);
+ } else {
+ $dest = sprintf('%s/langs/en/%s.pot', APP_ROOT, $domain);
+ }
+ $dir = dirname($dest);
+
+ if (!is_dir($dir)) {
+ if(!$quiet) { echo "making $dir\n"; }
+ mkdir($dir, 0755, true);
+ }
+ if(!$quiet) { echo sprintf("saved %d strings in %s\n", count($strs), $dest); }
+ if (FALSE === file_put_contents($dest, $f)) {
+ if(!$quiet) { echo "Failed to write $f to $dest.\n"; }
+ $error = 30;
+ }
+}
+if(!$quiet) { echo "Done. thxbye.\n"; }
+exit($error);
diff --git a/tools/extract2lang.php b/tools/extract2lang.php
new file mode 100644
index 000000000..17d8417ff
--- /dev/null
+++ b/tools/extract2lang.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * Lookup for _e(), _t() and _h() in source code and build a
+ *
+ * PHP 5.3
+ *
+ * @license MIT
+ * @author Romain d'Alverny, rdalverny, rda
+ * @copyright 2012/05
+ * @author Filip (small fixes and some added features)
+*/
+
+if (php_sapi_name() !== 'cli') {
+ echo "CLI only.\n";
+ exit(1);
+}
+
+if (version_compare(PHP_VERSION, '5.3.0') < 0) {
+ echo "PHP 5.3 needed.\n";
+ exit(1);
+}
+
+define('APP_ROOT', realpath(__DIR__ . '/..'));
+
+$php_source = isset($argv[1]) ? $argv[1] : null;
+$domain = isset($argv[2]) ? $argv[2] : null;
+
+if (is_null($php_source) || is_null($domain)) {
+ echo <<<U
+Usage:
+ php tools/extract2lang.php path/to/source.php domain_name
+
+ Example:
+ php tools/extract2lang.php en/index.php index
+
+ You can join multiple sources with apostrophe - single quote (') like this:
+ 'en/3/download_index.php en/for-pc/index.php en/for-server/index.php en/3/index.php en/3/nav.php'
+
+U;
+ exit(1);
+}
+
+echo "ohai!\n";
+
+$cmd = sprintf('grep -HrnEi "_(e|t|h|d)\((.*)" %s', $php_source);
+echo $cmd, "\n";
+exec($cmd, $out);
+
+$strings = array();
+$f = array();
+$error = 0;
+
+foreach ($out as $str) {
+ $arr = explode(':', $str);
+ $file = array_shift($arr);
+ $file = str_replace(APP_ROOT, '', $file);
+ $files[] = $file;
+ $line = array_shift($arr);
+ $arr = implode(':', $arr);
+ $arr = str_replace('\\\'', '_apostrophe_', $arr);
+
+ if (preg_match_all('/\_(e|t|h|d)\(\'(.+)\'/imU', $arr, $reg)) {
+ foreach ($reg[2] as $found) {
+ $found = str_replace('_apostrophe_', '\'', $found);
+ $strings[$domain][$found][] = $file . ' +' . $line;
+ }
+ }
+ else {
+ echo "\n\n!!!! Could not find string in $file, line $line: $str\n";
+ echo "!!!! Please fix $file before using $domain.en.lang file!!!\n\n";
+ $error = 2;
+ }
+}
+
+foreach ($strings as $domain => $strs) {
+ $f[] = sprintf('# Generated by extract2lang.php on %s', date('c'));
+ $f[] = sprintf('# Domain %s', $domain);
+ $f[] = '# include translation strings from:';
+ $files = array_unique($files);
+ foreach ($files as $source) {
+ $f[] = sprintf('# %s', $source);
+ }
+
+ foreach ($strs as $str => $info) {
+ $str = str_replace(array("\'", "\""), array("'", '"'), $str);
+ $f[] = '';
+ $f[] = sprintf('# %s', $info[0]);
+ $f[] = ';' . $str;
+ $f[] = $str;
+ $f[] = '';
+ }
+ $f = implode("\n", $f);
+ $dest = sprintf('%s/langs/%s/%s.%s.lang', APP_ROOT, 'en', $domain, 'en');
+ $dir = dirname($dest);
+
+ if (!is_dir($dir)) {
+ echo "making $dir\n";
+ mkdir($dir, 0755, true);
+ }
+ echo sprintf("saved %d strings in %s\n", count($strs), $dest);
+ if (FALSE === file_put_contents($dest, $f))
+ echo "Failed to write.\n";
+}
+echo "Done. kthxbye.\n";
+exit($error);
diff --git a/tools/lookup_for_second_argument.php b/tools/lookup_for_second_argument.php
new file mode 100644
index 000000000..97ce33728
--- /dev/null
+++ b/tools/lookup_for_second_argument.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Lookup for second argument in functions _t() and _d() in source code
+ *
+ * PHP 5.3
+ *
+ * @license MIT
+ * @author Filip (transformation to build a gettext dictionary)
+ * @copyright 2014/02
+ * based on extract2lang.php by author Romain d'Alverny, rdalverny, rda
+*/
+
+if (php_sapi_name() !== 'cli') {
+ echo "CLI only.\n";
+ exit(1);
+}
+
+if (version_compare(PHP_VERSION, '5.3.0') < 0) {
+ echo "PHP 5.3 needed.\n";
+ exit(1);
+}
+
+$php_source = isset($argv[1]) ? $argv[1] : null;
+$domain = isset($argv[2]) ? $argv[2] : null;
+
+if (is_null($php_source) || is_null($domain)) {
+ echo <<<U
+Usage:
+ php tools/lookup_for_second_argument.php path/to/source.php domain_name
+
+ Example:
+ php tools/lookup_for_second_argument.php en/index.php index
+
+ You can join multiple sources with apostrophe - single quote (') like this:
+ 'en/3/download_index.php en/for-pc/index.php en/for-server/index.php en/3/index.php en/3/nav.php'
+
+U;
+ exit(1);
+}
+
+date_default_timezone_set(@date_default_timezone_get());
+
+$cmd = sprintf('grep -HrnEi "_(e|t|h|d)\((.*)" %s', $php_source);
+exec($cmd, $out);
+
+foreach ($out as $str) {
+ $arr = explode(':', $str);
+ $file = array_shift($arr);
+ $line = array_shift($arr);
+ $arr = implode(':', $arr);
+ $arr = str_replace('\\\'', '_apostrophe_', $arr);
+ if (preg_match_all('/\_(t|d)\(\'(.+)\'(,.+)$/im', $arr, $test)) { // qq i=PCRE_CASELESS, m=PCRE_MULTILINE, U=PCRE_UNGREEDY
+ foreach ($test[3] as $more_arg) { // qq
+ $att = $php_source . ' (line ' . $line . '): '. trim($arr) . PHP_EOL; // qq
+ $attention[] = $att;
+ echo $att . PHP_EOL;
+ }
+ }
+}
+
+exit(0);
diff --git a/tools/lookup_for_second_argument.sh b/tools/lookup_for_second_argument.sh
new file mode 100755
index 000000000..30bcc1034
--- /dev/null
+++ b/tools/lookup_for_second_argument.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Filip Komar, 2014
+# @license GPL v2
+# @author Filip (prepare for transformation to gettext translation system)
+# @copyright 2014/03
+# inspired by check_for_translation_work.sh
+
+declare -A resources
+
+source ./tools/web_projects.dat
+
+for resource in "${!resources[@]}"
+do
+ php_source=${resources[$resource]}
+ php tools/lookup_for_second_argument.php $php_source $resource
+done
+echo ''
+echo "Done lookup for second argument in functions _t() and _d() in the source code"
diff --git a/tools/pa2lang.php b/tools/pa2lang.php
new file mode 100644
index 000000000..95e926641
--- /dev/null
+++ b/tools/pa2lang.php
@@ -0,0 +1,108 @@
+<?php
+/**
+ * Migrate PHP array to .lang files.
+ *
+ * PHP 5.3
+ *
+ * @license MIT
+ * @author Romain d'Alverny, rdalverny, rda
+ * @copyright 2012/05
+*/
+
+if (php_sapi_name() !== 'cli') {
+ echo "CLI only.\n";
+ exit(1);
+}
+
+if (version_compare(PHP_VERSION, '5.3.0') < 0) {
+ echo "PHP 5.3 needed.\n";
+ exit(1);
+}
+
+define('APP_ROOT', realpath(__DIR__ . '/..'));
+
+$php_source = isset($argv[1]) ? $argv[1] : null;
+$var = isset($argv[2]) ? $argv[2] : null;
+$domain = isset($argv[3]) ? $argv[3] : null;
+
+if (is_null($php_source) || is_null($var) || is_null($domain)) {
+ echo <<<U
+Usage:
+ pa2lang.php path/to/source.php var_name domain_name
+
+
+U;
+ exit(1);
+}
+
+echo "ohai!\n";
+
+$dest = sprintf('%s/langs/{LOC}/%s.{LOC}.lang', APP_ROOT, $domain);
+
+$php_source = realpath(APP_ROOT . '/' . $php_source);
+if (is_null($php_source)) {
+ echo "$php_source is not found. kthxbye.\n";
+ exit(1);
+}
+
+echo "Loading " . $php_source . " looking for \$$var\n";
+
+include $php_source;
+
+if (!isset($$var)) {
+ echo "$var is not set. kthxbye\n";
+ exit(1);
+}
+
+echo sprintf("Found %d locales here: %s.\n",
+ count($$var), implode(', ', array_keys($$var)));
+
+$files = array();
+$eng_array = $$var;
+$eng_array = $eng_array['en'];
+$number_of_eng_strings = count($eng_array);
+
+foreach ($$var as $k => $v) {
+
+ echo sprintf("> %s has %d translated strings, adding the rest %d untranslated.", $k, count($v), ($number_of_eng_strings - count($v)));
+ $v = array_merge($eng_array, $v); // add untranslated strings
+
+ $f = array();
+ $f[] = sprintf('# Generated by pa2lang.php on %s', date('c'));
+ $f[] = sprintf('# from %s $%s', $php_source, $var);
+
+ foreach ($v as $s0 => $s1) {
+ $s0 = str_replace("\n", ' ', $s0);
+ $s0 = preg_replace('/\s+/', ' ', $s0); // remove multiple spaces
+ $s0 = str_replace("\'", "'", $s0); // remove also backslashes
+
+ if (is_array($s1)) {
+ echo "\nWe have an array for string $k:'$s0':\n";
+ foreach ($s1 as $sv)
+ echo " * ", $sv, "\n";
+
+ echo "\nThis can't be inserted into this .lang file. Fix this upstream and come back.\n\n";
+ exit(1);
+ }
+ $s1 = str_replace("\n", ' ', $s1);
+ $s1 = preg_replace('/\s+/', ' ', $s1);
+ $s1 = str_replace("\'", "'", $s1);
+
+ $f[] = '';
+ $f[] = ';' . $s0;
+ $f[] = $s1;
+ $f[] = "\n";
+ }
+
+ echo " ok\n";
+ $files[$k] = implode("\n", $f);
+}
+
+echo "Saving those into ...\n";
+foreach ($files as $k => $data) {
+ $file = str_replace('{LOC}', $k, $dest);
+// file_put_contents($file, $data);
+}
+
+echo "Done.\n";
+exit(0); \ No newline at end of file
diff --git a/tools/rebuild_gettext_catalogs.sh b/tools/rebuild_gettext_catalogs.sh
new file mode 100755
index 000000000..1c7b9e34e
--- /dev/null
+++ b/tools/rebuild_gettext_catalogs.sh
@@ -0,0 +1,149 @@
+#!/bin/bash
+# Filip Komar, 2014
+# @license GPL v2
+# @author Filip (rebuilding a gettext dictionaries)
+# @copyright 2014/03
+# inspired by check_for_translation_work.sh
+
+error=0
+declare -A resources
+declare -A errors
+if [ -f ./tools/web_projects.dat ]; then
+ source ./tools/web_projects.dat
+else
+ echo Critical error!!! It was not possible to load web projects database!
+fi
+
+for resource in "${!resources[@]}"
+do
+ difference=
+ if [ "$resource" = "mognase" ]; then # is it about navigation?
+ path_and_filename=./_nav/langs/en
+ else
+ path_and_filename=./langs/en/$resource
+ fi
+ if [ -f $path_and_filename.pot ]; then # do a temporary copy
+ cp $path_and_filename.pot $path_and_filename.copy
+ fi
+ php_source=${resources[$resource]}
+ php tools/extract2gettext.php "$php_source" $resource true
+ php_error_level=$? # catch php error level
+ errors[$php_source]=$php_error_level
+ if [ -f $path_and_filename.pot ]; then
+ # msgmerge check of generated pot file
+ msgmerge --quiet --no-wrap $path_and_filename.pot $path_and_filename.pot --output-file=$path_and_filename.tmp
+ msgmerge_error_level=$? # catch msgmerge error level
+ if [ $msgmerge_error_level -gt 0 ]; then # on failure stop the process for this resource
+ errors[$php_source]=$msgmerge_error_level
+ rm $path_and_filename.tmp
+ fi
+ if [ -f $path_and_filename.copy ] && [ -f $path_and_filename.tmp ]; then
+ diff --ignore-matching-lines='^"POT-Creation-Date:' $path_and_filename.tmp $path_and_filename.copy
+ if [ $? -eq 1 ]; then # there are differences
+ errors[$php_source]=0
+ mv $path_and_filename.tmp $path_and_filename.pot
+ rm $path_and_filename.copy
+ echo Changes in $path_and_filename.pot
+ else # Cleanup as there are no changes in $resource
+ errors[$php_source]=5
+ rm $path_and_filename.tmp
+ mv $path_and_filename.copy $path_and_filename.pot
+ difference=none
+ fi
+ else # diff not possible
+ if [ -f $path_and_filename.tmp ]; then
+ mv $path_and_filename.tmp $path_and_filename.pot
+ if [ -f $path_and_filename.copy ]; then
+ rm $path_and_filename.copy
+ fi
+ else
+ rm $path_and_filename.pot
+ if [ -f $path_and_filename.copy ]; then
+ mv $path_and_filename.copy $path_and_filename.pot
+ difference=none
+ fi
+ fi
+ fi
+ if [ "$resource" = "mognase" ]; then # is it about navigation?
+ # create po files if needed from lang files if available
+ if [ -f ./_nav/langs/en.lang ]; then
+ python tools/translated_converter.py --filename ./_nav/langs/
+ python_error_level=$? # catch python error level
+ if [ $python_error_level -gt 0 ]; then
+ errors[$resource]=50
+ fi
+ if [ -f ./_nav/langs/en.po ]; then
+ rm ./_nav/langs/en.po
+ fi
+ fi
+
+ for tr_file in ./_nav/langs/*.po
+ do
+ if [ -z $difference ]; then # update po file if needed
+# msgfmt --statistics --verbose -c $tr_file -o /dev/null # usefull for debuging (msgctxt "/web/en/ or msgctxt "en/)
+ echo merging $tr_file
+ msgmerge --quiet --no-wrap $tr_file ./_nav/langs/en.pot --output-file=$tr_file.tmp
+ msgmerge_error_level=$? # catch msgmerge error level
+ if [ $msgmerge_error_level -gt 0 ]; then
+ errors[$directory/$resource]=60
+ echo "$directory"/$resource.po could not be created succesfully
+ if [ -f $tr_file.tmp ]; then
+ rm $tr_file.tmp
+ fi
+ else
+ mv $tr_file.tmp $tr_file
+# msgfmt --statistics --verbose -c $tr_file -o /dev/null # usefull for debuging (msgctxt "/web/en/ or msgctxt "en/)
+ fi
+ fi
+ done
+ else
+ for directory in ./langs/*
+ do
+ # in each language directory except source
+ if [ -d $directory/ ] && [ $directory != ./langs/en ]; then
+ # create po file if needed from lang file if available
+ if [ ! -f $directory/$resource.po ] && [ -f $directory/$resource.*.lang ]; then
+# echo $directory # usefull for debuging of non UTF-8 files or other python errors
+ python tools/translated_converter.py --filename $directory/$resource
+ python_error_level=$? # catch python error level
+ if [ $python_error_level -gt 0 ]; then
+ errors[$directory/$resource]=50
+ fi
+ fi
+ if [ -f $directory/$resource.po ] && [ -z $difference ]; then # update po file if it exists
+# msgfmt --statistics --verbose -c $directory/$resource.po -o /dev/null # usefull for debuging (msgctxt "/web/en/ or msgctxt "en/)
+ echo merging $directory/$resource.po
+ msgmerge --quiet --no-wrap $directory/$resource.po ./langs/en/$resource.pot --output-file=$directory/$resource.tmp
+ msgmerge_error_level=$? # catch msgmerge error level
+ if [ $msgmerge_error_level -gt 0 ]; then
+ errors[$directory/$resource]=60
+ echo "$directory"/$resource.po could not be created succesfully
+ if [ -f $tr_file.tmp ]; then
+ rm $directory/$resource.tmp
+ fi
+ else
+ mv $directory/$resource.tmp $directory/$resource.po
+# msgfmt --statistics --verbose -c $directory/$resource.po -o /dev/null # usefull for debuging (msgctxt "/web/en/ or msgctxt "en/)
+ fi
+ fi
+ fi
+ done
+ fi
+ fi
+done
+
+echo ''
+#printf "%s\n" "${errors[@]}"
+for error_in_source in "${!errors[@]}"
+do
+ case ${errors[$error_in_source]} in
+ 0) echo "Done lookup for _g() and _r() in $error_in_source. Gettext catalogs (pot files) rebuilded. Existing po files updated." ;;
+ 1) echo "Unkown error!!" ;;
+ 5) echo "There are no changes in $error_in_source." ;;
+ 10) echo "No strings to save from $error_in_source!" ;;
+ 20) echo "!!!! Parse error, please fix $error_in_source first !!!! See details above." ;;
+ 30) echo "!!!! Failed to write $error_in_source !!!! See details above." ;;
+ 50) echo "!!!! Script translated_converter.py encounter an error in $error_in_source !!!!" ;;
+ 60) echo "$error_in_source.po could not be created succesfully!! Duplicates?" ;;
+ esac
+done
diff --git a/tools/translated_converter.py b/tools/translated_converter.py
new file mode 100644
index 000000000..568e3fb43
--- /dev/null
+++ b/tools/translated_converter.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# This file is free software. It come without any warranty, to the extent
+# permitted by applicable law. You can redistribute it and/or modify them under
+# the terms of the Do What The Fuck You Want To Public License, Version 2, as
+# published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details.
+
+# author yurchor
+# http://gitweb.mageia.org/software/i18n/tools/tree/websites
+# adaptation by filip
+
+import errno, glob, polib, re, os, getopt, sys
+from time import strftime
+
+def usage():
+ print '\nUsage: python %s [OPTION]' %os.path.basename(sys.argv[0])
+ print ' generates po file for existing lang translations'
+ print 'Options: -h, --help : usage'
+ print ' -f filename, --filename filename : target filename'
+ sys.exit(2)
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "hf:", ["help", "filename="])
+except getopt.GetoptError:
+ usage() # print help information and exit
+
+filename=''
+for o,a in opts:
+ if o in ("-h", "--help"):
+ usage()
+ if o in ("-f", "--filename"):
+ filename=a
+
+if filename == '':
+ sys.exit('No filename given')
+
+def po_append(message_id, message_str, langfile):
+ # Strip ';' from msgid
+ message_id = message_id.lstrip(';')
+ if message_str == message_id:
+ message_str=''
+ message_str = message_str.replace('{ok}', '').rstrip()
+ potentry = polib.POEntry(
+ msgid = message_id.decode('utf-8'),
+ msgstr = message_str.decode('utf-8'),
+ occurrences=[(langfile,'')]
+ )
+ po.append(potentry)
+
+file_mask = filename + '.*.lang'
+if filename == './_nav/langs/':
+ file_mask = './_nav/langs/*.lang'
+for langfile in glob.glob(file_mask):
+# print langfile # useful for debuging
+ nofilename = langfile.replace(filename + '.','')
+ language = nofilename.replace('.lang','')
+ language = language.replace('./_nav/langs/','')
+ #open lang file
+ text = open(langfile,"r").read()+"\n"
+ #Remove trailing spaces from lines
+ spaces=' {1,}\n'
+ spattern=re.compile(spaces,re.DOTALL)
+ for emptyline in spattern.findall(text):
+ text = text.replace(emptyline,'\n')
+ text = text.replace('\n\n','\n\n\n\n')+'\n'
+
+ # Write PO file
+ po = polib.POFile(wrapwidth=999) # increase default wrap limit
+ pocreationtime = strftime('%Y-%m-%d %H:%M%z')
+ po.metadata = {
+ 'Project-Id-Version': langfile,
+ 'Report-Msgid-Bugs-To': 'mageia-i18n@mageia.org',
+ 'POT-Creation-Date': pocreationtime,
+ 'PO-Revision-Date': pocreationtime,
+ 'Last-Translator': 'Duffy Duck <d_duck@nowhere.net>',
+ 'Language-Team': 'LANGUAGE <LL@li.org>',
+ 'Language': language,
+ 'MIME-Version': '1.0',
+ 'Content-Type': 'text/plain; charset=UTF-8',
+ 'Content-Transfer-Encoding': '8bit',
+ }
+
+ # Parse contents and add them to PO
+ messagetemplate='\n\n#\ .*?\n\n'
+ mpattern=re.compile(messagetemplate,re.DOTALL)
+ for mblock in mpattern.findall(text):
+ message_comment, message_text = mblock.strip('\n').split('\n;',1)
+ # Strip '# ' from comments
+ message_comment = message_comment.lstrip('# ')
+ message_id, message_str = message_text.split('\n',1)
+# print message_id # useful for debuging
+ po_append(message_id, message_str, langfile)
+ messagetemplate='\n\n;.*?\n\n'
+ mpattern=re.compile(messagetemplate,re.DOTALL)
+ for mblock in mpattern.findall(text):
+ message_id, message_str = mblock.strip('\n').split('\n',1)
+# print message_id # useful for debuging
+ po_append(message_id, message_str, langfile)
+ if text[0] == ';':
+ message_id, message_str = text.partition('\n\n')[0].strip('\n').split('\n',1)
+# print message_id # useful for debuging
+ po_append(message_id, message_str, langfile)
+ if filename == './_nav/langs/':
+ file_name = filename + language
+ else:
+ file_name = filename
+ po.save(file_name + '.po')
diff --git a/tools/update-mirrors-list.php b/tools/update-mirrors-list.php
new file mode 100644
index 000000000..d9be85226
--- /dev/null
+++ b/tools/update-mirrors-list.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Run this to update lib/cached.list.php mirrors list from mirrors.mageia.org/api
+ *
+*/
+
+require __DIR__ . '/../lib/Downloads.php';
+Downloads::get_all_mirrors(false); \ No newline at end of file
diff --git a/tools/web_projects.dat b/tools/web_projects.dat
new file mode 100644
index 000000000..189974ed2
--- /dev/null
+++ b/tools/web_projects.dat
@@ -0,0 +1,25 @@
+resources[about/code-of-conduct]="en/about/code-of-conduct/index.php"
+resources[about/constitution]="en/about/constitution/index.php"
+resources[about/license]="en/about/license/index.php"
+resources[about/media]="en/about/media/index.php"
+resources[about/reports]="en/about/reports/index.php"
+resources[about/values]="en/about/values/index.php"
+resources[downloads/get]="en/downloads/get/index.php"
+resources[2]="en/2/download_index.php en/2/for-pc/index.php en/2/for-server/index.php en/2/index.php en/2/nav.php"
+resources[3]="en/3/download_index.php en/3/for-pc/index.php en/3/for-server/index.php en/3/index.php en/3/nav.php"
+resources[4]="en/4/download_index.php en/4/nav.php en/4/index.php"
+resources[cauldron]="en/5/download_index.php en/5/nav.php en/5/index.php"
+resources[404]="404.php"
+resources[about]="en/about/index.php"
+resources[calendar]="en/calendar/index.php"
+resources[community]="en/community/index.php"
+resources[contact]="en/contact/index.php"
+resources[contribute]="en/contribute/index.php"
+resources[documentation]="en/doc/index.php en/doc/archive.php en/doc/doc.php"
+resources[donate]="en/donate/index.php"
+resources[index]="en/index.php"
+resources[map]="en/map/index.php"
+resources[support]="en/support/index.php"
+resources[thank-you]="en/thank-you/index.php"
+resources[timeline]="en/timeline/index.php"
+resources[mognase]="_nav/lib.php"