Page 2 of 3
Re: My solution for multilanguage products
Posted: 25 Jun 2018, 15:12
by PixelZombie
Hey Jan,
I already tried to change the output with content.prepare in various files, but unfortunately I can't get it to work.
Re: My solution for multilanguage products
Posted: 26 Jun 2018, 14:08
by Jan
This reads the content plugins so the question is if the translation feature is based on content or system plugins?
Jan
Re: My solution for multilanguage products
Posted: 26 Jun 2018, 21:57
by PixelZombie
It's a system plugin
Code: Select all
jimport('joomla.plugin.plugin');
class plgSystemMultilanguagesck extends JPlugin
{
function __construct(&$subject, $config) {
parent :: __construct($subject, $config);
}
public function onAfterRender()
{
$app = JFactory::getApplication();
$document = JFactory::getDocument();
$doctype = $document->getType();
$input = new JInput();
// si pas en frontend, on sort
if ($app->isAdmin()) {
return false;
}
// si pas HTML, on sort
if ($doctype !== 'html') {
return;
}
if ($input->get('layout') == 'edit') {
return;
}
// renvoie les données dans la page
$body = JResponse::getBody();
// debug mode
// get attribute from system plugin params
$plugin = JPluginHelper::getPlugin('system', 'multilanguagesck');
$pluginParams = new JRegistry($plugin->params);
if ($pluginParams->get('debugmode') == '1') {
// get the language
$lang = JFactory::getLanguage();
$langtag = $lang->getTag(); // returns fr-FR or en-GB
$debugmessage = '<p style="font-size:14px;color:red;">The actual language tag is : '.$langtag.'</p>';
$body = str_replace("<body",$debugmessage."<body", $body);
}
$regex = "#{langck(.*?){/langck}#s"; // masque de recherche
$body = preg_replace_callback($regex, 'self::checklanguageck', $body);
JResponse::setBody($body);
}
function checklanguageck(&$matches) {
// découpe l'expression pour récupérer les textes
$patterns = "#{langck(.*)}(.*){/langck}#Uis";
$result = preg_match($patterns, $matches[0], $results);
// vérifie si des paramètres personnalisés existent
$params = explode('=', $results[1]);
// si pas de langue définie on sort
if (!isset($params[1])) return $matches[0];
$lang = JFactory::getLanguage();
$langtag = $lang->getTag(); // returns fr-FR or en-GB
// vérifie si ça colle avec la langue active
if (($params[1] == $langtag) AND isset($results[2])) {
$return = $results[2];
} else {
$return = '';
}
return $return;
}
}
Re: My solution for multilanguage products
Posted: 01 Jul 2018, 12:53
by Jan
Hi, hmmm, so I think, this cannot be somehow managed as the system plugin applies after the content output is ready
Jan
Re: My solution for multilanguage products
Posted: 03 Jul 2018, 11:41
by PixelZombie
Can't we just take the replace-function and put it where the mail-output is created?
Re: My solution for multilanguage products
Posted: 05 Jul 2018, 12:59
by Jan
The question is what should be replaced (if you want simulate the function of the whole system plugin or you somehow get the event for the system plugin), hard to say, I don't have any experiences regarding this
Jan
Re: My solution for multilanguage products
Posted: 09 Jul 2018, 16:24
by Jan
Hi, the only idea for now is:
Add this method to the system plugin:
plugins\system\multilanguagesck\multilanguagesck.php
Code: Select all
public function onChangeText(&$body) {
// debug mode
// get attribute from system plugin params
$plugin = JPluginHelper::getPlugin('system', 'multilanguagesck');
$pluginParams = new JRegistry($plugin->params);
if ($pluginParams->get('debugmode') == '1') {
// get the language
$lang = JFactory::getLanguage();
$langtag = $lang->getTag(); // returns fr-FR or en-GB
$debugmessage = '<p style="font-size:14px;color:red;">The actual language tag is : '.$langtag.'</p>';
$body = $body . $debugmessage;
}
$regex = "#{langck(.*?){/langck}#s"; // masque de recherche
$body = preg_replace_callback($regex, 'self::checklanguageck', $body);
return true;
}
and in:
administrator\components\com_phocacart\libraries\phocacart\order\status.php
line cca 480:
Code: Select all
JPluginHelper::importPlugin( 'system' );
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('plgSystemMultilanguagesck');
$dispatcher->trigger('onChangeText', array(&$body));
$dispatcher->trigger('onChangeText', array(&$bodyOthers));
Please test and let me know.
Did you do some modifications to the system plugin?
Maybe we can contact the author of this plugin and ask to extend it about "manual" method to translate text. If this will be not possible we can do specific version for Phoca Cart.
Jan
Re: My solution for multilanguage products
Posted: 12 Jul 2018, 13:54
by PixelZombie
Awesome Jan! That worked!
I think creating a phoca version of this multilanguge plugin would be the best way to do and maintain it. As I see it, the original plugin isn't maintained anymore since the last update is really old.
Cheers!
Frank
Re: My solution for multilanguage products
Posted: 13 Jul 2018, 15:57
by Jan
Ok, see the link to the edited file here (at the bottom):
https://www.phoca.cz/download/category/ ... -component
Please install and check (the status.php file needs to be edited now, I will add it in the next version)
Jan
Re: My solution for multilanguage products
Posted: 19 Jul 2018, 13:06
by PixelZombie
Hey Jan,
I just tested it out a little more and noticed that the payment title and the email-title are'nt translated by the plugin. The Mail-Description is fine. See the Screenshot for details:
Could you extend the plugin to these fields aswell?
Cheers
Frank