Problem/Motivation

Forms are still including language.admin.inc to use language_admin_predefined_list().

Proposed resolution

Move language_admin_predefined_list() to ConfigurableLanguageManager

Remaining tasks

Review

User interface changes

None

API changes

Remove language_admin_predefined_list() and add ConfigurableLanguageManagerInterface::getUnusedPredefinedList()

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott’s picture

Status: Active » Needs review
FileSize
11.03 KB
Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +language-ui, +sprint

Great improvement indeed.

penyaskito’s picture

+++ b/core/modules/language/lib/Drupal/language/ConfigurableLanguageManager.php
@@ -407,4 +407,21 @@ public function getLanguageConfigOverride($langcode, $name) {
+    asort($predefined);

Will this order by key? Shouldn't we order by the label?
Maybe it is even out of scope of this issue.

Gábor Hojtsy’s picture

Its not changed in this issue. The native names of the languages may use various character sets, they may be left to right, Chinese, etc. Not sure there could be any sensible order of them if ordered by name/label.

Gábor Hojtsy’s picture

Wait, no, its in the interface language. Well, maybe, ordering by their name would be good, but this issue just moves the existing code :) So as far as the scope goes RTBC.

ParisLiakos’s picture

FileSize
11.04 KB
1.31 KB

i just couldnt let it go :P

Gábor Hojtsy’s picture

Cool, looks good still :)

penyaskito’s picture

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Nice little clean-up. Committed to 8.x.

  • Commit 85c8f32 on 8.x by Dries:
    Issue #2254495 by ParisLiakos, alexpott: Move...
Gábor Hojtsy’s picture

Issue tags: -sprint

Yay, thanks!

sun’s picture

Status: Fixed » Needs work
Issue tags: +API change
+  /**
+   * Prepare a language code list for unused predefined languages.
+   *
+   * @return array
+   *   List of predefined language names keyed by langcode.
+   */
+  public function getUnusedPredefinedList();

Huh? What's an "unused" predefined list?

Why didn't we simply name that getPredefinedList(), which would correspond 1:1 to the @return value description...?

EDIT: Also needs a change notice, since API change.

Gábor Hojtsy’s picture

Well, there is indeed some terminology mismatch here. LanguageManager already has a getStandardLanguageList() as used by this method. The method filters that list to the "unused" ones, that is the ones not yet saved as configured languages on the site. That is it returns all the predefined/standard languages that are not used on the site. getStandardLanguageList() already returns the full list. Naming this getPredefinedList() would be pretty confusing since its a filtered list of the languages included with Drupal based on live configuration. Therefore the result itself is not predefined :)

sun’s picture

Sorry, I get it now — the method removes all languages from the predefined list that are enabled already. But hm, getUnusedPredefinedList() is a confusing name, because the context of "unused" and its relation to "predefined" is not clear.

listPredefinedWithoutEnabled()?

Something along that line would be more clear? Also note list vs. get; all of the get* methods appear to return Language objects, whereas this method simply returns a langcode/label mapping.

Alternatively, we could shoot for a full parity:

getStandardLanguageList() [LanguageManager]

getStandardLanguageListWithoutEnabled() [ConfigurableLanguageManager]

Gábor Hojtsy’s picture

Well, we should indeed ideally match terminology with standard vs. predefined.

sun’s picture

Status: Needs work » Needs review
FileSize
4.73 KB

So how about this?

Gábor Hojtsy’s picture

Languages are not enabled in D7 they are added/removed. We just standardised that earlier with #2240463: Fix text: languages are not "enabled/disabled" anymore, they are added/removed. So not sure saying 'enabled' here would be a good idea.

sun’s picture

Sorry, I wasn't aware of that terminology change. Given that,

getStandardLanguageListWithoutConfigured() would seemingly encompass the technical meaning + take that terminology change into account?

Gábor Hojtsy’s picture

Title: Move language_admin_predefined_list to ConfigurableLanguageManager » Followup to Move language_admin_predefined_list to ConfigurableLanguageManager
Status: Needs review » Reviewed & tested by the community

Looks good.

sun’s picture

+   * Returns the standard language list excluding already enabled languages.

Sorry, missed this instance. s/enabled/configured/

Will cancel previous tests.

The last submitted patch, 16: drupal8.language-list-disabled.16.patch, failed testing.

The last submitted patch, 18: drupal8.language-list-disabled.18.patch, failed testing.

catch’s picture

Title: Followup to Move language_admin_predefined_list to ConfigurableLanguageManager » Move language_admin_predefined_list to ConfigurableLanguageManager
Status: Reviewed & tested by the community » Fixed

Would be a lot easier to follow this if the follow-up had been in its own issue. Committed/pushed to 8.x anyway.

  • Commit 9ac2a7d on 8.x by catch:
    Issue #2254495 by sun, ParisLiakos, alexpott: Followup to Move...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.