diff --git a/api/LocaleAPI.php b/api/LocaleAPI.php
index 26cdbead6..00518e71d 100755
--- a/api/LocaleAPI.php
+++ b/api/LocaleAPI.php
@@ -1,12 +1,16 @@
";
-
+
//Calculate base directory
$baseDir = Director::baseFolder();
@@ -19,12 +23,12 @@ class LocaleAPI extends Controller {
} else {
LocaleAPI::processModule($baseDir, $_GET['module']);
}
-
+
echo "Done!";
-
+
}
- private static function processModule($baseDir, $module) {
+ private static function processModule($baseDir, $module) {
if(is_dir("$baseDir/$module") && !in_array($module, array('sapphire','jsparty','assets')) && substr($module,0,1) != '.') {
LocaleAPI::getFilesRec("$baseDir/$module/code", $fileList);
foreach($fileList as $index => $file) {
@@ -41,13 +45,13 @@ class LocaleAPI extends Controller {
if(!file_exists($baseDir. '/' . $module . '/lang')) {
mkdir($langFolder);
}
-
+
// Open the English file and write the Master String Table
if($fh = fopen($langFolder . '/en.php', "w")) {
- fwrite($fh, "");
+ fwrite($fh, "");
fclose($fh);
echo "Created file: $langFolder/en.php
";
-
+
} else {
die("Cannot write language file! Please check permissions of $langFolder/en.php");
}
@@ -64,9 +68,9 @@ class LocaleAPI extends Controller {
else if(is_dir("$folder/$item")) LocaleAPI::getFilesRec("$folder/$item", $fileList);
}
}
-
+
/**
- * Look for calls to the underscore function and build our MST
+ * Look for calls to the underscore function and build our MST
*/
private static function reportCallsCode($index, $file) {
static $callMap;
@@ -75,13 +79,13 @@ class LocaleAPI extends Controller {
$class = ($regs[1] == '__FILE__' ? $index : $regs[1]);
$entity = substr($regs[2],2,-1);
-
+
if ($callMap[$class.'--'.$entity]) echo "Warning! Redeclaring entity $entity in file $file
";
$mst .= '$lang[\'en\'][\'' . $class . '\'][\'' . substr($regs[2],2,-1) . '\'] = ';
if ($regs[4]) {
$mst .= "array(\n\t'" . substr($regs[3],2,-1) . "',\n\t" . substr($regs[4],1);
- if ($regs[5]) $mst .= ",\n\t'" . substr($regs[5],2,-1) . '\'';
+ if ($regs[5]) $mst .= ",\n\t'" . substr($regs[5],2,-1) . '\'';
$mst .= "\n);";
} else $mst .= '\'' . substr($regs[3],2,-1) . '\';';
$mst .= "\n";
@@ -89,12 +93,12 @@ class LocaleAPI extends Controller {
$callMap[$class.'--'.$entity] = $regs[3];
}
-
+
return $mst;
}
/**
- * Look for calls to the underscore function and build our MST
+ * Look for calls to the underscore function and build our MST
* Template version - no "class" argument
*/
private static function reportCallsTpl($index, $file) {
@@ -103,13 +107,13 @@ class LocaleAPI extends Controller {
while (ereg('_\(([^$][^,"\']*|"[^,]*"|\'[^,]*\')(,[^$][^,)]*)(,[^,)]*)?(,[^)]*)?\)',$content,$regs)) {
$entity = substr($regs[1],2,-1);
-
+
if ($callMap[$index.'--'.$entity]) echo "Warning! Redeclaring entity $entity in file $file
";
$mst .= '$lang[\'en\'][\'' . $index . '\'][\'' . substr($regs[1],1,-1) . '\'] = ';
if ($regs[3]) {
$mst .= "array(\n\t'" . substr($regs[2],2,-1) . "',\n\t" . substr($regs[3],1);
- if ($regs[4]) $mst .= ",\n\t'" . substr($regs[4],2,-1) . '\'';
+ if ($regs[4]) $mst .= ",\n\t'" . substr($regs[4],2,-1) . '\'';
$mst .= "\n);";
} else $mst .= '\'' . substr($regs[2],2,-1) . '\';';
$mst .= "\n";
@@ -117,7 +121,7 @@ class LocaleAPI extends Controller {
$callMap[$index.'--'.$entity] = $regs[3];
}
-
+
return $mst;
}
@@ -127,19 +131,19 @@ class LocaleAPI extends Controller {
static function getLocale() {
return LocaleAPI::$currentlocale;
}
-
+
/**
* Includes all available language files for a certain defined locale
*/
static function includeByLocale($locale) {
$topLevel = scandir(Director::baseFolder());
foreach($topLevel as $module) {
- if (file_exists($file = Director::getAbsFile("$module/lang/$locale.php"))) {
+ if (file_exists($file = Director::getAbsFile("$module/lang/$locale.php"))) {
include_once($file);
}
}
}
-
+
/**
* Given a class name (a "locale namespace"), will search for its module and, if available,
* will load the resources for the currently defined locale.