Can also sync alternatives languages from transifex now.
This commit is contained in:
parent
5cc48c7c78
commit
927925f4fd
54
dev/fixaltlanguages.sh
Executable file
54
dev/fixaltlanguages.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
# Recursively deduplicate file lines on a per file basis
|
||||
# Useful to deduplicate language files
|
||||
#
|
||||
# Needs awk 4.0 for the inplace fixing command
|
||||
#
|
||||
# Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr
|
||||
|
||||
# Syntax
|
||||
if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
|
||||
then
|
||||
echo "Scan alternate language files and remove entries found into parent file"
|
||||
echo "Usage: fixaltlanguages.sh (list|fix) (all|file.lang) [xx_XX]"
|
||||
exit
|
||||
fi
|
||||
if [ "x$2" = "x" ]
|
||||
then
|
||||
echo "Scan alternate language files and remove entries found into parent file"
|
||||
echo "Usage: fixaltlanguages.sh (list|fix) (all|file.lang) [xx_XX]"
|
||||
exit
|
||||
fi
|
||||
|
||||
# To detect
|
||||
if [ "x$1" = "xlist" ]
|
||||
then
|
||||
echo Feature not available
|
||||
fi
|
||||
|
||||
# To fix
|
||||
if [ "x$1" = "xfix" ]
|
||||
then
|
||||
for dir in `find htdocs/langs/$3* -type d`
|
||||
do
|
||||
dirshort=`basename $dir`
|
||||
#echo $dirshort
|
||||
|
||||
export aa=`echo $dirshort | nawk -F"_" '{ print $1 }'`
|
||||
export bb=`echo $dirshort | nawk -F"_" '{ print $2 }'`
|
||||
aaupper=`echo $dirshort | nawk -F"_" '{ print toupper($1) }'`
|
||||
bblower=`echo $dirshort | nawk -F"_" '{ print tolower($2) }'`
|
||||
if [ "$aa" != "$bblower" ]
|
||||
then
|
||||
reflang="htdocs/langs/"$aa"_"$aaupper
|
||||
if [ -d $reflang ]
|
||||
then
|
||||
echo "***** Process language "$aa"_"$bb" - Search original into "$reflang
|
||||
echo $dirshort est une langue alternative de $reflang
|
||||
echo ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2
|
||||
./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2
|
||||
for fic in `ls htdocs/langs/${aa}_${bb}/*.delta`; do f=`echo $fic | sed -e 's/\.delta//'`; echo $f; mv $f.delta $f; done
|
||||
fi
|
||||
fi
|
||||
done;
|
||||
fi
|
||||
@ -25,7 +25,7 @@
|
||||
*
|
||||
* Usage:
|
||||
* cd htdocs/langs
|
||||
* ../../dev/translation/strip_language_file.php <primary_lang_dir> <secondary_lang_dir> [file.lang|all]
|
||||
* ./dev/translation/strip_language_file.php <primary_lang_dir> <secondary_lang_dir> [file.lang|all]
|
||||
*
|
||||
* To rename all .delta files, you can do
|
||||
* for fic in `ls *.delta`; do f=`echo $fic | sed -e 's/\.delta//'`; echo $f; mv $f.delta $f; done
|
||||
@ -66,7 +66,7 @@ if (empty($lPrimary) || empty($lSecondary) || empty($filesToProcess))
|
||||
{
|
||||
$rc = 1;
|
||||
$msg = '***** Script to clean language files *****'."\n";
|
||||
$msg.= 'Usage: ../../dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
|
||||
$msg.= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
|
||||
print $msg . "(rc=$rc).\n";
|
||||
exit($rc);
|
||||
}
|
||||
@ -77,7 +77,7 @@ $aSecondary = array();
|
||||
// Define array $filesToProcess
|
||||
if ($filesToProcess == 'all')
|
||||
{
|
||||
$dir = new DirectoryIterator($lPrimary);
|
||||
$dir = new DirectoryIterator('htdocs/langs/'.$lPrimary);
|
||||
while($dir->valid()) {
|
||||
if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./',$dir->getFilename())) {
|
||||
$files[] = $dir->getFilename();
|
||||
@ -94,8 +94,8 @@ else $filesToProcess=explode(',',$filesToProcess);
|
||||
// Loop on each file
|
||||
foreach($filesToProcess as $fileToProcess)
|
||||
{
|
||||
$lPrimaryFile = $lPrimary.'/'.$fileToProcess;
|
||||
$lSecondaryFile = $lSecondary.'/'.$fileToProcess;
|
||||
$lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess;
|
||||
$lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess;
|
||||
$output = $lSecondaryFile . '.delta';
|
||||
|
||||
print "---- Process language file ".$lSecondaryFile."\n";
|
||||
@ -270,8 +270,8 @@ foreach($filesToProcess as $fileToProcess)
|
||||
|
||||
print "Output can be found at $output.\n";
|
||||
|
||||
print "To rename all .delta files, you can do\n";
|
||||
print 'for fic in `ls *.delta`; do f=`echo $fic | sed -e \'s/\.delta//\'`; echo $f; mv $f.delta $f; done'."\n";
|
||||
print "To rename all .delta files, you can do:\n";
|
||||
print '> for fic in `ls htdocs/langs/'.$lSecondary.'/*.delta`; do f=`echo $fic | sed -e \'s/\.delta//\'`; echo $f; mv $f.delta $f; done'."\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user