This is an attempt to clarify how the integration between the Language switcher block links and the Content translation links currently works and which is the rationale behind it. We need this to find a shared approach on some open issues.
While working on the new language negotiation system we introduced the concept of language type. Initially we made both interface language and content language configurable from the language detection and selection page. When it became clear that the Translatable fields UI was not ready for core inclusion, we decided to remove the ability to configure content language negotiation as, without field translation, it had no actual use in core and thus represented a serious UX bug. In core now interface and content language share the same value exactly as in D6, but we will enable the content language negotiation again in the Translation contrib project, which aims to enhance and replace the core Translation module.
The main drawback of the above choice was we were forced to restore the old D6 behavior. The current system generates a language switcher block for each configurable language; initially we made Translation alter only the content language switcher links but then, by making content language non-configurable, we had to suppress the content language switcher block, once again tying content translation links to the active interface language (see the first test in the if condition).
The idea behind this choice was that in the core version of the Translation module we should try to keep the overall behavior as close as possible to Drupal 6, to avoid problems to sites upgrading from Drupal 6 and not installing the contrib Translation version. Hence while fixing bugs, given the late stage of D7 development, we should find conservative solutions and work on more comprehensive/intrusive ones in http://drupal.org/project/issues/translation.
In this issue we should try to identify all the problems with the language switcher links and understand what can go in core and what can only be fixed in contrib.
Comment | File | Size | Author |
---|---|---|---|
#29 | translation-778528-29.patch | 18.99 KB | plach |
#26 | translation-778528-26.patch | 19.58 KB | plach |
#22 | translation-778528-22.patch | 19.32 KB | plach |
#19 | translation-778528-19.patch | 19.21 KB | plach |
#14 | translation-778528-14.patch | 17.46 KB | plach |
Comments
Comment #1
plachThis is a summary of the open issues somehow dealing with content translation links:
As I was syaing in the OP, I'd go for a conservative solution preserving most of the Drupal 6 behavior: since in D6 language switcher links and content translation links are strictly tied, I'd keep the current approach and make the language switcher links always match the content translation links, removing links from the language switcher when translations are missing. I realize that the need of showing all the language switcher links even if there are missing translations is perfectly valid and sensible, but that's not how the current (and the previous) system works and again it's too late to change things now (according to webchick we have to put our minds in release mode). OTOH the contrib Translation module will provide a content language switcher and will allow to deal with missing translations in a more complete way. In the same way it could let choose if showing content translation links for disabled languages or not, as both approaches have valid use cases.
In my mind this should be the core behavior:
Comments?
Comment #2
plachRelated issue: #631928: Language switcher block does not handle a single link correctly
Comment #3
sunI've read this issue two times on different days in the meantime, but I still don't fully grok it. Would it be possible to provide an explicit and targeted issue summary in the form of Problem + Goal + Details + Suggested procedure + Notes/Links? (example)
Comment #4
plachProblem
There are some open issues all of which concerning more or less the same parts of the Translation code: language switch links. There are a few proposed solutions, but IMO they need to be discussed altogether to avoid conflicting fixes. Moreover some of the proposed solutions involve UI or behavior changes that might be
problematicunacceptable at this stage of D7 development; this is probably caused by the fact that those solutions sat there waiting for months.Goal
Find a viable fix for each issue and create a valid overall reference for people dealing with the single patches.
Details
The OP provides some background on the current status and how we got here, while #1 summarizes the open issues and how I would address them.
Suggested procedure
We should examine each issue, understand how to fix it without introducing massive/intrusive changes to core and get back to the single threads with a working solution to implement. To achieve this we must first agree on the language switch links general behavior.
Links
Notes
While analyzing some of the proposed solutions, I realized that opposite behaviors were suggested to fix the same problem because people had different (valid) use cases in mind. Personally I think we should try to support all of them, but this is not feasible anymore, at least in core, as I was saying above. In the OP I tried to provide some useful background knowledge and also tried to make clear that what cannot be fixed here will likely be fixed in the contrib version of Translation. Here I'd try to come up with fixes preserving as much as possible the original (D6) design.
Comment #5
plachRetitling for clarity's sake.
Comment #6
plachI had a skype chat about this with sun, who found it clarifying. Reporting the entire log for people wishing to dive into the discussion:
Comment #7
good_man CreditAttribution: good_man commentedI can summarize the proposed solutions as I'm working on this issue lately. Should I do this in another issue?
Comment #8
plach@good_man:
Which issue? There are 5 different issues cited here.
Comment #9
good_man CreditAttribution: good_man commentedI mean this issue (#778528: Define the language switcher's correct behavior), since there are some overlaps & same problem IMHO. Most of my previous & current work involve developing sites with multi language features, I want to help in making D7 have a good solid ground for multi language sites.
Comment #10
steinmb CreditAttribution: steinmb commentedReading different issues on both core and contrib to try and get the overall picture of what the current state is and where we are going and what is still left to fix/do. Some issues is postponed, some moved to d8, some won't fix, some moved to contrib. I think it would be easier to get more involvment if we could sum up the current state of d7 and translation.
Comment #11
plach@steinmb:
Basically patches around are implementing what I proposed in #1. I seriously hope to get back to D7 the disabled content creation issue soon.
Edit: The contrib Translation project is waiting the core issues to be solved before working on them.
Comment #12
plachSince most of the issues above went in or are RTBC, it would be wise to improve the language switch link testing coverage.
Working on a patch soon.
Comment #13
plachAnd here are the tests. They won't pass until #518364: Nodes with one language don't affect the language switcher block is committed but aside from this they should be ok.
The content translation test (the first one) is more or less untouched, and so are the related helper functions (just moved around), while the language switch links test has been completely rewritten.
Comment #14
plachThere were some trailing white spaces around. Rerolled.
Comment #16
plachComment #17
plach#14: translation-778528-14.patch queued for re-testing.
Comment #18
sunSorry, only time for a quick review:
Should be assertLanguageSwitchLinks().
The conditional invocation of assertTrue() via $result should be removed.
Should be drupalCreatePage().
"Install a language or ensure it is enabled."
Wrong Doxygen @param formatting.
Powered by Dreditor.
Comment #19
plachThanks, sun!
Comment #20
sunI don't understand why this drupal_static_reset() is needed, since the surrounding test code entirely acts in the simpletest client site only.
'nid' would make more sense to be NULL here (nid is never a string).
This is very condensed - can we write the arrays in multi-line syntax and use if/else control structures where possible?
Since this method does not return what it finds, but rather whether it found something or not, it is a typical assert* method. Let's revert the renaming and also keep the final assertTrue().
Powered by Dreditor.
Comment #21
plachThanks again, the patch partially implementes the above suggestions:
Yes, but probably the static cache is populated anyway, since without it the test fails because the language negotiation changes are not reflected by the url rewriting.
This change is needed because in some cases a FALSE return value is the expected one, so to make tests pass we cannot always have an assertTrue invocation:
Comment #22
plachThe patch :)
Comment #24
plachUnrelated failure
#22: translation-778528-22.patch queued for re-testing.
Comment #25
plach@sun: is this ok now?
Comment #26
plachAgreed with sun a cleaner way to handle the static resets cited in #20.
Comment #27
sunThanks!
Comment #28
webchickThe first few hunks of this make sense.
Then we're off into random API-change-for-no-good-reason territory, and we can't change that stuff at this stage.
etc.
Let's get this pared down to only what's required to fix the bug. Thanks.
Comment #29
plach@webchick:
There's no bug fix here: we are just massively improving translation test coverage (mainly language switcher links behavior), and this involved moving some functions around to get a more readable file. Anyway, the attached patch reverts all the previous (unnecessary) API changes: now
assertContentByXPath
is unused, though.testContentTranslationLinks
is still replaced bytestLanguageSwitchLinks
, since the new test has a broader scope and the previous name would be misleading.Comment #30
webchickOk, thanks. This looks a lot better.
Committed to HEAD.
Comment #31
plach@webchick:
Who-hoo! Thanks a lot for spending all this time on the translation issues! I owe you a big, big, beer :)
Comment #33
Andrew Answer CreditAttribution: Andrew Answer commentedMay be my last patch can help to D6 users, see http://drupal.org/node/237696#comment-3798330