Skip to content

Commit

Permalink
MDL-22084 making a clear distinction between list of our translations…
Browse files Browse the repository at this point in the history
… and list of all languages defined in ISO 639-2
  • Loading branch information
skodak committed Apr 14, 2010
1 parent b2ad1a3 commit 1f96e90
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 48 deletions.
2 changes: 1 addition & 1 deletion admin/cli/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
//Fist select language
if ($interactive) {
cli_separator();
$languages = get_list_of_languages();
$languages = get_string_manager()->get_list_of_translations();
// format the langs nicely - 3 per line
$c = 0;
$langlist = '';
Expand Down
5 changes: 0 additions & 5 deletions admin/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,6 @@
}
mtrace('Finished admin reports');

if (!empty($CFG->langcache)) {
mtrace('Updating languages cache');
get_list_of_languages(true);
}

mtrace('Removing expired enrolments ...', ''); // See MDL-8785
$timenow = time();
$somefound = false;
Expand Down
8 changes: 4 additions & 4 deletions admin/langimport.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
if (file_exists($CFG->dataroot.'/cache/languages')) {
print_error('cannotdeletelangcache', 'error');
}
get_list_of_languages(true); //refresh lang cache
//TODO: refresh lang cache

$notice_ok = array();
$notice_error = array();
Expand Down Expand Up @@ -123,7 +123,7 @@
if (file_exists($dest2)){
$rm2 = remove_dir($dest2);
}
get_list_of_languages(true); //refresh lang cache
//TODO: refresh lang cache
//delete the direcotries
if ($rm1 or $rm2) {
$notice_ok[] = get_string('langpackremoved','admin');
Expand All @@ -140,7 +140,7 @@
//key = langname, value = md5
$md5array = array();
$updated = 0; //any packs updated?
$alllangs = array_keys(get_list_of_languages(false, true)); //get all available langs
$alllangs = array_keys(get_string_manager()->get_list_of_translations(true)); //get all available langs
$lang20 = array(); //all the Moodle 1.6 unicode lang packs (updated and not updated)
$packs = array(); //all the packs that needs updating

Expand Down Expand Up @@ -245,7 +245,7 @@

echo $OUTPUT->header();

$installedlangs = get_list_of_languages(true, true);
$installedlangs = get_string_manager()->get_list_of_translations(true);

$missingparents = array();
$oldlang = isset($SESSION->lang) ? $SESSION->lang : null; // override current lang
Expand Down
2 changes: 1 addition & 1 deletion admin/settings/courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
$temp->add(new admin_setting_heading('language', get_string('language'), ''));
$languages=array();
$languages[''] = get_string('forceno');
$languages += get_list_of_languages();
$languages += get_string_manager()->get_list_of_translations();
$temp->add(new admin_setting_configselect('moodlecourse/lang', get_string('forcelanguage'), '',key($languages),$languages));

if (!empty($CFG->enablecompletion)) {
Expand Down
2 changes: 1 addition & 1 deletion admin/settings/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// "languageandlocation" settingpage
$temp = new admin_settingpage('langsettings', get_string('languagesettings', 'admin'));
$temp->add(new admin_setting_configcheckbox('autolang', get_string('autolang', 'admin'), get_string('configautolang', 'admin'), 1));
$temp->add(new admin_setting_configselect('lang', get_string('lang', 'admin'), get_string('configlang', 'admin'), current_language(), get_list_of_languages())); // $CFG->lang might be set in installer already, default en is in setup.php
$temp->add(new admin_setting_configselect('lang', get_string('lang', 'admin'), get_string('configlang', 'admin'), current_language(), get_string_manager()->get_list_of_translations())); // $CFG->lang might be set in installer already, default en is in setup.php
$temp->add(new admin_setting_configcheckbox('langmenu', get_string('langmenu', 'admin'), get_string('configlangmenu', 'admin'), 1));
$temp->add(new admin_setting_langlist());
$temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('configlangcache', 'admin'), 1));
Expand Down
2 changes: 1 addition & 1 deletion admin/uploaduser_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function definition (){
$mform->setDefault('timezone', $templateuser->timezone);
$mform->setAdvanced('timezone');

$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages());
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
$mform->setDefault('lang', $templateuser->lang);
$mform->setAdvanced('lang');

Expand Down
2 changes: 1 addition & 1 deletion backup/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2848,7 +2848,7 @@ function restore_create_users($restore,$xml_file) {
if (!empty($userids)) {

/// Get languages for quick search later
$languages = get_list_of_languages();
$languages = get_string_manager()->get_list_of_translations();

/// Iterate over all users loaded from xml
$counter = 0;
Expand Down
2 changes: 1 addition & 1 deletion course/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function definition() {

$languages=array();
$languages[''] = get_string('forceno');
$languages += get_list_of_languages();
$languages += get_string_manager()->get_list_of_translations();
$mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
$mform->setDefault('lang', $courseconfig->lang);

Expand Down
2 changes: 1 addition & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@
get_string('chooselanguagesub', 'install'));
}

$languages = get_list_of_languages();
$languages = get_string_manager()->get_list_of_translations();
echo '<div class="userinput">';
echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
Expand Down
2 changes: 1 addition & 1 deletion lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3517,7 +3517,7 @@ public function __construct() {
*/
public function write_setting($data) {
$return = parent::write_setting($data);
get_list_of_languages(true);//refresh the list
//TODO: reset lang cache
return $return;
}
}
Expand Down
14 changes: 14 additions & 0 deletions lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ function auth_get_plugin_title($authtype) {
return get_string('pluginname', "auth_{$authtype}");
}

/**
* Was returning list of translations, use new string_manager instead
*
* @deprecated
* @param bool $refreshcache force refreshing of lang cache
* @param bool $returnall ignore langlist, return all languages available
* @return array An associative array with contents in the form of LanguageCode => LanguageName
*/
function get_list_of_languages($refreshcache=false, $returnall=false) {
if ($refreshcache) {
// TODO: reset lang cache
}
return get_string_manager()->get_list_of_translations($returnall);
}

/**
* @deprecated
Expand Down
38 changes: 10 additions & 28 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ function clean_param($param, $type) {

case PARAM_LANG:
$param = clean_param($param, PARAM_SAFEDIR);
$langs = get_list_of_languages(false, true);
$langs = get_string_manager()->get_list_of_translations(true);
if (in_array($param, $langs)) {
return $param;
} else {
Expand Down Expand Up @@ -3296,8 +3296,8 @@ function create_user_record($username, $password, $auth='manual') {
// fix for MDL-8480
// user CFG lang for user if $newuser->lang is empty
// or $user->lang is not an installed language
$sitelangs = array_keys(get_list_of_languages());
if (empty($newuser->lang) || !in_array($newuser->lang, $sitelangs)) {
$sitelangs = get_string_manager()->get_list_of_translations();
if (empty($newuser->lang) || !isset($sitelangs[$newuser->lang])) {
$newuser->lang = $CFG->lang;
}
$newuser->confirmed = 1;
Expand Down Expand Up @@ -5722,10 +5722,10 @@ public function string_exists($identifier, $component);
public function get_list_of_countries();

/**
* Returns localised list of installed languages
* Returns localised list of installed translations
* @param bool $returnall return all or just enabled
*/
public function get_list_of_languages($returnall = false);
public function get_list_of_translations($returnall = false);

/**
* Load all strings for one component
Expand Down Expand Up @@ -5996,10 +5996,10 @@ public function get_list_of_countries() {
}

/**
* Returns localised list of installed languages
* Returns localised list of installed translations
* @param bool $returnall return all or just enabled
*/
public function get_list_of_languages($returnall = false) {
public function get_list_of_translations($returnall = false) {
global $CFG;

$languages = array();
Expand Down Expand Up @@ -6190,10 +6190,10 @@ public function get_list_of_countries() {
}

/**
* Returns localised list of installed languages
* Returns localised list of installed translations
* @param bool $returnall return all or just enabled
*/
public function get_list_of_languages($returnall = false) {
public function get_list_of_translations($returnall = false) {
// return all is ignored here - we need to know all langs in installer
$languages = array();
// Get raw list of lang directories
Expand Down Expand Up @@ -6344,24 +6344,6 @@ function print_string($identifier, $component = '', $a = NULL) {
echo get_string($identifier, $component, $a);
}

/**
* Returns a list of language codes and their full names
* hides the _local files from everyone.
*
* @global object
* @param bool $refreshcache force refreshing of lang cache
* @param bool $returnall ignore langlist, return all languages available
* @return array An associative array with contents in the form of LanguageCode => LanguageName
*/
function get_list_of_languages($refreshcache=false, $returnall=false) {

if ($refreshcache) {
// TODO: reimplement caching?; this may not be necessary if we implement lang pack precompilation in dataroot
}

return get_string_manager()->get_list_of_languages($returnall);
}

/**
* Returns a list of charset codes
*
Expand Down Expand Up @@ -9109,7 +9091,7 @@ function setup_lang_from_browser() {
}
krsort($langs, SORT_NUMERIC);

$langlist = get_list_of_languages();
$langlist = get_string_manager()->get_list_of_translations();

/// Look for such langs under standard locations
foreach ($langs as $lang) {
Expand Down
2 changes: 1 addition & 1 deletion lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public function lang_menu() {
}

$currlang = current_language();
$langs = get_list_of_languages();
$langs = get_string_manager()->get_list_of_translations();

if (count($langs) < 2) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion user/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function useredit_shared_definition(&$mform, $editoroptions = null) {
$mform->setDefault('timezone', '99');
}

$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages());
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
$mform->setDefault('lang', $CFG->lang);

if (!empty($CFG->allowuserthemes)) {
Expand Down
2 changes: 1 addition & 1 deletion user/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function create_users($users) {
unset($availableauths['webservice']); // we do not want new webservice users for now

$availablethemes = get_plugin_list('theme');
$availablelangs = get_list_of_languages();
$availablelangs = get_string_manager()->get_list_of_translations();

$transaction = $DB->start_delegated_transaction();

Expand Down

0 comments on commit 1f96e90

Please sign in to comment.