Permalink
Browse files

Merge branch 'hotfix/localedeveloper'

  • Loading branch information...
2 parents 1f63b71 + 829b90e commit cb60303703387111725b9e1d4ab5f37be9d6a02d @kaecyra kaecyra committed May 22, 2012
Showing with 20 additions and 18 deletions.
  1. +1 −1 library/core/class.configuration.php
  2. +19 −17 library/core/class.locale.php
@@ -904,7 +904,7 @@ public static function ParseString($String, $Name) {
// Parse the string
if (!empty($String)) {
- $String = str_replace(array('<?php','<?','?>'), '', $String);
+ $String = trim(str_replace(array('<?php','<?','?>'), '', $String));
$Parsed = eval($String);
if ($Parsed === FALSE)
return FALSE;
@@ -37,23 +37,12 @@ class Gdn_Locale extends Gdn_Pluggable {
*/
public $DeveloperContainer = NULL;
+ public $SavedDeveloperCalls = 0;
+
public function __construct($LocaleName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping = FALSE) {
parent::__construct();
$this->ClassName = 'Gdn_Locale';
- // Prepare developer mode if needed
- $this->DeveloperMode = C('Garden.Locales.DeveloperMode', FALSE);
- if ($this->DeveloperMode) {
- $this->DeveloperContainer = new Gdn_Configuration();
- $this->DeveloperContainer->Splitting(FALSE);
- $this->DeveloperContainer->Caching(FALSE);
-
- $DeveloperCodeFile = PATH_CACHE."/locale-developer.php";
- if (!file_exists($DeveloperCodeFile))
- touch($DeveloperCodeFile);
- $this->DeveloperContainer->Load($DeveloperCodeFile, 'Definition', TRUE);
- }
-
$this->Set($LocaleName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping);
}
@@ -91,10 +80,10 @@ public function SaveTranslations($Translations, $LocaleName = FALSE) {
* automatically force a remapping.
*/
public function Set($LocaleName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping = FALSE) {
-
// Get locale sources
$this->Locale = $LocaleName;
$LocaleSources = $this->GetLocaleSources($LocaleName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping);
+
if (!is_array($LocaleSources))
$LocaleSources = array();
@@ -112,6 +101,20 @@ public function Set($LocaleName, $ApplicationWhiteList, $PluginWhiteList, $Force
if (file_exists($ConfLocaleOverride))
$this->LocaleContainer->Load($ConfLocaleOverride, 'Definition', TRUE);
+ // Prepare developer mode if needed
+ $this->DeveloperMode = C('Garden.Locales.DeveloperMode', FALSE);
+ if ($this->DeveloperMode) {
+ $this->DeveloperContainer = new Gdn_Configuration();
+ $this->DeveloperContainer->Splitting(FALSE);
+ $this->DeveloperContainer->Caching(FALSE);
+
+ $DeveloperCodeFile = PATH_CACHE."/locale-developer-{$LocaleName}.php";
+ if (!file_exists($DeveloperCodeFile))
+ touch($DeveloperCodeFile);
+
+ $this->DeveloperContainer->Load($DeveloperCodeFile, 'Definition', TRUE);
+ }
+
// Import core (static) translations
if ($this->DeveloperMode)
$this->DeveloperContainer->MassImport($this->LocaleContainer->Get('.'));
@@ -230,7 +233,6 @@ public function SetTranslation($Code, $Translation = '', $Save = FALSE) {
* @return string
*/
public function Translate($Code, $Default = FALSE) {
-
if ($Default === FALSE)
$Default = $Code;
@@ -245,7 +247,7 @@ public function Translate($Code, $Default = FALSE) {
if ($this->DeveloperMode && $Translation == $Default) {
$DevKnows = $this->DeveloperContainer->Get($Code, FALSE);
if ($DevKnows === FALSE)
- $this->DeveloperContainer->SaveToConfig($Code, $Translation);
+ $this->DeveloperContainer->SaveToConfig($Code, $Default);
}
return $Translation;
@@ -255,7 +257,6 @@ public function Translate($Code, $Default = FALSE) {
* Clears out the currently loaded locale settings.
*/
public function Unload() {
-
// If we're unloading, don't save first
if ($this->LocaleContainer instanceof Gdn_Configuration)
$this->LocaleContainer->AutoSave(FALSE);
@@ -302,4 +303,5 @@ public function GetDeveloperDefinitions() {
return $this->DeveloperContainer->Get('.');
}
+
}

0 comments on commit cb60303

Please sign in to comment.