-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathlanglink.php
84 lines (71 loc) · 1.98 KB
/
langlink.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
function translateWinPath($p_path)
{
if (stristr(php_uname(), 'windows')) {
// ----- Change potential windows directory separator
if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
$p_path = strtr($p_path, '\\', '/');
}
$p_path = strtr($p_path, '/','\\');
}
return $p_path;
}
function doTheHippyHippyShake($root, $target)
{
echo "$root\n";
foreach(new DirectoryIterator($root) as $oArea) {
if(!$oArea->isDir()) continue;
if($oArea->isDot()) continue;
$area = $oArea->getFilename();
$areaDir = $root.'/'.$area;
echo "\t$area\n";
foreach(new DirectoryIterator($areaDir) as $oModule)
{
if(!$oModule->isDir()) continue;
if($oModule->isDot()) continue;
$module = $oModule->getFilename();
echo "\t\t$module";
$moduleDir = $areaDir.'/'.$module;
$from = $target.'/'.$area.'/'.$module.'/en-GB';
$to = $moduleDir.'/language/en-GB';
if(!is_dir($from)) {
// Some things may be untranslated
echo "\tNot translated\n";
continue;
}
if (stristr(php_uname(), 'windows') && is_dir($from)) {
if(file_exists($to)) {
if(!@unlink($to)) {
echo "\tCannot remove old link\n";
continue;
}
}
} elseif(is_link($to)) {
if(!@unlink($to)) {
echo "\tCannot remove old link\n";
continue;
}
} elseif(is_dir($to)) {
// Let's do it The Hard Way™
$cmd = 'rm -rf "'.$to.'"';
exec($cmd);
echo "\tHard Way™";
}
if (stristr(php_uname(), 'windows') && is_dir($from)) {
$f = translateWinPath($from);
$t = translateWinPath($to);
$cmd = 'mklink /D "'.$to.'" "'.$from.'"';
exec($cmd);
} else {
@symlink($from, $to);
}
echo "\tLINKED\n";
}
}
}
$root = dirname(__FILE__).'/modules';
$target = dirname(__FILE__).'/translations/modules';
doTheHippyHippyShake($root, $target);
$root = dirname(__FILE__).'/plugins';
$target = dirname(__FILE__).'/translations/plugins';
doTheHippyHippyShake($root, $target);