Like any core Joomla extension, Trombinoscope Contacts can be used on multi-language websites.

In the context of contacts, you may not want to create a contact per language because all fields may contain the same information, where addresses, phone numbers... will be identical. What if all the fields you will be using are identical for all languages? It makes no sense to create duplicates.

If the position field is the only one that will be different for all languages, Trombinoscope Contacts has a solution for you.

Translating the position field

Step 1 - Enter language keys

In order for the positions for all contacts to be translated, you will need to enter language keys inside the position field. For instance, instead of staff, you need to enter the key POSITION_STAFF.

As a general rule, you need to prefix the languages keys with POSITION_

For several positions, coma separate the keys. For instance, instead of staff, financial, you need to enter the keys POSITION_STAFF, POSITION_FINANCIAL.

Step 2 - Create language overrides

For your keys to be translated, you need to tell the system what they need to be translated into.

Go to Extensions -> Language(s) -> Overrides in the Joomla administrator console.

Create as many entries for each language as you need.

Pro If you are using Joomla's smart search (or finder) and the packaged Trombinoscope Contacts Pro smart search plugin, you will need to create language keys for the site AND the administration sides. This will allow the smart search component to index the translated positions rather than the keys themselves.

In our previous example, for instance, visitors will be able to search for staff. Without keys for the administration side, the smart search will return nothing.

Wen several positions are coma separated, the extension formats the output. For instance, POSITION_STAFF, POSITION_FINANCIAL will be translated into staff and financial. POSITION_STAFF, POSITION_FINANCIAL, POSITION_HR will be translated into staff, financial and HR.

To change the and into a coma or & (for instance), you need to override the key TROMBINOSCOPEEXTENDED_AND. If a language is not supported by the extension, you will also need to create entries for TROMBINOSCOPEEXTENDED_AND (the space in the translation is required, unless you replace that translation with a coma).

If you are using the free version of the extension and/or linking contacts to the core Joomla contact view, you will need to create a template override of the contact view for the translations to take place.

The contact core vcard output would also need to be altered, but it is not possible to override this one as it is a core file.
The pro version of Trombinoscope Contacts does not have this limitation.

To create the contact override, go to Extensions -> Templates -> Styles. Create an override for the com_contact contact view. In the html/com_contact/contact newly created folder in your template, open the default.php file.

Find the line

echo $this->contact->con_position;

Replace it with

$lang = JFactory::getLanguage();
$lang->load('com_trombinoscopeextended', JPATH_SITE);
if (strpos($this->contact->con_position, 'POSITION_') !== false) {
    $field_array = explode(',', $this->contact->con_position);
    $field_array_fixed = array();
    $last_field = '';
    foreach ($field_array as $field_element) {
        $field_array_fixed[] = JText::_(trim($field_element));
    }
    $count = count($field_array);
    if ($count > 1) {
        $last_field = $field_array_fixed[$count - 1];
        unset($field_array_fixed[$count - 1]);
        echo implode(', ', $field_array_fixed).JText::_('TROMBINOSCOPEEXTENDED_AND').' '.$last_field;
    } else {
        echo JText::_(trim($this->contact->con_position));
    }
} else {
    echo $this->contact->con_position;
}

Featured Blogs