Pending

User tests: Successful: Unsuccessful:

avatar C-Lodder
C-Lodder
6 Dec 2017

Pull Request for Issue #17093

Summary of Changes

  • Fix the badges not displaying correctly
  • Call minified JS files

Screenshot of what it would look like:
screeny

avatar C-Lodder C-Lodder - open - 6 Dec 2017
avatar C-Lodder C-Lodder - change - 6 Dec 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 6 Dec 2017
Category Administration Language & Strings JavaScript Front End Plugins
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Dec 2017

which Extension to use to get "Updates are available"?


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

avatar C-Lodder
C-Lodder - comment - 7 Dec 2017
avatar franz-wohlkoenig franz-wohlkoenig - test_item - 7 Dec 2017 - Tested successfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Dec 2017

I have tested this item successfully on f035ae1

Thanks for Info @C-Lodder, used Kunena.


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

avatar franz-wohlkoenig franz-wohlkoenig - change - 8 Dec 2017
Easy No Yes
avatar wilsonge
wilsonge - comment - 10 Dec 2017

I'm not sure this actually looks any better with a label? I know you're kinda fixing a bug here because it was originally clearly supposed to have one - but thoughts on just removing the label outright?

avatar C-Lodder
C-Lodder - comment - 10 Dec 2017

@wilsonge Without a badge, it's simply a number on it's on which isn't a very clear indicator. Unless you want to change the language string so that is reads:

2 updates available

If is reads like the above, then we could possibly get away without the need for a badge.

@brianteeman thoughts on this?

avatar Quy
Quy - comment - 10 Dec 2017

I like the badge like it is for the post-installation messages badge for a quick glance without having to read.

avatar brianteeman
brianteeman - comment - 10 Dec 2017

it makes more sense in english to make the string change when updates are available

avatar C-Lodder
C-Lodder - comment - 10 Dec 2017

@brianteeman so in favour of:

2 updates available!

as opposed to:

Updates are available! 2

Also, with or without the badge?

avatar brianteeman
brianteeman - comment - 10 Dec 2017

2 updates available!

avatar Bakual
Bakual - comment - 11 Dec 2017

If you put the number into the string you will have to make sure the correct plural form is used.
I guess JText:plural doesn't work here since it is Javascript.

avatar infograf768
infograf768 - comment - 11 Dec 2017

See /libraries/src/Language/Text.php

* Examples:
	 * `<script>alert(Joomla.JText._('<?php echo Text::plural("COM_PLUGINS_N_ITEMS_UNPUBLISHED", 1, array("script"=>true)); ?>'));</script>`
	 * will generate an alert message containing '1 plugin successfully disabled'
	 * `<?php echo Text::plural('COM_PLUGINS_N_ITEMS_UNPUBLISHED', 1); ?>` will generate a '1 plugin successfully disabled' string
	 *
	 * @param   string   $string  The format string.
	 * @param   integer  $n       The number of items
	 *
	 * @return  string  The translated strings or the key if 'script' is true in the array of options
	 *
	 * @since   11.1
	 */
	public static function plural($string, $n)

Looks like there is a possibility of making plural js compatible.

avatar C-Lodder
C-Lodder - comment - 11 Dec 2017

I can simply pass the plural string via Joomla.options object. No biggy

avatar Bakual
Bakual - comment - 11 Dec 2017

Looks like there is a possibility of making plural js compatible.

If you know the item count before creating the string, then yes. But afaik in that plugin we generate all possible strings before and then decide which one to use in JS after the AJAX response.

I can simply pass the plural string via Joomla.options object. No biggy

I don't think you can. Because you don't know which plural string to use. Not all languages are like english were you only have one plural string. There are languages where you have eg a specific plural form for "12 items". That's what JText::plural takes care of, together with some language specific code in localise.php that tells it which form to use. You can't do that on client side because you don't have the information you need (at least not that I know).
It's probably also the reason we currently have that ugly text ?

I think you would have to generate the answer text as part of the AJAX response and echo that.

avatar C-Lodder
C-Lodder - comment - 11 Dec 2017

@Bakual - Correct me if I'm wrong, but JText::plural will take care of strings that contain plurals. So if we use:

.ini

UPDATES_AVAILABLE = 2 updates available!

.php

$text = Text::plural('UPDATES_AVAILABLE');

Factory::getDocument()->addScriptOptions('foo', ['bar' => $text]);

.js

var text = Joomla.getOptions('foo');

The plural text is then generated PHP side and pass to the JS options object.

It will then be up to those who manage language packs to update the string.

Unless I'm missing something, I don't see the need for Ajax.

avatar mbabker
mbabker - comment - 11 Dec 2017

You have to pass a count to the plural() method for it to work correctly. Depending on the active language, there may be different strings for different counts (unlike the en packs which are all _0, _1, and _MORE). So you can't just seed the options with one generic string.

avatar C-Lodder
C-Lodder - comment - 11 Dec 2017

Fair enough. In which case lets just leave this PR as it is.

avatar wilsonge wilsonge - change - 20 Dec 2017
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-12-20 00:13:56
Closed_By wilsonge
avatar wilsonge wilsonge - close - 20 Dec 2017
avatar wilsonge wilsonge - merge - 20 Dec 2017

Add a Comment

Login with GitHub to post a comment