[SOLVED] Why are VM language variables not translated in Joomla SQL field type?

Started by gba, October 17, 2017, 11:32:03 AM

Previous topic - Next topic

gba

Hi!

I am creating a VM plugin having a params field 'orderstatus':
<field name="plg_myplugin_orderstatus" type="sql"
description="PLG_MYPLUGIN_ORDERSTATUS_DESC"
label="PLG_MYPLUGIN_ORDERSTATUS_LABEL"
default=""
query="
SELECT `#__virtuemart_orderstates`.`virtuemart_orderstate_id`,`#__virtuemart_orderstates`.`order_status_name`
FROM  `#__virtuemart_orderstates`
WHERE `#__virtuemart_orderstates`.`published`=1
ORDER BY  `#__virtuemart_orderstates`.`ordering` ASC
"
key_field="virtuemart_orderstate_id"
value_field="order_status_name"
translate="translate"
/>


Although I am using the tag 'translate', VM language variables in #__virtuemart_orderstates.order_status_name are not translated, while other are translated (i. e. language overrides).
Is VM not fully compatible with Joomla's multilanguage features?

Kind regards,
Gerald

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

gba

JFactory::getLanguage('com_virtuemart')

Right?

EDIT: No, I have no PHP file ... I have the XML file of the plugin. How do I load the language file there? ???


gba

Why cannot I use a standard Joomla field with an own created VM plugin?

Studio 42

Because is not a standard field and Joomla do not load all language files.

gba


Studio 42

You had a question, i give you the right answer.
Sorry if you don't understand, or not have the lust to write the code.
type="sql" is to use a query to load a list, it's not the role of this field to add any language files.

gba

Quote from: Studio 42 on October 17, 2017, 20:44:20 PM
type="sql" is to use a query to load a list, it's not the role of this field to add any language files.

Ah, now I see ... thank you for the additional explanation!

Kind regards,
Gerald

gba

Hi again!

If someone could help me:
In my plugin folder I created a subdir 'fields' containing a file 'sql.php':
<?php
defined
'_JEXEC' ) or die( 'Restricted access' );

JFormHelper::loadFieldClass('sql');

class 
MyFormFieldSql extends JFormFieldSql
{
protected function getOptions()
{
$options $this->getOptions();

if ($this->translate == true)
{
foreach ($options as $item
{
$item vmText::_($item);
}
}

return $options;
}
}

But I guess I have forgotten something ... nothing happens.
Function getOptions() is even not executed.

All I want is:
Run through the options of the sql field once again translating them with vmText::_().

Can anyone help me finding out, what is missing, please?
Thank you very much in advance!

Kind regards,
Gerald

Studio 42



gba

Just one more question here, because it is VM related and I cannot find any hint in the VM documentation:
What do I need to be able to use 'vmText' functions in my field class?

Milbo

http://dev.virtuemart.net/projects/virtuemart/wiki/Developing_a_module_or_plugin_for_VirtueMart_2

"Use
if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR .'/components/com_virtuemart/helpers/config.php');
to load the configuration object in your extension. Now you have loaded the main API of VirtueMart 2. To be sure that the vm config is loaded, you may use

$config = VmConfig::loadConfig();"

the loadConfig ensures also that the language is loaded
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

gba

Hi!

Thank you for your hint.

Unfortunately not working:
i. e. vmText::_("COM_VIRTUEMART_ORDER_STATUS_PENDING") returns COM_VIRTUEMART_ORDER_STATUS_PENDING.

protected function getOptions() {
if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR .'/components/com_virtuemart/helpers/config.php');
$config = VmConfig::loadConfig();

$options = parent::getOptions();

foreach ($options as $option) {
$option->text = vmText::_($option->text);
}

return $options;
}

Am I blind?  ???

Kind regards,
Gerald