Skip to content

Commit

Permalink
MDL-22059 fixing install_string_manager to work with new installer la…
Browse files Browse the repository at this point in the history
…nguage formats
  • Loading branch information
skodak committed Apr 11, 2010
1 parent 9c496b5 commit d8fa5a1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
4 changes: 3 additions & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
$CFG->dataroot = $config->dataroot;
$CFG->admin = $config->admin;
$CFG->docroot = 'http://docs.moodle.org';
$CFG->langotherroot = $CFG->dataroot.'/lang';
$CFG->langlocalroot = $CFG->dataroot.'/lang';
$CFG->directorypermissions = 00777;
$CFG->running_installer = true;
$CFG->early_install_lang = true;
Expand Down Expand Up @@ -362,7 +364,7 @@
if ($cd->install() == COMPONENT_ERROR) {
if ($cd->get_error() == 'remotedownloaderror') {
$a = new stdClass();
$a->url = 'http://download.moodle.org/lang20/'.$INSTALL['language'].'.zip';
$a->url = 'http://download.moodle.org/lang20/'.$config->lang.'.zip';
$a->dest = $CFG->dataroot.'/lang';
$downloaderror = get_string($cd->get_error(), 'error', $a);
} else {
Expand Down
42 changes: 33 additions & 9 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -6038,13 +6038,39 @@ public function __construct() {
* @return string The String !
*/
public function get_string($identifier, $component = '', $a = NULL) {
if (!$component) {
$component = 'moodle';
}
$lang = current_language();

//get parent lang
$parent = '';
if ($lang !== 'en' and $identifier !== 'parentlanguage' and $component !== 'langconfig') {
if (file_exists("$this->installroot/$lang/langconfig.php")) {
$string = array();
include("$this->installroot/$lang/langconfig.php");
if (isset($string['parentlanguage'])) {
$parent = $string['parentlanguage'];
}
unset($string);
}
}

// include en string first
if (!file_exists("$this->installroot/en/$component.php")) {
return "[[$identifier]]";
}
$string = array();
include("$this->installroot/en/installer.php");
include("$this->installroot/en/$component.php");

// now override en with parent if defined
if ($parent and $parent !== 'en' and file_exists("$this->installroot/$parent/$component.php")) {
include("$this->installroot/$parent/$component.php");
}

if (file_exists("$this->installroot/$lang/installer.php") and $lang !== 'en') {
include("$this->installroot/$lang/installer.php");
// finally override with requested language
if ($lang !== 'en' and file_exists("$this->installroot/$lang/$component.php")) {
include("$this->installroot/$lang/$component.php");
}

if (!isset($string[$identifier])) {
Expand All @@ -6063,16 +6089,14 @@ public function get_string($identifier, $component = '', $a = NULL) {
// we do not support numeric keys - sorry!
continue;
}
$search[] = '$a->'.$key.'';
//$search[] = '{$a->'.$key.'}'; // TODO: uncomment after switch to {a->aa}
$search[] = '{$a->'.$key.'}';
$replace[] = (string)$value;
}
if ($search) {
$string = str_replace($search, $replace, $string);
}
} else {
$string = str_replace('$a', (string)$a, $string);
//$string = str_replace('{$a}', (string)$a, $string); // TODO: uncomment after switch to {a}
$string = str_replace('{$a}', (string)$a, $string);
}
}

Expand All @@ -6099,9 +6123,9 @@ public function get_list_of_languages($returnall = false) {
asort($langdirs);
// Get some info from each lang
foreach ($langdirs as $lang) {
if (file_exists($this->installroot.'/'.$lang.'/installer.php')) {
if (file_exists($this->installroot.'/'.$lang.'/langconfig.php')) {
$string = array();
include($this->installroot.'/'.$lang.'/installer.php');
include($this->installroot.'/'.$lang.'/langconfig.php');
if (!empty($string['thislanguage'])) {
$languages[$lang] = $string['thislanguage'].' ('.$lang.')';
}
Expand Down

0 comments on commit d8fa5a1

Please sign in to comment.