Problem/motivation
In Drupal 8, we introduced new special languages which are maintained technically on the same level as user-added languages. However, the only thing that users could do with them was to order them with the rest of the languages, which only has an effect on how those languages show up for admins in select lists (special languages will not show up in language switcher blocks for example, since they are not human-understood languages). This created lots of confusion apparent in our first user testing. People did not understand the special "multiple" language (see #1869292: Remove confusing "multiple" language from core) and further could not understand why they have a disabled radio button on special languages which is not useable and could not get the significance of the special languages in the reordering. Most of them did not understand why are such system internals showing up on their configuration page.
Proposal
Remove the special languages from the language listing page, so they are not reorderable with the other languages. Ensure the special languages show up after the user created (non-locked) languages though.
Remaining tasks
Initial proposed patch implements the UI change only.
- (done) Find help text that refers to non system languages and simplify it
(novice) remove the reordering cross-hairs when only one language shown in the uito be done in related issue- (done) add tests that a new language added still results in the two system languages being last in weights (it's ok to do this in part without implementing the fix)
- (done) add tests that reordering languages still results in the two system languages being last in weights (it's ok to do this in part without implementing the fix)
- (done) Need to adjust weights of special languages when weights of non-specials change, such as when
- new language added
- languages are re-ordered
- languages (weights?) were saved differently outside of the form (see #13)
- (done) when patch with ui changes is posted, add updated screenshots
- (final?) review
UI changes
with patch:

Related
- #1887582: update #type=table for language list
- (remove default column, which especially does not make sense with one row) #1803638: Improve default language change process (ui and help text)
- (remove reorder handles and row weight, which especially does not make sense with one row) #1016056: Hide tabledrag handle and "Show row weights" when there is only one item in list
- (remove submit when there is only one row) #1855402: Add generic weighting (tabledrag) support for config entities (DraggableListController) (or make a new issue and copy and paste code from there as a start)
| Comment | File | Size | Author |
|---|---|---|---|
| #62 | 1869328-remove-special-languages-from-ui-62.patch | 9.75 KB | yesct |
| #62 | interdiff-60-62.txt | 1.14 KB | yesct |
| #62 | simplify-s01-nopatch-2013-01-15_1841.png | 96.12 KB | yesct |
| #62 | simplify-s02-nopatch-showweights-2013-01-15_1843.png | 99.09 KB | yesct |
| #62 | simplify-s03-twolanguages-2013-01-15_1851.png | 80.33 KB | yesct |
Comments
Comment #1
miro_dietikerFor development purposes we sometimes need to switch to coding language (previous "English") ... thus disable the translation stuff.
I fully agree that this is not something regular "users" should deal with.
From some point of view, users might even understand the system if these options are
How would you suggest we should deal with that "neutral" view best? Add that special language configuration to e.g. devel?
This is a core functionality and it (enabling/disabling translation layer) still is core system behaviour. Hiding too much from the user might not help them to understand how the system works.
Comment #2
gábor hojtsy@miro: the special languages that were hidden were not possible to delete or switch to. The only thing was possible for them was to define their order within select boxes (by dragging them in this list). See screenshot on #1869292: Remove confusing "multiple" language from core (the default radio button is disabled on the special languages, see the code removed). So the only functionality this proposed patch removes is the ability to move special languages around (eg. inbetween the human created languages, before them, etc) which is not a very realistic feature (even if it would make sense, it would probably make sense on a per entity basis, which is not possible).
There is no other functionality removed.
Comment #3
plachI fully support this.
Comment #4
Bojhan commentedHow do we expect to support the usecase for those who do want to move it around?
Comment #5
miro_dietikerAck.
Comment #6
plachI am not speaking for everyone, obviously, but I never felt the need to reorder those or seen feature request about it.
Comment #7
gábor hojtsy@Bojhan: well, that is not an existing feature in Drupal 7. So we imagined there would be a need but the admittedly limited use of it hinders usability in basic operations, so I think it was legitimately sidelined as an imaginary need :) The special languages do have weight in the DB (and we need to fix their weight when adding new languages, still to be solved in this patch), so anybody in contrib can do a UI that lets people reorder them, or modify this form to make it happen.
Comment #9
gábor hojtsyThe notices were due to language_admin_overview_form_submit() assuming the locked languages will be in the form. They are not. The fail was in Drupal\views\Tests\UI\DisplayTest->testCloneDisplay which I can hardly believe has anything to do with this patch. Fixed the notices, let's see this again!
Comment #10
gábor hojtsyStill needs code adjustments to make sure newly added languages don't show up after/inbetween locked languages in language dropdowns. Theoretically weights might also be recalculated when languages are reordered (if they were saved differently outside of the form), so I think that case should be covered too.
Any takers?
Comment #11
klonos[Just a to-do note for if/when this gets implemented]
We need to adjust this part of the help text because it wouldn't make sense anymore:
Comment #12
yesct commentedComment #13
yesct commented@Gábor Hojtsy
I agree, but then this last part confuses me. What do you mean? Maybe give steps to test for just that bit.
This is a great issue for someone to jump in to.
Comment #14
yesct commentedFor help text:
...at least two languages added on the languages administration page
Comment #15
gábor hojtsy@klonos: that text is not introduced by this patch and is not yet in core, so it is a good cross-reference, but has no relevance here.
@YesCT: core does not have a way to order languages outside of the order screen (except when a new language is added, I think it does not get any weight and therefore likely shows up at top of the list). Ie. you can test this patch, manually add a couple languages and likely see the locked languages show up at odd places in language select dropdowns (intermixed with human added languages).
Comment #16
gábor hojtsyDid not intend to remove Needs tests.
Comment #17
yesct commented@Gábor Hojtsy:
Good point. That is from #1810386: Create workflow to setup multilingual for entity types, bundles and fields
I think that or similar text is somewhere else though.
Comment #18
vijaycs85Hope,site-wide drag-link with single item is UX defect. fixing it in tabledrag.js. and updating patch.
Comment #19
vijaycs85Comment #20
gábor hojtsyWell, it would still have the weight select box on the table, which is equally puzzling I think :)
Comment #21
yesct commentedSo this would fix this site wide too? [edit: question is regarding cross hairs drag and drop on list of only one thing]
Comment #22
yesct commentedI'm thinking to change the issue title as this will effect more than just this one multilingual page.
Or to break this out into it's own issue.
It might have wide consequences.
Comment #23
vijaycs85@Gábor Hojtsy : True, but as you can see in this image, by default weight is not enabled. So for author (or non-technical person) point of you, they are not getting confused as much (I guess). But it is up to the statistic on your user testing etc.
@YesCT: Yes, this is side-wide fix. However I haven't tested with intention etc and I do agree that it makes consequences.

Comment #24
gábor hojtsyOh, so the "Show row weights" feature remains (hides the weight) but the drag feature does not come in. Hm, interesting. This might be a good solution, yeah :)
Comment #25
gábor hojtsy@vijaycs85: so the more involved problem that this was left open for and needing tests is if you add a couple more languages, those would get weights that are higher than the special languages in the languages table (Not applicable, etc). so the list order would be upset. The weight of the special languages would need to be reset properly when submitting this form or adding new languages or removing languages I think. (Unless the problem I'm explaining is not reproducible, I did not actually test yet :).
Comment #26
andypostThere's a more unified issue about sorting here #1855402: Add generic weighting (tabledrag) support for config entities (DraggableListController)
Patch still needs work and tests
We know the number of languages so better to:
1) change a type of #radio to #value when is not multilingual + attach a table drag same
2) remove unused column
Comment #27
gábor hojtsy@andypost: languages are not yet config entities, so that does not apply (yet).
Comment #28
yesct commented#1803638: Improve default language change process (ui and help text) might remove the default column.
Comment #29
vijaycs85Updating system languages weight on add/edit/delete a language and its test case.
Comment #30
andypostLet's get this in first and continue in #1803638: Improve default language change process (ui and help text) by copy-paste code from #1855402: Add generic weighting (tabledrag) support for config entities (DraggableListController) for hidding a weight and submit elements when there's only 1 row.
@YesCT Please file a follow-up issue about #22 - we have a lot of draggable UIs in core
Comment #31
gábor hojtsyI don't agree with the weight logic. It seems like the system languages are weighted *before* the user created languages. That was not the behavior prior to the patch, the custom languages were weighted before the system languages, right? Am I missing something?
Also, minor code style comments: 'autoconfiguration' can be left as one word AFAIS and the new API function's phpdoc contains an extra empty line, that should not be there.
Comment #32
nod_Not straightforward to do from the JS side: #1016056: Hide tabledrag handle and "Show row weights" when there is only one item in list.
The same code as #22 was committed but had to be rolled back because it broke pretty much all field ui and block admin (that is currently broken for another reason #1875632: JS settings merging behavior: preserve integer keys (allow for array literals in drupalSettings)).
Comment #33
nod_proper tags
Comment #33.0
nod_Updated issue summary remaining tasks to help people jump in.
Comment #33.1
yesct commentedUpdated issue summary to clarify what will be done in separate issues.
Comment #34
yesct commentedupdated issue summary to clarify what will be done is separate issues.
Comment #34.0
yesct commentedhtml correction
Comment #35
yesct commentedadded related issue to convert table. #1887582: update #type=table for language list
That issue could use a link to another completed issue that did a table conversion to make it easier for someone new to replicate it on this table.
Comment #36
yesct commentedComment #37
gábor hojtsyYes, we did agree earlier to remove those references too, when we remove the display of them in the admin list.
Comment #38
manningpete commentedRemoved the words "non-system" from "non-system languages" on two help pages. admin/help/locale and admin/help/translation_entity per #36.
Comment #39
vijaycs85As per @YesCT changes in this issue, removed JS changes from this patch.
reg:#31, Still the system languages get the weight last. Here is a sample scenario:
Default state:
When you drag FR to top, there is a possibility we would get like this:
on submit this form, we try to find the minimum weight of Frech & English (i.e. locked=0) and set their weight to weight-1. so French gets -29 and English as -28 and now set invisible system language weight as -30. So the final output after language_update_default_weight() would be like this:
This assures that system languages always stays with low weight. Please advise, if there any better way.
Comment #40
gábor hojtsyAll right, so I don't know how that default state comes about, but is not really intended.
If you look at http://api.drupal.org/api/drupal/core%21modules%21language%21language.in... it sets up the default language and *then* adds the system languages with higher weights, ensuring the system languages are at the end of the list. (http://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/functio... gets the default language weight so it can set up the system languages with higher weights).
Also, http://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/functio... itself, when the language module is not enabled would return the default language and *then* the system languages, again later in the list (and with higher weight).
So the existing code demonstrates at least at two places that we want to have the system languages listed *after* the user created languages through weighting. Therefore it would be important we ensure that behaviour with this patch as well. ie. instead of taking the minimum of the weights for the non-locked languages, take the maximum :)
Comment #41
yesct commentedI think we have some misunderstanding about: higher weights, lower weights, first in list and last in list.
Higher weights (more negative) "float" to "rise" in the list to be "first" at the top of the table.
Lower weights are bigger. 20 is lower eight than 10. Lower weights "sink" to be "last" at the bottom of the table.
The system languages should sink and be at the bottom of the table (if they were in the table). So the are last at the bottom of the language select on the content add and edit pages.
Please correct if I mixed up lower/higher/float/sink :)
Comment #42
gábor hojtsyNo, more negative weights are lower, not higher :) -57 is *lower* than -12 :) Weights are simply ordered in order of the number,-57 will be before -12 which will be before 0 which will be before 12 which will be before 57. System languages should have *higher* weight (be a bigger number :) compared to user editable languages.
Comment #43
vijaycs85Updating review comments
Comment #44
gábor hojtsyFrom IRC review:
Comment #45
vijaycs85Updating changes for #44
Comment #47
vijaycs85Updating test cases to work with higher weight.
Comment #48
gábor hojtsyThanks! I only looked at the actual code now not yet the test. There are confusions around low/high in the test as well (comments vs. code :) but I assume you'll update the test a bit anyway due to the logic changes that seem to be needed. Thanks for working on this and keep it up :)
I think a better name for this would be language_update_locked_weights(). It updates multiple weights and does not relate to the default language :)
We can say locked languages here, that is correct internal terminology.
Minor: The comment is not indented properly.
Major: there could be any other system languages. It is possible that contrib modules add any other locked languages. So locked = 1 would be a more accurate condition here.
Also, it would be ideal if we could retain the existing order of locked languages. By setting all of them to the same weight, they will be listed in alphabetic ordering after the user configured languages. What I'd do is to use language_list(LANGUAGE_LOCKED) (or equivalent SQL) to get a full list of locked languages and update them in their order as returned with weights increasingly higher than the highest configured language. So that way they would retain their order and all be higher weighted compared to the configured languages.
Hope that is clear :)
Once again, this is fine as "autoconfiguration" IMHO. It looks like an odd word, but "auto configuration" makes less sense.
Comment #49
vijaycs85Thanks @Gábor Hojtsy. All review comments in #48 make more sense. Updated changes for them in this patch.
Comment #50
vijaycs85Sorry, missed test file comment changes...
Comment #51
gábor hojtsyLooking better, thanks! Most comments are now on the test :)
This still has an empty newline. Also I'd pluralize the weights and not languages, so:
"Updates locked system language weights."
Why the space between the variable and ++? :)
"System languages has ..." => "System languages have ..."
The inclusion of "limit 1" in the query is pretty MySQL specific, that should not be used as-is in a database compatible fashion :)
Anyway I'd make this a bit more specific, eg. do a drupal_static_reset('language_list') on top of this method to ensure the language list is reset and then compare weight of all items in language_list(LANGUAGE_LOCKED) to the high weight of the configurable languages. That would ensure all of them got a properly high weight.
Also I'd rename to hasCorrectWeights() or something, because we are not giving the same weight to all languages anymore, so the method name is misleading.
I'd rename to getHighestConfigurableLanguageWeight() or something descriptive like that :)
Comment #52
vijaycs85Fix for review comments in #51.
Comment #53
vijaycs85Comment #55
vijaycs85#52: 1869328-remove-special-languages-from-ui-52.patch queued for re-testing.
Comment #56
yesct commentedshould this be > (instead of >=)?
Comment #57
vijaycs85Updating patch with review comment in #56
Comment #58
gábor hojtsyThanks!
This is the 3rd time I'm making a note of this extra unneeded newline.
keep them on top
language weights
You've accidentally removed a line here.
Higher weight compare to what? I'd write:
"Validates system languages are ordered after configurable languages."
Naming this an $event is pretty misleading, Drupal has the concept of events which is unrelated to how you use it here. I'd name it $state or something along those lines, sounds more natural.
Also t() is not allowed in assert() messages, you can use format_string() as a replacement that does not translate text.
Comment #59
yesct commentedAlso, there was another issue where it was pointed out to use "for example" instead of e.g.
See #1877632-25: Improve comments and clean-up code for EntityNG and the TypedData API comment 25, point b: @jhodgdon
since we are making a new patch anyway. I think a better variable name for $system_lang_weight would be $max_configurable_language_weight
(The locked system languages are like "Not specified" and "Not applicable". The Configurable non-system unlocked languages are like English or Spanish.)
Also (and this is a very minor thing) but it might further add clarify to rename $language to $locked_language.
I think this configurable is exactly unlocked. and the "or" confuses this a bit.
Get a more precise meaning with: Helper to get maximum weight of configurable (unlocked) languages.
@return directives should usually have a description explaining what they return.
See http://drupal.org/node/1354#functions
Comment #60
vijaycs85Thanks @Gábor Hojtsy @YesCT for your time. My comments on individual items below:
#58
#59
Comment #61
yesct commentedwas trying to clarify why name for $system_lang_weight should be $max_configurable_language_weight because it's returning the max of the config languages which are not system languages (usually). If it had English and Spanish and their weights were -2 and -1, then the max would be -1, and "not specified" and "Not applicable" and other locked (system) languages should have a weight greater than -1 so that they would sink in the list to be below them.
Comment #62
yesct commentedWorks great! Manual testing results: weights match the behavior of the unpatched. Adding a language, reordering and deleting all result with reasonable weight values (and the same as the unpatched) and the language select looks great (the same) in the patched also.
Comments should use correct grammar. If "for example" was the beginning of a sentence, it would need to be "For example". But here it is just a phrase, so the mistake is really that the period before should be a comma. Actually the wording here is still weird. And... the default is not listed: 'by default'. Hmm.. and it's optional. See http://drupal.org/node/1354#functions for examples of comment standards.
updated screenshots:
1. before, weights hidden
2. before, weights shown
3. with patch
4. with patch, show weights
5. with patch, reorder (matches weights of unpatched)
6. with patch, langselect shows locked languages are sinking correctly
7. with patch, what it looks like with just one row
8. with patch, show weights
Help text
The help text pages also read well, more simple now.
They are the content language config page (from the wizard issue): admin/config/regional/content-language
And the entity translation help (content translation help): admin/help/translation_entity
Next
I would have rtbc'd this except I changed the comment...
so next is a (final?) review.
Comment #62.0
yesct commentedadded related issue to convert table
Comment #63
gábor hojtsyLooks good to go now! Thanks for sticking to it and producing quick iterations :)
Comment #64
dries commentedCommitted to 8.x. Thanks!
Comment #65
gábor hojtsySuperb, thanks!
Comment #66
yesct commentedComment #67.0
(not verified) commentedupdated with actual screenshot from patch and updated remaining tasks