@Cottser points out that there are problems displaying multiples separated simply by ", " and that it would be better for internationalization to use HTML lists so that we don't need to worry so much about grammar for different languages.

From a brief search, this problem exists in a number of places.

core/modules/views_ui/views_ui.theme.inc:
$variables['displays'] = empty($variables['displays']) ? t('None') : format_plural(count($variables['displays']), 'Display', 'Displays') . ': ' . '<em>' . implode(', ', $variables['displays']) . '</em>';

core/lib/Drupal/Core/Extension/InfoParser.php:
$message = format_plural(count($missing_keys), 'Missing required key (!missing_keys) in !file.', 'Missing required keys (!missing_keys) in !file.', array('!missing_keys' => implode(', ', $missing_keys), '!file' => $filename));

core/modules/system/lib/Drupal/system/Tests/Form/ValidationTest.php:
$top_message = format_plural(count($error_links), '1 error has been found', '@count errors have been found') . ': ' . implode(', ', $error_links);

core/modules/system/system.install:
'value' => format_plural(count($modules), 'The %modules module is disabled.', 'The following modules are disabled: %modules', array('%modules' =>implode(', ', $modules))),

core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/filter/TaxonomyIndexTid.php:
form_error($form, $form_state, format_plural(count($missing), 'Unable to find term: @terms', 'Unable to find terms: @terms', array('@terms' => implode(', ', array_keys($missing)))));

core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php:
form_error($form, $form_state, format_plural(count($missing), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', array_keys($missing)))));

But came up because of a patch in #1493324-198: Inline form errors for accessibility and UX which is adding to this problem.

We should have a consistent pattern in dealing with this. I think it would look better, as the current solution doesn't even work well in English as it lacks both the ", and " which is traditional for the last item as well as the final "." which is another normal convention.

Comments

mgifford’s picture

Issue summary: View changes
SKAUGHT’s picture

$nameList = implode(' & ', array_filter(array_reverse(array_merge(array(array_pop($names)), array(implode(', ',$names))))));

mgifford’s picture

@SKAUGHT - That looks like it would solve the "item 1, item2, item 3 & item4" business. It could be extended to include the "." easily.

$nameList = implode(' & ', array_filter(array_reverse(array_merge(array(array_pop($names)), array(implode(', ',$names)))))) . '.';

But not sure how it would assist improved internationalization.

SKAUGHT’s picture

i'm not best sure how to handle multilingual aspects. I'm not sure what languages might fall into an issue here..is this just the user of the ampersand across languages? Maybe array matching what character the LanguageManager::getStandardLanguageList() would pull??

As well, rtl/ltr I image is also some issue.. A little routine for that would be needed.

SKAUGHT’s picture

Perhaps adding an option check into formatPlural() to run this idea. default to ON.

But i'm also wondering if it might be good to introduce another format function for this so it can be recycled as it's certainly a useful formatter...i do myself use it for term outputs all the time. Then: where would be best to add it (I'm not certain in the TranslationManager class is where it should be). How should it as a function be named? formatAndList()??

Toward the point of the ticket title: i think outputting an UL element in the middle of a sentence won't really help anyone and does add html and additional css (that we then need to un-block level it). i know there's some trouble in formatting for languages...but that might be worth that effort in the end to help people read a message that actually makes sense.

===

From my random thoughts of yesterday: might using &amp; and &comma; be a decent approach to shortcut some issues -- allow the font to display the right character. otherwise some extend/supplement to getStandardLanguageList type data.

mgifford’s picture

Sounds good to me. Really gotta get someone like @Gábor Hojtsy to look at it who are familiar with how lists like this are expressed in different languages.

davidhernandez’s picture

I think Cottser's point was to avoid the use of a sentence at all.

Instead of:
1,2,3

use:

  • 1
  • 2
  • 3

This would be the only thing I see bypassing the translation issues, because it isn't a sentence that needs translating. Imploding the list in different ways, replacing 'and' with '&', etc, will still have problems. I know Gábor mentioned some languages would replace the 'and' with another comma, but might be too particular for someone to want to deal with. It would also mean leaving out the serial (Oxford) comma, which goes agains the style guide.

SKAUGHT’s picture

i think the issue with a full UL/OL list is that will take alot of screen space, when a list is...more than 4 or 5.. And in a responsive site, even worse. Which could happen in a lot of real world uses.

A lot of clients/designers outlines i have, would hate that (i hate that, too) -- especially as an out of the box solution for Core to do.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

SKAUGHT’s picture

linking. How basic concept has now been introduced to core.

Although is a css pseudo-class based method which will lack both legacy browser support and poor content indexing of content from search engines. Does work with RTL, (but only visually)

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
larowlan’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update, +Needs steps to reproduce, +Bug Smash Initiative

We need an issue summary update here to clarify what the bug is

Thanks

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

If still a valid bug please reopen adressing #20 and updating issue summary.

Thanks!