Skip to content

Commit

Permalink
MDL-21693 Dropping _utf8 suffix from language codes and folder names;…
Browse files Browse the repository at this point in the history
… enabling new string managers - please note the transition is not yet fully complete because we need to wait for git to recognize the renames in cvs
  • Loading branch information
skodak committed Apr 10, 2010
1 parent 4bf0c0b commit 3a915b0
Show file tree
Hide file tree
Showing 847 changed files with 2,249 additions and 2,448 deletions.
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For more information, see the INSTALL DOCUMENTATION:

A local copy can also be found in

lang/en_utf8/help/install.html (or your language)
lang/en/help/install.html (or your language)


Good luck and have fun!
Expand Down
26 changes: 13 additions & 13 deletions admin/cli/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

// set up configuration
$CFG = new stdClass();
$CFG->lang = 'en_utf8';
$CFG->lang = 'en';
$CFG->dirroot = str_replace('\\', '/', dirname(dirname(dirname(__FILE__)))); // Fix for win32
$CFG->libdir = "$CFG->dirroot/lib";
$CFG->wwwroot = "http://localhost";
Expand All @@ -114,6 +114,8 @@
$CFG->docroot = 'http://docs.moodle.org';
$CFG->directorypermissions = 00777;
$CFG->running_installer = true;
$CFG->early_install_lang = true;

$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
$CFG->admin = array_pop($parts);

Expand Down Expand Up @@ -170,10 +172,6 @@
$lang = clean_param($options['lang'], PARAM_SAFEDIR);
if (file_exists($CFG->dirroot.'/install/lang/'.$lang)) {
$CFG->lang = $lang;
} else {
if (file_exists($CFG->dirroot.'/install/lang/'.$lang.'_utf8')) {
$CFG->lang = $lang.'_utf8';
}
}

if ($unrecognized) {
Expand Down Expand Up @@ -205,23 +203,23 @@
$langlist .= "\n";
}
}
$default = str_replace('_utf8', '', $CFG->lang);
$default = $CFG->lang;
cli_heading(get_string('availablelangs', 'install'));
echo $langlist."\n";
$prompt = get_string('clitypevaluedefault', 'admin', $default);
$prompt = get_string('clitypevaluedefault', 'admin', $CFG->lang);
$error = '';
do {
echo $error;
$input = cli_input($prompt, $default);
$input = clean_param($input, PARAM_SAFEDIR);

if (!file_exists($CFG->dirroot.'/install/lang/'.$input.'_utf8')) {
if (!file_exists($CFG->dirroot.'/install/lang/'.$input)) {
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
} else {
$error = '';
}
} while ($error !== '');
$CFG->lang = $input.'_utf8';
$CFG->lang = $input;
} else {
// already selected and verified
}
Expand Down Expand Up @@ -314,12 +312,12 @@
}

//download lang pack with optional notification
if ($CFG->lang != 'en_utf8') {
if ($cd = new component_installer('http://download.moodle.org', 'lang16', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
if ($CFG->lang != 'en') {
if ($cd = new component_installer('http://download.moodle.org', 'lang20', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
if ($cd->install() == COMPONENT_ERROR) {
if ($cd->get_error() == 'remotedownloaderror') {
$a = new stdClass();
$a->url = 'http://download.moodle.org/lang16/'.$CFG->lang.'.zip';
$a->url = 'http://download.moodle.org/lang20/'.$CFG->lang.'.zip';
$a->dest = $CFG->dataroot.'/lang';
cli_problem(get_string($cd->get_error(), 'error', $a));
} else {
Expand All @@ -328,14 +326,16 @@
} else {
// install parent lang if defined
if ($parentlang = get_parent_language()) {
if ($cd = new component_installer('http://download.moodle.org', 'lang16', $parentlang.'.zip', 'languages.md5', 'lang')) {
if ($cd = new component_installer('http://download.moodle.org', 'lang20', $parentlang.'.zip', 'languages.md5', 'lang')) {
$cd->install();
}
}
}
}
}

$CFG->early_install_lang = false;

// ask for db type - show only drivers available
if ($interactive) {
$options['dbtype'] = strtolower($options['dbtype']);
Expand Down
48 changes: 21 additions & 27 deletions admin/langimport.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php
///This file only manages the installation of 1.6 lang packs.
///in downloads.moodle.org, they are store in separate directory /lang16
///This file only manages the installation of 2.0 lang packs.
///in downloads.moodle.org, they are store in separate directory /lang20
///in local server, they are stored in $CFG->dataroot/lang
///This helps to avoid confusion.

die('Work in progress, to be replaced by the new language update interface...');

require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/filelib.php');
Expand Down Expand Up @@ -60,15 +62,15 @@
}

foreach ($packs as $pack) {
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
if ($cd = new component_installer('http://download.moodle.org', 'lang20',
$pack.'.zip', 'languages.md5', 'lang')) {
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
switch ($status) {

case COMPONENT_ERROR:
if ($cd->get_error() == 'remotedownloaderror') {
$a = new object();
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
$a->url = 'http://download.moodle.org/lang20/'.$pack.'.zip';
$a->dest= $CFG->dataroot.'/lang';
print_error($cd->get_error(), 'error', 'langimport.php', $a);
} else {
Expand All @@ -80,7 +82,7 @@
$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')) {
if ($cd = new component_installer('http://download.moodle.org', 'lang20', $parentlang.'.zip', 'languages.md5', 'lang')) {
$cd->install();
}
}
Expand All @@ -99,8 +101,8 @@

case DELETION_OF_SELECTED_LANG: //delete a directory(ies) containing a lang pack completely

if ($uninstalllang == 'en_utf8') {
$notice_error[] = 'en_utf8 can not be uninstalled!';
if ($uninstalllang == 'en') {
$notice_error[] = 'en can not be uninstalled!';

} else if (!$confirm && confirm_sesskey()) {
echo $OUTPUT->header();
Expand Down Expand Up @@ -139,7 +141,7 @@
$md5array = array();
$updated = 0; //any packs updated?
$alllangs = array_keys(get_list_of_languages(false, true)); //get all available langs
$lang16 = array(); //all the Moodle 1.6 unicode lang packs (updated and not updated)
$lang20 = array(); //all the Moodle 1.6 unicode lang packs (updated and not updated)
$packs = array(); //all the packs that needs updating


Expand All @@ -162,12 +164,12 @@
$dest2 = $CFG->dirroot.'/lang/'.$clang;

if (file_exists($dest1.'/langconfig.php') || file_exists($dest2.'/langconfig.php')){
$lang16[] = $clang;
$lang20[] = $clang;
}
}

//then filter out packs that have the same md5 key
foreach ($lang16 as $clang) {
foreach ($lang20 as $clang) {
if (!is_installed_lang($clang, $md5array[$clang])){
$packs[] = $clang;
}
Expand All @@ -176,7 +178,7 @@
@mkdir ($CFG->dataroot.'/temp/', $CFG->directorypermissions);
@mkdir ($CFG->dataroot.'/lang/', $CFG->directorypermissions);
foreach ($packs as $pack){ //for each of the remaining in the list, we
if ($pack == 'en_utf8') { // no update for en_utf8
if ($pack == 'en') { // no update for en
continue;
}

Expand All @@ -201,15 +203,15 @@

//2. copy & unzip into new

if ($cd = new component_installer('http://download.moodle.org', 'lang16',
if ($cd = new component_installer('http://download.moodle.org', 'lang20',
$pack.'.zip', 'languages.md5', 'lang')) {
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
switch ($status) {

case COMPONENT_ERROR:
if ($cd->get_error() == 'remotedownloaderror') {
$a = new stdClass();
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
$a->url = 'http://download.moodle.org/lang20/'.$pack.'.zip';
$a->dest= $CFG->dataroot.'/lang';
print_error($cd->get_error(), 'error', "", $a); // not probable
} else {
Expand Down Expand Up @@ -251,7 +253,7 @@
foreach($installedlangs as $l=>$unused) {
$SESSION->lang = $l;
$parent = get_string('parentlanguage');
if ($parent == 'en_utf8') {
if ($parent == 'en') {
continue;
}
if (strpos($parent, '[[') !== false) {
Expand Down Expand Up @@ -297,11 +299,7 @@
$a->parent = $parent;
foreach ($availablelangs as $alang) {
if ($alang[0] == $parent) {
if (substr($alang[0], -5) == '_utf8') { //Remove the _utf8 suffix from the lang to show
$shortlang = substr($alang[0], 0, -5);
} else {
$shortlang = $alang[0];
}
$shortlang = $alang[0];
$a->parent = $alang[2].' ('.$shortlang.')';
}
}
Expand Down Expand Up @@ -359,18 +357,14 @@
if ($alang[0] == '') {
continue;
}
if (trim($alang[0]) != "en_utf8") {
if (trim($alang[0]) != "en") {
if ($remote) {
if (substr($alang[0], -5) == '_utf8') { //Remove the _utf8 suffix from the lang to show
$shortlang = substr($alang[0], 0, -5);
} else {
$shortlang = $alang[0];
}
$shortlang = $alang[0];
if (!is_installed_lang($alang[0], $alang[1])){ //if not already installed
echo '<option value="'.$alang[0].'">'.$alang[2].' ('.$shortlang.')</option>';
}
} else { //print list in local format, and instruction to install
echo '<tr><td>'.$alang[2].'</td><td><a href="http://download.moodle.org/lang16/'.$alang[0].'.zip">'.get_string('download','admin').'</a></td></tr>';
echo '<tr><td>'.$alang[2].'</td><td><a href="http://download.moodle.org/lang20/'.$alang[0].'.zip">'.get_string('download','admin').'</a></td></tr>';
}
$empty = 0;
}
Expand Down Expand Up @@ -433,7 +427,7 @@ function is_installed_lang($lang, $md5check) {
* @return array or false if can not download
*/
function get_remote_list_of_languages() {
$source = 'http://download.moodle.org/lang16/languages.md5';
$source = 'http://download.moodle.org/lang20/languages.md5';
$availablelangs = array();

if ($content = download_file_content($source)) {
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 or en_utf8 is in setup.php
$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_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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion course/format/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Standard files
Configuration file, mainly controlling default blocks for the format.
See existing formats for examples.

* yourformat/lang/en_utf8/format_yourformat.php
* yourformat/lang/en/format_yourformat.php

Language file containing basic language strings for your format. Here
is a minimal language file:
Expand Down
2 changes: 1 addition & 1 deletion course/format/topics/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package
*/
//TODO (nfreear): Accessibility: evaluation, lang/en_utf8/moodle.php: $string['formattopicscss']
//TODO (nfreear): Accessibility: evaluation, lang/en/moodle.php: $string['formattopicscss']

require_once($CFG->libdir.'/filelib.php');

Expand Down
2 changes: 1 addition & 1 deletion course/format/weeks/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package
*/
//TODO (nfreear): Accessibility: evaluation, lang/en_utf8/moodle.php: $string['formatweekscss']
//TODO (nfreear): Accessibility: evaluation, lang/en/moodle.php: $string['formatweekscss']

require_once($CFG->libdir.'/filelib.php');

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions filter/multilang/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ function filter($text) {
function multilang_filter_impl($langblock) {
global $CFG;

$mylang = str_replace('_utf8', '', current_language());
$mylang = current_language();
static $parentcache;
if (!isset($parentcache)) {
$parentcache = array();
}
if (!array_key_exists($mylang, $parentcache)) {
$parentlang = str_replace('_utf8', '', get_string('parentlanguage'));
$parentlang = get_string('parentlanguage');
$parentcache[$mylang] = $parentlang;
} else {
$parentlang = $parentcache[$mylang];
Expand All @@ -91,7 +91,7 @@ function multilang_filter_impl($langblock) {

$langlist = array();
foreach ($rawlanglist[1] as $index=>$lang) {
$lang = str_replace('_utf8', '', str_replace('-','_',strtolower($lang))); // normalize languages
$lang = str_replace('-','_',strtolower($lang)); // normalize languages
$langlist[$lang] = $rawlanglist[2][$index];
}

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 3a915b0

Please sign in to comment.