joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.76k stars 3.65k forks source link

Ellipsis instead of three dots #38630

Open Valdnet opened 2 years ago

Valdnet commented 2 years ago

The spelling of the ellipsis should be corrected in all text strings. Currently, three dots ... are used which is a spelling mistake. The ellipsis character of the form should be used.

ReLater commented 2 years ago

I would prefer a language string for the code places where the three dots are used (e.g. in truncate methods, especially truncateComplex). Then everyone can decide for themselves what they want to use. Empty string, icon, 3 dots, ellipsis, whatever.

But I'm against a change in core like hard-coded ellipsis instead of 3 dots.

brianteeman commented 2 years ago

The style guide says it should be an ellipsis (https://developer.joomla.org/en-gb-user-interface-text-guidelines/punctuation.html)

Also a screen reader understands an ellipsis but doesnt understand three dots

ReLater commented 2 years ago

Also a screen reader understands an ellipsis but doesnt understand three dots

Set the default of my proposed language string to an ellipsis.

Method truncateComplex sets the 3 dots/ellipsis outside of the last HTML tag; e.g. after last <p></p>.

I think a language string would be the best solution for all needs.

brianteeman commented 2 years ago

Method truncateComplex sets the 3 dots/ellipsis outside of the last HTML tag; e.g. after last

.

It shouldn't do that. Can you post an example please.

ReLater commented 2 years ago

That's the behavior since ever.

$text = '<p>Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo Hello hallo </p>';
$introtext_limit = 35;

echo HTMLHelper::_('string.truncateComplex', $text, $introtext_limit);

==>

<p>Hello hallo Hello hallo Hello</p>...

brianteeman commented 2 years ago

That's the behavior since ever.

then its always been a bug

N6REJ commented 2 years ago

@brianteeman apparently this was introduced in J! 2.5 https://blog.crosborne.uk/truncstring-joomla-bug

brianteeman commented 2 years ago

thanks - will read it in the morning

N6REJ commented 2 years ago

looking @ the code it looks like it was designed to do that...

            // If the new plain text string matches the original plain text string we are done.
            if ($ptString === $htmlStringToPtString) {
                return $htmlString . '...';
            }

            // Get the number of HTML tag characters in the first $maxLength characters
            $diffLength = strlen($ptString) - strlen($htmlStringToPtString);

            if ($diffLength <= 0) {
                return $htmlString . '...';
            }
Valdnet commented 2 years ago

@N6REJ You should also remember about text strings that come with three dots, such as: https://github.com/joomla/joomla-cms/blob/9df5e6c7a7a1c6ec0aed99d6d4a22be048b9b299/language/en-GB/com_media.ini#L101

Additionally, the ellipsis should be separated by a space.

ReLater commented 2 years ago

Just to have it mentioned:

You should keep in mind that simple <p></p> examples are relatively easy to fix. Find the last closing tag move ... inside.

It becomes more complicated if you work with more complex HTML:

$text = '
<p>Happa heppiu.</p>
<ul>
<li>A1 A1 A1 A1 A1 A1 A1 A1 A1 A1 A1 A1</li>
<li>A2 A2 A2 A2 A2 A2 A2</li>
<li>A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14</li>
<li>B1cdsww B1cdsww B1cdsww B1cdsww B1cdsww B1cdsww B1cdsww</li>
<li>B2weqwewq B2weqwewq B2weqwewq B2weqwewq B2weqwewq B2weqwewq</li>
</ul>
';
$introtext_limit = 100;
echo HTMLHelper::_('string.truncateComplex', $text, $introtext_limit);

=>

<p>Happa heppiu.</p>
<ul>
<li>A1 A1 A1 A1 A1 A1 A1 A1 A1 A1 A1 A1</li>
<li>A2 A2 A2 A2 A2 A2 A2</li>
<li>A3 A4 A5 A6 A7 A8 A9 A10</li></ul>...

instead of

<p>Happa heppiu.</p>
<ul>
<li>A1 A1 A1 A1 A1 A1 A1 A1 A1 A1 A1 A1</li>
<li>A2 A2 A2 A2 A2 A2 A2</li>
<li>A3 A4 A5 A6 A7 A8 A9 A10...</li></ul>
brianteeman commented 2 years ago

It actually happens very rarely in core. But there are solutions available.

brianteeman commented 2 years ago

@laoneo it looks like you have addressed this exact bug in dpcalendar

laoneo commented 2 years ago

Did I? Not sure what you mean...