Welcome, Guest
Username: Password: Remember me

TOPIC: Translate Values List With Language System (JText)

Translate Values List With Language System (JText) 06 Nov 2015 11:56 #13659

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 278
  • Thank you received: 35
  • Karma: 22
Hi cookers,

Has someone already translate Combo List of values with the natif Joomla3 Language System ?


The question is: where and how do I integrate the JText::_() ?

option 1
/views/single_item/view.html.php
                $model_id_statut = CkJModel::getInstance('Statuts', 'JbreedingModel');
                $model_id_statut->addGroupOrder("a.value");
                $lists['fk']['id_statut'] = $model_id_statut->getItems();

option 2 Any facilities to translate the values with jdomOptions ?
/views/single_item/tmpl/default_form.php
$fieldSet['jform_id_statut']->jdomOptions = array(
			'list' => $this->lists['fk']['id_statut']
		);

Thanks for help ...
Last Edit: 06 Nov 2015 11:58 by liubov.
The administrator has disabled public write access.

Translate Values List With Language System (JText) 06 Nov 2015 15:44 #13660

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 278
  • Thank you received: 35
  • Karma: 22
My custom code works. (option2)

But I would like to know if somebody has another (Jdom) method to manage Language translations of Combo List...
// Combo List of values Translation with JLanguage System
        for ($i=0, $n=count($this->lists['fk']['id_statut']); $i < $n; $i++):
                $Jtx_statut = $this->lists['fk']['id_statut'][$i]->value;
                unset($this->lists['fk']['id_statut'][$i]->value) ;
                $this->lists['fk']['id_statut'][$i]->value = JText::_($Jtx_statut);
        endfor;
        $fieldSet['jform_id_statut']->jdomOptions = array(
                        'list' => $this->lists['fk']['id_statut']
                );

tanslated result :
The administrator has disabled public write access.

Translate Values List With Language System (JText) 06 Nov 2015 19:24 #13661

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
In a component which reads out shps I have created a table: Languages.
It has a label and a value (Dutch/nl, English/en etc)
You can then create another table for the values in the combo, which has an FK to the language.
Add a where statement with the language and you wille have your combo filled with the values from that language.

So, the combo is not a enum in the table, but an extra table.
Maybe not what you want or need, but you asked for another solution :D
The administrator has disabled public write access.

Translate Values List With Language System (JText) 07 Nov 2015 12:20 #13664

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 278
  • Thank you received: 35
  • Karma: 22
thank you for your reply, never mind, it's a way to do ...
but i prefer to keep the Language System ...
Last Edit: 07 Nov 2015 12:20 by liubov.
The administrator has disabled public write access.
Time to create page: 0.098 seconds

Get Started