joomla / backend-template

backend template for Joomla 4 working area
GNU General Public License v2.0
13 stars 23 forks source link

Quickicon improvements #362

Closed chmst closed 5 years ago

chmst commented 5 years ago

Pull Request for Issue #258 .

Summary of Changes

1) Fixed: Button MenuItems

2) Numbers on icons can be useful and important but sometimes are useless, asdescribe in the issues. We have expanded module parameters so the administrator can choose if she want to see the number or only the button.

3) If a number is displayed, both the number and component name have attribute "aria-hidden", but a sr-only text is added which gives information in a sentence.

brianteeman commented 5 years ago

Made some comments inline

Someone else will have to check that the pluralisation is correct in the code to allow for languages that have more complex pluralisation rules - maybe @infograf768 can check this

infograf768 commented 5 years ago

Would someone be kind enough to explain what we are supposed to get (screenshots) and what the plural forms are for and how/where they display?

I have installed the quickicon-improvements branch here

infograf768 commented 5 years ago

Note: I have enabled all possible stuff in the Quickicon module

infograf768 commented 5 years ago

I get this when enabled

<div class="quickicon-sr-desc sr-only" data-sronly-zero="Article categories: No category is available" data-sronly-one="Article categories: One category is available" data-sronly-n="Article categories: 2 categories are available">Article categories: 5 categories are available</div>

I am lost as whatever that means it seems that any other plural form is not taken care of.

if (isset($displayData['srOnly']))
{
    $srOnly_0 = Text::plural($displayData['srOnly'], 0);
    $srOnly_1 = Text::plural($displayData['srOnly'], 1);
    $srOnly_n = Text::plural($displayData['srOnly'], 2);
}
infograf768 commented 5 years ago

Example In en-GB we have

COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_1="%d banner checked in."
COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_MORE="%d banners checked in."

in Russian

COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_0="Ни один баннер не был разблокирован"
COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_1="%d баннер успешно разблокирован"
COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_2="%d баннера успешно разблокировано"
COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_MORE="%d баннеров успешно разблокировано"

In some other languages, we may have even more strings/plural forms. In Scottish (only available for 2.5) we have

public static function getPluralSuffixes($count) {
        if ($count == 0 || $count > 19) {
            $return =  array('0');
        }
        elseif($count == 1 || $count == 11) {
               $return =  array('1');
        }
        elseif($count == 2 || $count == 12) {
               $return =  array('2');
        }
        elseif(($count > 2 && $count < 12) || ($count > 12 && $count < 19)) {
                $return =  array('FEW');
        }
        return $return;
     }
brianteeman commented 5 years ago

That's exactly what I suspected

chmst commented 5 years ago

The Plural forms do this: 1) for sighted users

quickicons-singular

2) For blind users the Screen Reader says for example:

Users: One User is activated.

Articles: No article is available

Modules: Three modules are available

Global Checkin: No Items are locked.

Cache: The Cache is empty

We have adopted this from the joomla update plugins. In case of many different plural forms we could add more strings.

brianteeman commented 5 years ago

In case of many different plural forms we could add more strings.

That's the whole point - we can not. The current system used throughout joomla is that the TT add them if they need to

bembelimen commented 5 years ago

@infograf768 you're right, we have to take care for the pluralism form. Do you have an JS example where this happen in Joomla!?

infograf768 commented 5 years ago

Did not find any but this should help https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Language/Text.php#L171-L198

infograf768 commented 5 years ago

@chmst Please use the normalized string constants for plural forms. I mean adding the _N_ in the constant. For example: COM_CATEGORIES_QUICKICON_N_SRONLY

chmst commented 5 years ago

Thank ou, @infograf768. I did the normalization but was not successful with the RTL. Will try again when I have some spare time.

infograf768 commented 5 years ago

RTL: will test a new install of your branch and see what I can do.

infograf768 commented 5 years ago

RTL: the problem with the Cache value display is the JsonResponse. It does not accept htmlentities in general and even if it was, this specific one should not be decoded anyway as it is a pure unicode &#x200E; = \u200E

For example if I use $result['amount'] = json_encode('&#x200E;' . $mb); I get the correct LTR but with the htmlentity

Screen Shot 2019-07-13 at 19 48 11
infograf768 commented 5 years ago

@chmst RTL: found a solution in quickicon.es6.js Change counter.textContent = response.data.amount; to counter.textContent = '\u200E' + response.data.amount;

Screen Shot 2019-07-14 at 12 07 45

Same for sronly sronly.textContent = '\u200E' + response.data.sronly;

provided that RTL TT creates a string formatted such: COM_CACHE_QUICKICON_SRONLY= "%s حجم کش است"

Screen Shot 2019-07-14 at 12 25 45