J3 Issue ?
avatar mixahlos
mixahlos
14 Sep 2018

Steps to reproduce the issue

create an install script for extension.
In the preflight function (or any other function, I have also tried in more cases)

  public function __construct() {
    $manifest = $this->getItemArray(JFactory::getDbo()->quote($this->extension));
    $this->oldRelease = $manifest['version'];
  }
  public function preflight($type, $parent) {
    $this->release = $parent->get('manifest')->version;
    if (strtolower($type) == 'update') {
      if (version_compare($this->release, $this->oldRelease, '<')) {
        JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_EXAMPLE_UPDATE_LOWER_VERSION', $this->oldRelease, $this->release), 'error');
        return false;
      } 
      return true;
    }

The language file in : admin/language/en-GB.com_example.sys.ini

COM_EXAMPLE_UPDATE_LOWER_VERSION="Your version is %s. You cannot downgrade to version %s !"

Expected result

Error
Your version is 0.1.5. You cannot downgrade to version 0.1.1 !
Error installing component

Actual result

Error
COM_EXAMPLE_UPDATE_LOWER_VERSION
Error installing component

System information (as much as possible)

Joomla Version : 3.8.12

Additional comments

avatar mixahlos mixahlos - open - 14 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - change - 14 Sep 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Sep 2018
avatar mixahlos mixahlos - change - 14 Sep 2018
Title
JTEXT::sprintf not translating in install script
[com_installer] JTEXT::sprintf not translating in install script
avatar mixahlos mixahlos - edited - 14 Sep 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Sep 2018
Category External Library
avatar brianteeman brianteeman - change - 14 Sep 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 14 Sep 2018
avatar tonypartridge
tonypartridge - comment - 17 Sep 2018

You haven’t included the language file on the preflight since it’s not installed.

iirc for it to be loaded on the installer it needs to be in:

/language/en-GB.com_example.ini

avatar franz-wohlkoenig franz-wohlkoenig - change - 18 Sep 2018
Status New Information Required
avatar infograf768
infograf768 - comment - 18 Sep 2018

/language/en-GB.com_example.ini

or /language/en-GB/en-GB.com_example.ini ?
can't find a doc on preflight

avatar mixahlos
mixahlos - comment - 18 Sep 2018

The Language ini file is not the problem. The following Is translated fine.
JText::_('COM_EXAMPLE_UPDATE_LOWER_VERSION')

If you check the docs you will notice this :

note: If you want that these languages KEYs to be used at the first install of the component, the sys.ini language file must be stored in the component folder (admin/language/en-GB/en-GB.com_helloworld.sys.ini), and the xml manifest file must contains a folder tag for copying language in the component folder. Modify your Manifest file accordingly:

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Mar 2019

@infograf768 can you please comment?

avatar infograf768
infograf768 - comment - 5 Mar 2019

can't help without getting such an extension.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Mar 2019

so @mixahlos have to provide an Extension?

avatar infograf768
infograf768 - comment - 5 Mar 2019

that would help, yes, as I see no reason for JText to work and JText::sprintf not

avatar infograf768
infograf768 - comment - 5 Mar 2019

My guess is that the string should be in components/extension/language/xx-XX/xx-XX.extension.sys.ini

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Mar 2019

@mixahlos can you provide a Extension?

avatar joomla-cms-bot joomla-cms-bot - change - 16 Mar 2019
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2019-03-16 05:54:58
Closed_By joomla-cms-bot
avatar franz-wohlkoenig franz-wohlkoenig - change - 16 Mar 2019
Closed_By joomla-cms-bot franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - close - 16 Mar 2019
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Mar 2019

Closed as no Answer, please reopen if needed.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22179.

avatar joomla-cms-bot
joomla-cms-bot - comment - 16 Mar 2019

Add a Comment

Login with GitHub to post a comment