Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Joomla JText::_("")

Tags:

php

joomla

Im trying to change the language of a Joomla! component called DigiCom. Actually I don't understand this line here:

<th class="text-center"><?php echo JText::_("COM_DIGICOM_PRICE_PLAN");?></th>

I guess this might be a reference, as the text displayed is not COM_DIGICOM_PRICE_PLAN. If I am right, do you know where can I change it?

Here is part of the code:

<?php
/**
 * @package     DigiCom
 * @author      ThemeXpert http://www.themexpert.com
 * @copyright   Copyright (c) 2010-2015 ThemeXpert. All rights reserved.
 * @license     GNU General Public License version 3 or later; see LICENSE.txt
 * @since       1.0.0
 */

defined('_JEXEC') or die;


JHTML::_('behavior.formvalidation');

$pg_plugin = $this->pg_plugin;
$configs = $this->configs;
$data = $this->data;
?>
<div id="digicom" class="dc dc-checkout">

    <?php
    $this->setLayout('cart');
    echo $this->loadTemplate('steps');
    ?>

    <h1 class="page-title"><?php echo JText::sprintf("COM_DIGICOM_CHECKOUT_PAYMENT_DETAILS_PAGE_TITLE", $pg_plugin); ?></h1>

    <div class="dc-checkout-items">

        <h4 class="align-center"><?php echo JText::_("COM_DIGICOM_SUMMARY_YOUR_ORDER");?></h4>
like image 657
Ero Stefano Avatar asked Dec 02 '22 14:12

Ero Stefano


1 Answers

JText::_() is a helper function to help with localization. It will take a symbol like COM_DIGICOM_PRICE_PLAN and lookup the users currently set language and pull the related string from the associated language file. These language files are located under the /language and /administrator/language folders.

If there is no matching symbol the function will simply return the passed symbol. So, if COM_DIGICOM_PRICE_PLAN was not found in the component's language files, it would just give back COM_DIGICOM_PRICE_PLAN. Otherwise, it will give back the associated string.

So, if you are wanting to change a component's localization strings you need to do one of two things. 1) edit the language file, or 2) add an override.

To edit the language file:

Find the component/module/plugin's language file. Find the associated symbol and change the string.

That particular component's language filename/path would be something like

/language/en-GB/en-GB.com_digicom.ini
/administrator/language/en-GB/en-GB.com_digicom.ini
/administrator/language/en-GB/en-GB.com_digicom.sys.ini

Where en-GB is the particular language you want to change (or go through all of them, if you want to change the string for all languages).

Then, look for a line like

COM_DIGICOM_PRICE_PLAN="Some text"

After that, just change Some Text to whatever you would like it changed to.

Read the Joomla component tutorial about adding language management to learn more

Note though these files may be overwritten when updating the component, so you may have to re-edit those if it does ever update.

Add an override

This is a better option as you do not need to edit/re-edit any files after an update.

Go to the Languages: Overrides page and add an override for the language constant. You can get there by accessing menu in the backend and going to Extensions -> Languages -> Overrides

There just put in the constant you want to override: COM_DIGICOM_PRICE_PLAN and then the text you want to appear. Then save.

enter image description here

like image 53
Patrick Evans Avatar answered Dec 21 '22 03:12

Patrick Evans