Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unpublished Content Language on Language Package Install #11867

Merged
merged 24 commits into from
Oct 1, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6fbfee8
initial commit
andrepereiradasilva Aug 31, 2016
57f4926
Update language.php
andrepereiradasilva Aug 31, 2016
1cb7f1f
Update en-GB.lib_joomla.ini
andrepereiradasilva Aug 31, 2016
3dc390b
Update en-GB.lib_joomla.ini
andrepereiradasilva Aug 31, 2016
9902f77
ups
andrepereiradasilva Aug 31, 2016
1a87e40
Update language.php
andrepereiradasilva Aug 31, 2016
755c18f
Update language.php
andrepereiradasilva Aug 31, 2016
4bbfd4c
Update language.php
andrepereiradasilva Aug 31, 2016
661ff82
change native to $siteLanguageManifest['name']
andrepereiradasilva Sep 1, 2016
69a02b5
allow to install published content languages on install 1
andrepereiradasilva Sep 2, 2016
cb55d32
allow to install published content languages on install 2
andrepereiradasilva Sep 2, 2016
0cd03f8
solve remaining issues
andrepereiradasilva Sep 2, 2016
b7c5ae4
Merge remote-tracking branch 'refs/remotes/joomla/staging' into insta…
andrepereiradasilva Sep 2, 2016
64ad0bf
Merge remote-tracking branch 'refs/remotes/joomla/staging' into insta…
andrepereiradasilva Sep 3, 2016
9ab5e30
cs
andrepereiradasilva Sep 3, 2016
49037b4
fix language names and simplify
andrepereiradasilva Sep 3, 2016
58d6e68
cs
andrepereiradasilva Sep 3, 2016
5bff1fa
improve code and deprecate unneed code
andrepereiradasilva Sep 3, 2016
63e9589
fix title issues (as possible with current xml scenario)
andrepereiradasilva Sep 4, 2016
52bb74c
Merge remote-tracking branch 'refs/remotes/joomla/staging' into insta…
andrepereiradasilva Sep 4, 2016
defc2c3
fix conflicts
andrepereiradasilva Sep 5, 2016
5f1eda6
remove non existent metadata values
andrepereiradasilva Sep 5, 2016
6abce71
shoudl not be row, it should be tableLanguage
andrepereiradasilva Sep 6, 2016
c924445
don't fallback to en-GB native title
andrepereiradasilva Sep 9, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions administrator/language/en-GB/en-GB.lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ JLIB_INSTALLER_ERROR_EXTENSION_INVALID_CLIENT_IDENTIFIER="Invalid client identif
JLIB_INSTALLER_ERROR_PACK_UNINSTALL_UNKNOWN_EXTENSION="Attempting to uninstall unknown extension from package. This extension may have already been removed earlier."
JLIB_INSTALLER_NOT_ERROR="If the error is related to the installation of TinyMCE language files it has no effect on the installation of the language(s). Some language packs created prior to Joomla! 3.2.0 may try to install separate TinyMCE language files. As these are now included in the core they no longer need to be installed."
JLIB_INSTALLER_UPDATE_LOG_QUERY="Ran query from file %1$s. Query text: %2$s."
JLIB_INSTALLER_WARNING_UNABLE_TO_INSTALL_CONTENT_LANGUAGE="Unable to create a content language for %s language: %s"

JLIB_JS_AJAX_ERROR_CONNECTION_ABORT="A connection abort has occurred while fetching the JSON data."
JLIB_JS_AJAX_ERROR_NO_CONTENT="No content was returned."
Expand Down
1 change: 1 addition & 0 deletions language/en-GB/en-GB.lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ JLIB_INSTALLER_ERROR_EXTENSION_INVALID_CLIENT_IDENTIFIER="Invalid client identif
JLIB_INSTALLER_ERROR_PACK_UNINSTALL_UNKNOWN_EXTENSION="Attempting to uninstall unknown extension from package. This extension may have already been removed earlier."
JLIB_INSTALLER_NOT_ERROR="If the error is related to the installation of TinyMCE language files it has no effect on the installation of the language(s). Some language packs created prior to Joomla! 3.2.0 may try to install separate TinyMCE language files. As these are now included in the core they no longer need to be installed."
JLIB_INSTALLER_UPDATE_LOG_QUERY="Ran query from file %1$s. Query text: %2$s."
JLIB_INSTALLER_WARNING_UNABLE_TO_INSTALL_CONTENT_LANGUAGE="Unable to create a content language for %s language: %s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why two %s

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one for the language other for the error message


JLIB_JS_AJAX_ERROR_CONNECTION_ABORT="A connection abort has occurred while fetching the JSON data."
JLIB_JS_AJAX_ERROR_NO_CONTENT="No content was returned."
Expand Down
51 changes: 48 additions & 3 deletions libraries/cms/installer/adapter/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ public function install()

$basePath = $client->path;
$clientId = $client->id;
$element = $this->getManifest()->files;
$element = $this->getManifest()->files;

return $this->_install($cname, $basePath, $clientId, $element);
}
else
{
// No client attribute was found so we assume the site as the client
$cname = 'site';
$cname = 'site';
$basePath = JPATH_SITE;
$clientId = 0;
$element = $this->getManifest()->files;
$element = $this->getManifest()->files;

return $this->_install($cname, $basePath, $clientId, $element);
}
Expand Down Expand Up @@ -300,6 +300,51 @@ protected function _install($cname, $basePath, $clientId, &$element)
return false;
}

// Create an unpublished content language.
if ((int) $clientId === 0)
{
$siteLanguageManifest = JLanguage::parseXMLLanguageFile(JPATH_SITE . '/language/' . $this->get('tag') . '/' . $this->get('tag') . '.xml');

$row = JTable::getInstance('language');
$row->lang_code = $this->name;
$row->title = $siteLanguageManifest['name'];
$row->title_native = $this->get('name');
$row->image = strtolower(str_replace('-', '_', $this->get('tag')));
$row->description = '';
$row->metakey = '';
$row->metadesc = '';
$row->sitename = '';
$row->published = 0;
$row->access = (int) JFactory::getConfig()->get('access', 1);
$row->ordering = 0;

$sefs = array(
preg_replace('#([a-z]{2,3})-[A-Z]{2}#', '$1', $this->get('tag')),
strtolower($this->get('tag')),
);

// Try both sef types (xx or xx-xx). For instance, for en-US when you have en-GB installed.
foreach ($sefs as $sef)
{
$row->sef = $sef;

if ($row->check() && $row->store())
{
$created = true;
break;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add here an else to deal for an installation language without key

else
{
    $contentLanguageNativeTitle = $contentLanguageTitle;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that fallback is already there. see above

// Set the content language as native_name in site xx-XX.ini, fallback to installation language variable, fallback to content language title.
$contentLanguageNativeTitle = $contentLanguageTitle;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but it does not work. You have to add the else as I suggested;
In the example below, I deleted the string for Sinhala:
INSTL_DEFAULTLANGUAGE_NATIVE_LANGUAGE_NAME="සිංහල (ශ්‍රී ලංකාව)"

and I got:

screen shot 2016-09-09 at 11 14 11

}

if (!$created)
{
JLog::add(
JText::sprintf('JLIB_INSTALLER_WARNING_UNABLE_TO_INSTALL_CONTENT_LANGUAGE', $this->get('name'), $row->getError()),
JLog::WARNING,
'jerror'
);
}
}

// Clobber any possible pending updates
$update = JTable::getInstance('update');
$uid = $update->find(array('element' => $this->get('tag'), 'type' => 'language', 'folder' => ''));
Expand Down