We all need it, But it doesn't exists yet.I need a list of all the strings I have to translate.
function InterceptLangCode($Code){
//$Application = GetDumpDispatcherValue('_ApplicationFolder');
//if(True || $Application){
$Application = 'garden';
//$ControllerName = '';
//[_ControllerName:private] => plugin
//[_ControllerMethod:private] => loadup
$LocalePath = PATH_APPLICATIONS.'/'.$Application.'/locale/TR/';
if(!is_dir($LocalePath)) mkdir($LocalePath, 0777, True);
if(!file_exists($LocalePath.'definitions.php')){
file_put_contents($LocalePath.'definitions.php', "<?php if (!defined('APPLICATION')) exit();\n\n");
}
// PATH_ROOT
include $LocalePath.'definitions.php';
if(Empty($Definition)) $Definition = array();
if(!array_key_exists($Code, $Definition)){
$Code = str_replace('\'', '\\\'', $Code);
$S = "\$Definition['$Code'] = '$Code';\n";
$Trace = debug_backtrace();
$CountTrace = Count($Trace);
for($i = 0; $i < $CountTrace; $i++){
$TraceInfo = $Trace[$i];
if($TraceInfo['function'] != 'Translate') continue;
if(array_key_exists('file', $TraceInfo)){
$File = str_replace('\\', '/', str_replace(PATH_ROOT, '', $TraceInfo['file']));
$File = str_replace('.php', '', $File);
$C = file_get_contents($LocalePath.'definitions.php');
//$FilePattern = preg_quote($File, '/');
if(!strpos($C, $File)) $S = "// $File\n$S";
//$S = "// $File\n$S";
break;
}
}
file_put_contents($LocalePath.'definitions.php', $S, FILE_APPEND);
}
//}
}function GetDumpDispatcherValue($Name){
$Dump = print_r($GLOBALS['Dispatcher'], True);
if(preg_match('/\['.$Name.':private\] \=\> (\w+)/', $Dump, $Matches)) return $Matches[1];
}
public static function Translate($Code, $Default = '') {
if ($Default == '')
$Default = $Code;
InterceptLangCode($Code); // <-- hack
return Gdn::Locale()->Translate($Code, $Default);
}
Plural you should make locale dependent (like FormatPossessive()), because there are languages which have more than one plural form of a word, and this form depends of number for this word.echo sprintf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments);<?php if (!defined('APPLICATION')) exit();
$Definition['Apply for Membership'] = "Register Now!";
$Definition['Sign In'] = 'Login'; $Definition['ErrorCredentials'] = "z.B. ü";It looks like you're new here. If you want to get involved, click one of these buttons!