Skip to content

Commit

Permalink
Force loading the default administrator language
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 committed Feb 14, 2016
1 parent 2fc17a3 commit be6c91a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
27 changes: 27 additions & 0 deletions administrator/components/com_languages/controllers/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,31 @@ public function setDefault()
$clientId = $model->getState('filter.client_id');
$this->setredirect('index.php?option=com_languages&view=installed&client=' . $clientId, $msg, $type);
}

/**
* Task to force loading the default administrator language.
*
* @return void
*/
public function forceAdminLanguage()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JInvalid_Token'));

$model = $this->getModel('installed');

if ($model->force())
{
$msg = JText::_('COM_LANGUAGES_MSG_DEFAULT_LANGUAGE_FORCED');
$type = 'message';
}
else
{
$msg = $this->getError();
$type = 'error';
}

$clientId = $model->getState('filter.client_id');
$this->setredirect('index.php?option=com_languages&view=installed&client=' . $clientId, $msg, $type);
}
}
26 changes: 26 additions & 0 deletions administrator/components/com_languages/models/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,30 @@ protected function compareLanguages($lang1, $lang2)
{
return strcmp($lang1->name, $lang2->name);
}

/**
* Method to force loading the default administrator language.
*
* @return boolean
*
* @since 3.5
*/
public function force()
{
$language = JComponentHelper::getParams('com_languages')->get('administrator','en-GB');
$client = $this->getClient();

if ($client->name == 'administrator')
{
JFactory::getApplication()->setUserState('application.lang', $language);
}
else
{
$this->setError(JText::_('COM_LANGUAGES_ERR_DEFAULT_LANGUAGE_NOT_FORCED'));

return false;
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ protected function addToolbar()
$bar->appendButton('Link', 'upload', 'COM_LANGUAGES_INSTALL', 'index.php?option=com_installer&view=languages');
JToolbarHelper::divider();

// Force administrator language
if ($this->state->get('filter.client_id', 0) == 1)
{
JToolbarHelper::custom('installed.forceadminlanguage', 'refresh', 'refresh', 'COM_LANGUAGES_FORCE_ADMIN', false);
JToolbarHelper::divider();
}

JToolbarHelper::preferences('com_languages');
JToolbarHelper::divider();
}
Expand Down
3 changes: 3 additions & 0 deletions administrator/language/en-GB/en-GB.com_languages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ COM_LANGUAGES_ERR_DELETE="Select a language to delete"
COM_LANGUAGES_ERR_NO_LANGUAGE_SELECTED="No language selected."
COM_LANGUAGES_ERROR_LANG_TAG="<br />The Language Tag should contain 2 or 3 lowercase letters corresponding to the ISO language, a dash and 2 uppercase letters corresponding to the ISO country code. <br />This should be the exact prefix used for the language installed or to be installed. Example: en-GB, srp-ME."
COM_LANGUAGES_ERR_PUBLISH="Select a language to publish."
COM_LANGUAGES_ERR_DEFAULT_LANGUAGE_NOT_FORCED="Could not force loading the default Administrator Language."
COM_LANGUAGES_FIELD_DESCRIPTION_DESC="Enter a description for the language."
COM_LANGUAGES_FIELD_IMAGE_DESC="Prefix of the image file for this language when using the &quot;Use image flags&quot; Language Switcher basic option. Example: if 'en' is chosen, then the image will be en.gif. Images and CSS for this module are in media/mod_languages/."
COM_LANGUAGES_FIELD_IMAGE_LABEL="Image Prefix"
COM_LANGUAGES_FIELD_LANG_TAG_DESC="Enter the language tag – example: en-GB for English (UK). This should be the exact prefix used for the language installed or to be installed."
COM_LANGUAGES_FIELD_LANG_TAG_LABEL="Language Tag"
COM_LANGUAGES_FORCE_ADMIN="Force Administrator Language"
COM_LANGUAGES_INSTALL="Install Language"
COM_LANGUAGES_OVERRIDE_ERROR_RESERVED_WORDS="YES, NO, NULL, FALSE, ON, OFF, NONE, TRUE are reserved words and can't be used as language constants."
COM_LANGUAGES_OVERRIDE_FIELD_BOTH_LABEL="For both locations"
Expand Down Expand Up @@ -53,6 +55,7 @@ COM_LANGUAGES_HEADING_LANGUAGE="Language"
COM_LANGUAGES_HEADING_TITLE_NATIVE="Native Title"
COM_LANGUAGES_HOMEPAGE="Home"
COM_LANGUAGES_MSG_DEFAULT_LANGUAGE_SAVED="Default Language Saved. This does not affect users that have chosen a specific language on their profile or on the login page.<br /><strong class="_QQ_"red"_QQ_">Warning!</strong> When using the multilingual functionality (ie when the plugin System - Languagefilter is enabled) the Site Default Language has to also be a published Content language."
COM_LANGUAGES_MSG_DEFAULT_LANGUAGE_FORCED="The default Administrator Language was successfully loaded."
COM_LANGUAGES_MULTILANGSTATUS_CONTACTS_ERROR="Some of the contacts linked to the user <strong>%s</strong> are incorrect."
COM_LANGUAGES_MULTILANGSTATUS_CONTACTS_ERROR_TIP="Warning! A user/author should have only one contact to which is assigned language 'All' OR one contact for each published Content Language."
COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_PUBLISHED="Published Content Languages"
Expand Down

0 comments on commit be6c91a

Please sign in to comment.