diff --git a/.env b/.env index 48550caa89..fbc7d86839 100644 --- a/.env +++ b/.env @@ -3,11 +3,11 @@ ###> doctrine/doctrine-bundle ### # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url -DATABASE_HOST="{{DATABASE_HOST}}" -DATABASE_PORT="{{DATABASE_PORT}}" -DATABASE_NAME="{{DATABASE_NAME}}" -DATABASE_USER="{{DATABASE_USER}}" -DATABASE_PASSWORD="{{DATABASE_PASSWORD}}" +DATABASE_HOST='{{DATABASE_HOST}}' +DATABASE_PORT='{{DATABASE_PORT}}' +DATABASE_NAME='{{DATABASE_NAME}}' +DATABASE_USER='{{DATABASE_USER}}' +DATABASE_PASSWORD='{{DATABASE_PASSWORD}}' ###< doctrine/doctrine-bundle ### ###> symfony/swiftmailer-bundle ### @@ -19,35 +19,35 @@ MAILER_PORT='' ###< symfony/swiftmailer-bundle ### ###> symfony/framework-bundle ### -APP_ENV=dev -APP_DEBUG=1 -APP_SECRET=141af65f23c7935a37b504c422f113b0 +APP_ENV='dev' +APP_DEBUG='1' +APP_SECRET='141af65f23c7935a37b504c422f113b0' ###< symfony/framework-bundle ### ###> chamilo ### -APP_INSTALLED={{APP_INSTALLED}} +APP_INSTALLED='{{APP_INSTALLED}}' ## Encrypt method bcrypt/sha1/md5 -APP_ENCRYPT_METHOD={{APP_ENCRYPT_METHOD}} +APP_ENCRYPT_METHOD='{{APP_ENCRYPT_METHOD}}' -APP_LOCALE=en +APP_LOCALE='en' ## Example: '/chamilo2' -APP_URL_APPEND="{{APP_URL_APPEND}}" +APP_URL_APPEND='{{APP_URL_APPEND}}' -APP_MULTIPLE_ACCESS_URL="" +APP_MULTIPLE_ACCESS_URL='' ###< chamilo ### ###> hwi/oauth-bundle ### -FB_ID= -FB_SECRET= +FB_ID='' +FB_SECRET='' -GITHUB_ID= -GITHUB_SECRET= +GITHUB_ID='' +GITHUB_SECRET='' -GOOGLE_ID= -GOOGLE_SECRET= +GOOGLE_ID='' +GOOGLE_SECRET='' ###< hwi/oauth-bundle ### diff --git a/main/inc/lib/extra_field.lib.php b/main/inc/lib/extra_field.lib.php index 2fa23d1bce..838c5bc0ff 100755 --- a/main/inc/lib/extra_field.lib.php +++ b/main/inc/lib/extra_field.lib.php @@ -161,7 +161,9 @@ class ExtraField extends Model $this->pageUrl = 'extra_fields.php?type='.$this->type; // Example QuestionFields - $this->pageName = get_lang(ucwords($this->type).'Fields'); + // @todo + //$this->pageName = get_lang(ucwords($this->type).'Fields'); + $this->pageName = ucwords($this->type).'Fields'; } /** diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 9d67357854..407f729589 100755 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -17,14 +17,8 @@ use Westsworld\TimeAgo; * * @package chamilo.library */ - -// Special tags for marking untranslated variables. -define('SPECIAL_OPENING_TAG', '[='); -define('SPECIAL_CLOSING_TAG', '=]'); - // Predefined date formats in Chamilo provided by the language sub-system. // To be used as a parameter for the function api_format_date() - define('TIME_NO_SEC_FORMAT', 0); // 15:23 define('DATE_FORMAT_SHORT', 1); // Aug 25, 09 define('DATE_FORMAT_LONG', 2); // Monday August 25, 09 @@ -75,9 +69,9 @@ function get_lang($variable) // Using symfony $defaultDomain = 'messages'; - $locale = api_get_interface_language(); + $locale = api_get_language_isocode(); - $translated = Container::getTranslator()->trans( + $translated = $translator->trans( $variable, [], $defaultDomain, @@ -86,7 +80,7 @@ function get_lang($variable) if ($translated === $variable) { // Check the langVariable for BC - $translated = Container::getTranslator()->trans( + $translated = $translator->trans( "lang$variable", [], $defaultDomain, @@ -143,11 +137,16 @@ function api_purify_language_id($language) } /** - * Gets language isocode. + * Gets language iso code. */ function api_get_language_isocode() { - return Container::getRequest()->getLocale(); + $request = Container::getRequest(); + if ($request) { + return $request->getLocale(); + } + + return 'en'; } /** @@ -158,18 +157,18 @@ function api_get_language_isocode() * */ function api_get_platform_isocodes() { - $iso_code = []; + $list = []; $sql = "SELECT isocode FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)." ORDER BY isocode "; - $sql_result = Database::query($sql); - if (Database::num_rows($sql_result)) { - while ($row = Database::fetch_array($sql_result)) { - $iso_code[] = trim($row['isocode']); + $result = Database::query($sql); + if (Database::num_rows($result)) { + while ($row = Database::fetch_array($result)) { + $list[] = trim($row['isocode']); } } - return $iso_code; + return $list; } /** diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index b1343f0fbf..bcd42f795e 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -186,8 +186,6 @@ class UserManager ) { $authSource = !empty($authSource) ? $authSource : PLATFORM_AUTH_SOURCE; $creatorId = empty($creatorId) ? api_get_user_id() : 0; - $creatorInfo = api_get_user_info($creatorId); - $creatorEmail = isset($creatorInfo['email']) ? $creatorInfo['email'] : ''; $hook = Container::instantiateHook(HookCreateUser::class); if (!empty($hook)) { diff --git a/main/install/index.php b/main/install/index.php index c772fdc1f7..d03c771fb7 100755 --- a/main/install/index.php +++ b/main/install/index.php @@ -713,7 +713,7 @@ $poweredBy = 'Powered by Chami ?> - — <?php echo get_lang('Chamilo installation').' — '.get_lang('Version').' '.$new_version; ?> + — <?php echo $translator->trans('Chamilo installation').' — '.$translator->trans('Version').' '.$new_version; ?> @@ -742,7 +742,7 @@ $poweredBy = 'Powered by Chami //Blocking step6 button $("#button_step6").click(function() { $("#button_step6").hide(); - $("#button_please_wait").html(''); + $("#button_please_wait").html('trans('Continue')); ?>'); $("#button_please_wait").show(); $("#button_please_wait").attr('disabled', true); $("#is_executable").attr("value",'step6'); @@ -752,12 +752,12 @@ $poweredBy = 'Powered by Chami if ($("#id_contact_form").css("display") == "none") { $("#id_contact_form").css("display","block"); $("#img_plus_and_minus").html( - '  ' + '  trans('Contact information'); ?>' ); } else { $("#id_contact_form").css("display","none"); $("#img_plus_and_minus").html( - '  ' + '  trans('Contact information'); ?>' ); } }); @@ -765,7 +765,7 @@ $poweredBy = 'Powered by Chami function send_contact_information() { if (!document.getElementById('accept_licence').checked) { - alert('') + alert('trans('You must accept the licence'); ?>') ;return false; } else { var data_post = ""; @@ -790,11 +790,11 @@ $poweredBy = 'Powered by Chami data: data_post, success: function(datos) { if (datos == 'required_field_error') { - message = ""; + message = "trans('The form contains incorrect or incomplete data. Please check your input.'); ?>"; } else if (datos == '1') { - message = ""; + message = "trans('Contact informationHasBeenSent'); ?>"; } else { - message = ""; + message = "trans('Error').': '.$translator->trans('Contact informationHasNotBeenSent'); ?>"; } alert(message); $('#license-next').trigger('click'); @@ -805,7 +805,7 @@ $poweredBy = 'Powered by Chami } - +
diff --git a/main/install/install.lib.php b/main/install/install.lib.php index 7990a6175a..c66ed17bec 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -1803,15 +1803,21 @@ function display_configuration_settings_form( */ function display_after_install_message() { - $html = '
'.get_lang('When you enter your portal for the first time, the best way to understand it is to create a course with the \'Create course\' link in the menu and play around a little.').'
'; + $container = Container::$container; + + $trans = $container->get('translator'); + $html = '
'. + $trans->trans( + 'When you enter your portal for the first time, the best way to understand it is to create a course with the \'Create course\' link in the menu and play around a little.').'
'; $html .= '
'; - $html .= ''.get_lang('Security advice').''; + $html .= ''.$trans->trans('Security advice').''; $html .= ': '; - $html .= sprintf(get_lang('To protect your site, make the whole %s directory read-only (chmod -R 0555 on Linux) and delete the %s directory.'), 'app/config/', 'main/install/'); + $html .= sprintf($trans->trans( + 'To protect your site, make the whole %s directory read-only (chmod -R 0555 on Linux) and delete the %s directory.'), 'var/config/', 'main/install/'); $html .= '

- '.get_lang('Go to your newly created portal.').' + '.$trans->trans('Go to your newly created portal.').' '; return $html; @@ -3163,13 +3169,15 @@ function finishInstallationWithContainer( $manager->persist($ticketProject); $manager->flush(); + $trans = $container->get('translator'); + $categories = [ - get_lang('Enrollment') => get_lang('Tickets about enrollment'), - get_lang('General information') => get_lang('Tickets about general information'), - get_lang('Requests and paperwork') => get_lang('Tickets about requests and paperwork'), - get_lang('Academic Incidents') => get_lang('Tickets about academic incidents, like exams, practices, tasks, etc.'), - get_lang('Virtual campus') => get_lang('Tickets about virtual campus'), - get_lang('Online evaluation') => get_lang('Tickets about online evaluation'), + $trans->trans('Enrollment') => $trans->trans('Tickets about enrollment'), + $trans->trans('General information') => $trans->trans('Tickets about general information'), + $trans->trans('Requests and paperwork') => $trans->trans('Tickets about requests and paperwork'), + $trans->trans('Academic Incidents') => $trans->trans('Tickets about academic incidents, like exams, practices, tasks, etc.'), + $trans->trans('Virtual campus') => $trans->trans('Tickets about virtual campus'), + $trans->trans('Online evaluation') => $trans->trans('Tickets about online evaluation'), ]; $i = 1; @@ -3194,9 +3202,9 @@ function finishInstallationWithContainer( // Default Priorities $defaultPriorities = [ - TicketManager::PRIORITY_NORMAL => get_lang('Normal'), - TicketManager::PRIORITY_HIGH => get_lang('High'), - TicketManager::PRIORITY_LOW => get_lang('Low'), + TicketManager::PRIORITY_NORMAL => $trans->trans('Normal'), + TicketManager::PRIORITY_HIGH => $trans->trans('High'), + TicketManager::PRIORITY_LOW => $trans->trans('Low'), ]; $i = 1; @@ -3217,11 +3225,11 @@ function finishInstallationWithContainer( // Default status $defaultStatus = [ - TicketManager::STATUS_NEW => get_lang('New'), - TicketManager::STATUS_PENDING => get_lang('Pending'), - TicketManager::STATUS_UNCONFIRMED => get_lang('Unconfirmed'), - TicketManager::STATUS_CLOSE => get_lang('Close'), - TicketManager::STATUS_FORWARDED => get_lang('Forwarded'), + TicketManager::STATUS_NEW => $trans->trans('New'), + TicketManager::STATUS_PENDING => $trans->trans('Pending'), + TicketManager::STATUS_UNCONFIRMED => $trans->trans('Unconfirmed'), + TicketManager::STATUS_CLOSE => $trans->trans('Close'), + TicketManager::STATUS_FORWARDED => $trans->trans('Forwarded'), ]; $i = 1; diff --git a/src/CoreBundle/Framework/Container.php b/src/CoreBundle/Framework/Container.php index 5fb794eabe..91f6663dab 100644 --- a/src/CoreBundle/Framework/Container.php +++ b/src/CoreBundle/Framework/Container.php @@ -205,6 +205,10 @@ class Container */ public static function getRequest() { + if (self::$container === null) { + return null; + } + if (!empty(self::$request)) { return self::$request; } @@ -213,7 +217,7 @@ class Container } /** - * @param $request + * @param Request $request */ public static function setRequest($request) { diff --git a/src/CoreBundle/Settings/LanguageSettingsSchema.php b/src/CoreBundle/Settings/LanguageSettingsSchema.php index bed0cef783..085e2848df 100644 --- a/src/CoreBundle/Settings/LanguageSettingsSchema.php +++ b/src/CoreBundle/Settings/LanguageSettingsSchema.php @@ -26,10 +26,10 @@ class LanguageSettingsSchema extends AbstractSettingsSchema 'allow_use_sub_language' => 'false', 'auto_detect_language_custom_pages' => 'true', 'show_different_course_language' => 'true', - 'language_priority_1' => '', - 'language_priority_2' => '', - 'language_priority_3' => '', - 'language_priority_4' => '', + 'language_priority_1' => 'platform_lang', + 'language_priority_2' => 'platform_lang', + 'language_priority_3' => 'platform_lang', + 'language_priority_4' => 'platform_lang', 'hide_dltt_markup' => 'false', 'show_language_selector_in_menu' => 'true', ]