Skip to content

Commit

Permalink
MDL-17573 added automatic downloading of parent languages
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 8, 2009
1 parent c33b83e commit 07f6711
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions admin/langimport.php
Expand Up @@ -78,6 +78,12 @@

case COMPONENT_INSTALLED:
$notice_ok[] = get_string('langpackinstalled','admin',$pack);
if ($parentlang = get_parent_language($pack)) {
// install also parent pack if specified
if ($cd = new component_installer('http://download.moodle.org', 'lang16', $parentlang.'.zip', 'languages.md5', 'lang')) {
$cd->install();
}
}
break;

case COMPONENT_UPTODATE:
Expand Down
22 changes: 20 additions & 2 deletions lib/moodlelib.php
Expand Up @@ -5144,13 +5144,31 @@ function current_language() {

/**
* Returns parent language of current active language if defined
* @param string $lang null means current language
* @return string
*/
function get_parent_language() {
function get_parent_language($lang=null) {
global $COURSE, $SESSION;

//let's hack around the current language
if (!empty($lang)) {
$old_course_lang = empty($COURSE->lang) ? '' : $COURSE->lang;
$old_session_lang = empty($SESSION->lang) ? '' : $SESSION->lang;
$COURSE->lang = '';
$SESSION->lang = $lang;
}

$parentlang = get_string('parentlanguage');
if ($parentlang === '[[parentlanguage]]' or strpos($parentlang, '<') !== false) {
return '';
$parentlang = '';
}

//let's hack around the current language
if (!empty($lang)) {
$COURSE->lang = $old_course_lang;
$SESSION->lang = $old_session_lang;
}

return $parentlang;
}

Expand Down

0 comments on commit 07f6711

Please sign in to comment.