Motivation

On most foreign language or multilingual Drupal 8 sites there will at least be views in 2 different languages, the English views shipped with Drupal core and the Views created on the site for the site's foreign language. On multilingual sites, it is possible there will be views that do not apply to all languages and therefore only created in specific languages (although that is more of an edge case).

The shipped views are in English and they should say so in their configuration yml files. See #1935000: Some configuration entities are created as in language unknown which covers views.

However when users edit/create views, we should give them the ability to specify the language for their views. Why is this important? Well, only English shipped views are translated with the localize.drupal.org .po file system. Second, knowing which source language is used lets the configuration translation system offer it up for translation in other languages.

As an example in core, vocabulary config entities already have a language selector for the same reason (the tags shipped vocabulary is also English).

I think on the Views UI this would likely belong in the "edit name/description" popup screen, because those are the high level properties of the view.

Follow-ups

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

Status: Active » Needs review
FileSize
58.8 KB
3.74 KB

All right, figured out we don't have langcode exported for .yml in Views even, so removed those from #1935000: Some configuration entities are created as in language unknown and this is the only issue for it. Here is my suggestion.

Screenshot_3_6_13_1_13_PM.png

Cameron Tod’s picture

How does this relate to the content actually in the view?

For example, if a view contains a listing of Hungarian language nodes, but the View is set to English.

Does this language relate to the labels, titles, and other properties of the View, as opposed to its results?

vijaycs85’s picture

@cam8001 description of the element says "Language of the labels and other textual elements in this view". So looks like, it is for properties of view.

Gábor Hojtsy’s picture

@cam8001: yes, this is limited to the properties on the view, its displays, etc. Titles, empty texts, labels, etc. Essentially any textual input that will be translatable. It is important we know this language, so we can translate the view to other languages as needed. The empty texts, labels, etc. What kind of language filtering is active on the content displayed using the view itself is configured with the filters as usual. This language only corresponds to the textual configuration that you configure within views UI.

dawehner’s picture

FileSize
1.76 KB
5.5 KB

That's great. I'm wondering whether we should adapt all test views configs as well, but that feels like a little too much.

During testing I had an issue with language module disabled, which is fine, but the question is whether this code should be wrapped with an module_exists?
Other places like the node edit form doesn't do it, so this seems fine.

Added a small adaption to one of the tests.

Gábor Hojtsy’s picture

Nice test update! No, there is no reason for module_exists, language_select is a core type that falls back in itself to a value field if there is no language module enabled. In that case obviously you cannot change the language, but that is to be expected. You should not have multiple languages if you don't have language module enabled, so no way to switch to any other language is natural :)

Status: Needs review » Needs work

The last submitted patch, drupal-1935022-5.patch, failed testing.

Gábor Hojtsy’s picture

CustomBlockTranslationUITest fail should not be related.

Gábor Hojtsy’s picture

Status: Needs work » Needs review

#5: drupal-1935022-5.patch queued for re-testing.

YesCT’s picture

Is this per view, or per display?

Gábor Hojtsy’s picture

Per view. That is on a global level for the whole config .yml for the views. One view one language. You are expected to use the same language across your view. You can than translate that to other languages with http://drupal.org/project/config_translation.

dawehner’s picture

Yeah it got green. As gabor didn't had something to complain about that test, this feels RTBC. @YesCT: Do you want to have the honor? :)

dudycz’s picture

Status: Needs review » Reviewed & tested by the community

looks ok for me

YesCT’s picture

I can't look at it till later tonight, so, proceed. :)

YesCT’s picture

I already double checked.. I'll tripple check later.

But:

 661 sudo rm -r sites
  662  git checkout sites
  663  git status
  664  git add core*
  665  git commit -m "patch"
  666  drush -y si --account-pass=admin --db-url="mysql://root:root@localhost/d8-patch" --site-name=8.x
  667  mvim core/modules/views/config/views.view.frontpage.yml
  668  mvim sites/default/files/config_p90OzGn6UalqnTGU2hRUzsTID5ByjLqrPbA4V7c8icc/active/views.view.frontpage.yml 

http://screencast.com/t/9mmej4sc

I dont see the langcode in the .yml file for the active config.

YesCT’s picture

Ah, talked to @Gábor Hojtsy in irc, and he pointed out it might be at the end of the active config file. it was.

$ diff core/modules/views/config/views.view.frontpage.yml sites/default/files/config__rzyR0s0KXhc9jjr4I7HQl3nK300t-85ew12vzYGO2A/active/views.view.frontpage.yml

1,6c1
< langcode: en
< status: '0'
< module: node
< id: frontpage
< description: 'Emulates the default Drupal front page; you may set the default home page path to this view to make it your front page.'
< tag: default
---
> base_field: nid
8d2
< human_name: 'Front page'
9a4,5
> description: 'Emulates the default Drupal front page; you may set the default home page path to this view to make it your front page.'
> status: '0'
20c16
<           query_comment: false
---
>           query_comment: '0'
34c30
<           links: 1
---
>           links: '1'
54c50
<           group: 0
---
>           group: '0'
56c52
<             operator: false
---
>             operator: '0'
63c59
<           group: 0
---
>           group: '0'
65c61
<             operator: false
---
>             operator: '0'
87c83
<         title: false
---
>         title: '0'
99a96,101
> human_name: 'Front page'
> module: node
> id: frontpage
> tag: default
> uuid: 70e7b744-0224-4f63-b800-a9843b3433d3
> langcode: en

I think this is *not* a problem with this issue, but a separate issue. I'll open that separate issue. There were similar things found while working on the schema issues, so I'll link those to see what we did for them, in terms of ensuring that the save is repeatable: that the order is the same each time it's saved.

Gábor Hojtsy’s picture

Thanks for double checking. This should be RTBC then.

YesCT’s picture

FileSize
140.85 KB

steps to test

  1. fresh git pull --rebase
  2. sudo rm -r sites
  3. git checkout sites
  4. drush si (or drop tables in db and install by hand)
  5. enable the language module
  6. add a language
  7. add a view

uh, I dont get the page as shown above...
I get:
s01-add_view.png

YesCT’s picture

continuing the steps.

8. save the view [edit: added screenshot]
s02-add_view_first.png

in the active config, the yml for that view ends like:

    display_options:
      path: first-test
human_name: first_test
module: views
id: first_test
tag: ''
uuid: e1990aa7-8b5e-43dc-ac13-19d08c6ed5a2
langcode: und

should that be en?

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

I don't think a language selector has a place in the views wizard. The 80% use case even on a multilingual site is you create a view in the site's default language, and then translate to other languages from there. So I'm not sure it makes sense on the wizard to have a language selector. However the view should be created in the site's default language automatically, not und. It has human readable text, there is no way it is und :) So the missing piece seems to be the initial view creation should use the site default language, not the und default in config entities.

YesCT’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
184.84 KB
192.92 KB
29.35 KB
181.59 KB
126.35 KB
192.18 KB

best practices and 80% thoughts

note, from irc with @Gábor Hojtsy

a site building best practice is you create the view in the site default and translate from there with exceptions only for those which only apply to specific languages (much less likely)

So that is a reason for *not* showing the language select in the add view.

9. the view

s03-the_view.png

10. edit the name to change the language

that is .. strange. will need to change the button to name/description/language? that's a little long for a button name. it's also the place to change the tag.
Lets change the button to something like: change the overall view information. Hm. I'll think more on that in a bit.

s04-the_language_select.png

11. language options in select

11 a.
s05-no_undef.png

Should the language options here be similar to those allowed on content?
Maybe they are...
Oh, I was thinking of this drop down on the default language selection. That is (for content) the select for picking the default language, not the actual language select.

11 b.
s06-language_config_content.png

11 c.
Do we want to include Not specified and Not applicable ?

s07-lang_select_article.png

YesCT’s picture

Status: Reviewed & tested by the community » Needs work

cross posted with Gabor.

Needs work to make the view be created in the site default language.

Gábor Hojtsy’s picture

Not specified and not applicable does not apply to config that has human text, that just cannot be paired I think (they don't apply to vocabularies either for example I believe). The other magic languages from the content type config screen pictured does not apply because they relate to what instances created would inherit. For a view instance, that kind of setting does not make sense either.

dawehner’s picture

Status: Needs work » Needs review
FileSize
704 bytes
6.19 KB

Let's do that.

Gábor Hojtsy’s picture

Can we add a test condition that before the langcode was edited to fr, it was language_default()->langcode?

dawehner’s picture

That's indeed a good idea.

Added a general test for wizard plugin base.

Gábor Hojtsy’s picture

Looks good, except:

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.phpundefined
@@ -556,6 +556,7 @@
+    module_load_include('inc', 'views_ui', 'admin');

@@ -822,6 +823,7 @@
+      module_load_include('inc', 'views_ui', 'admin');

Why do you need these? It seems unrelated?!

dawehner’s picture

Well yeah, the views_fetch_fields() method is part of admin.inc, so you have to include it. As a wizard should work without external setup,
I think these lines make sense here.

Alternative it would be for sure also possible to just include the file in the test, but this feels worse.

Gábor Hojtsy’s picture

But there is no added views_fetch_fields(), it is pre-existing code?!

Gábor Hojtsy’s picture

Rerolled without those two suspicious hunks, let's see testbot!

Status: Needs review » Needs work

The last submitted patch, drupal-1935022-30.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
8.68 KB

There is no views.view.frontpage.yml anymore, so that hunk did not apply. Rerolling by not attempting to touch that nonexistent file :)

Status: Needs review » Needs work

The last submitted patch, drupal-1935022-32.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
9.58 KB

Indeed, we need to include those admin.inc files, looking at the fail in the views wizard. So I missed that. Rolling it back. So the only change from #26 (from @dawehner's last version) is that frontpage.yml is not anymore in core / in the patch.

dawehner’s picture

Gábor Hojtsy’s picture

Issue tags: +SprintWeekend2013

Reviewing at sprintweekend.

thamas’s picture

1. Installed D8 from fresh git clone (in English)
2. Added Configuartion inspector module
3. Enabled the Language, Interface translation, Content translation and Configuration inspector modules
4. Added a new language (Hungarian)
5. Applied the patch from #1935022-35: Add a language selector on views
6. Created a new view
7. Inspected the yml file of the view. It has 'langcode' => 'en', in it, which means the default language of the site.

I think we are OK. :)

thamas’s picture

Status: Needs review » Reviewed & tested by the community
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Actually the front page one was moved to node config. It still needs the same change.

dawehner’s picture

Status: Needs work » Needs review
FileSize
444 bytes
10.02 KB

Oh right.

saltednut’s picture

+++ b/core/modules/node/config/views.view.frontpage.ymlundefined
@@ -3,6 +3,7 @@ base_table: node
 core: 8.x
 description: 'A list of nodes marked for display on the front page.'
 status: '1'
+langcode: 'en'

Perhaps langcode and status should be at the top of the file, as in other files?

Otherwise, if no standard is defined, this looks like its good to go.

dawehner’s picture

FileSize
473 bytes
10.05 KB

Yeah that's a good idea.

In general it seems to be that we want to move the entity ID to the top as well, but sure this is out of the scope of this issue.

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community

Looks super to me now.

saltednut’s picture

Following steps from #37 one more time - more or less.

1. Apply patch #42
2. Install in English
3. Enable the Language, Interface translation, Content translation and Configuration inspector extensions
4. Added additional language (Czech)
5. Created test view. (yml output below)
6. Langcode 'en' is appended to the end of the file.

base_field: nid
base_table: node
core: 8.x
description: ''
status: '1'
display:
  default:
    display_plugin: default
    id: default
    display_title: Master
    position: ''
    display_options:
      access:
        type: perm
      cache:
        type: none
      query:
        type: views_query
      exposed_form:
        type: basic
      pager:
        type: full
        options:
          items_per_page: '10'
      style:
        type: default
      row:
        type: node
        options:
          build_mode: teaser
          links: '1'
          comments: '0'
      fields:
        title:
          id: title
          table: node
          field: title
          label: ''
          alter:
            alter_text: '0'
            make_link: '0'
            absolute: '0'
            trim: '0'
            word_boundary: '0'
            ellipsis: '0'
            strip_tags: '0'
            html: '0'
          hide_empty: '0'
          empty_zero: '0'
          link_to_node: '1'
      filters:
        status:
          value: '1'
          table: node
          field: status
          id: status
          expose:
            operator: '0'
          group: '1'
      sorts:
        created:
          id: created
          table: node
          field: created
          order: DESC
      title: Test
  page_1:
    display_plugin: page
    id: page_1
    display_title: Page
    position: ''
    display_options:
      path: test
human_name: Test
module: views
id: test
tag: ''
uuid: f862704e-d9e8-4f33-9f00-fe8a13977e77
langcode: en

This looks RTBC to me.

In general it seems to be that we want to move the entity ID to the top as well, but sure this is out of the scope of this issue.

Agreed.

Gábor Hojtsy’s picture

As YesCT pointed out above, the order of the keys in the files re-exported is not the same as is now, but that is true for many existing keys. She wanted to opne an issue for it. Either way, it is a pre-existing problem.

+1 to RTBC!

YesCT’s picture

Issue summary: View changes

added follow-up section and issues

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome!!

Committed and pushed to 8.x. Thanks!

Gábor Hojtsy’s picture

Issue tags: -sprint

Thanks all! Moving off of the D8MI sprint.

We'll need the same feature on menu config entities and possibly contact config entities. Will open issues on that too. Those are the items we identified in Budapest when doing the D8MI inventory on sprint weekend (https://docs.google.com/a/acquia.com/spreadsheet/ccc?key=0Aj6aNMguSdHCdH...).

klonos’s picture

I really think we should show the language select menu and the tag field on the view create form. I don't buy the reasoning behind the explanation in #21. What used to be an easy thing to do in D7 requires at least two extra clicks in D8 and is hidden behind a button that doesn't provide any hint these settings can be configured there.

dawehner’s picture

I really think we should show the language select menu and the tag field on the view create form. I don't buy the reasoning behind the explanation in #21. What used to be an easy thing to do in D7 requires at least two extra clicks in D8 and is hidden behind a button that doesn't provide any hint these settings can be configured there.

I understand that there might be use-cases in which you want to configure a lot of different views in different languages, but even for a multilingual page I think using the site default language will work in most cases. Additional your point that this was easier in D7 feels wrong. At least I don't know of a place on the add views formular where you can configure the language?

klonos’s picture

...the "easy thing in D7" was meant for the views tag only.

dawehner’s picture

Oh you talk about D6. In general I don't think that having a tag exposed primarily helps anyone.

Gábor Hojtsy’s picture

Added #1945226: Add language selector on menus which should be a relatively easy one to take following on from this one. Who wants to take that?

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

Anonymous’s picture

Issue summary: View changes

fixed typo