backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 40 forks source link

Views config files do not have any `_config_translatables` specified to allow for things like the views label and description to be translated #6608

Open klonos opened 3 months ago

klonos commented 3 months ago

The discussion around this was brought up in #4137, which is to discuss whether a specific translation-related commit in Views 7.x needs to be crossposted or not.

This was also discussed during this week's dev meeting, as part of the discussion around other issues (like #6511 and #6512). It was 40:13 into the recording. Here: https://youtu.be/CTPd63wSpAg?t=2413

During the meeting, we decided that it would be better if we created a separate issue and PR for the following:

indigoxela commented 3 months ago

Caution! Views does "its own thing" with translations.

There's a views setting to enable translation of certain strings (on by default) admin/structure/views/settings/advanced

So, things like views titles are always translatable out of the box. This has nothing to do with config translation.

klonos commented 3 months ago

There's a views setting to enable translation of certain strings (on by default) admin/structure/views/settings/advanced

Yup 👍🏼 ...I made sure to check that on a vanilla Backdrop site, and it is set to "Core" by default.

So, things like views titles are always translatable out of the box.

Nope 👎🏼 ...I've tested that in great detail over in #6610, and that is not the case at all. Here's a simpler way to reproduce this:

  1. On a vanilla Backdrop site, enable the Locale module.
  2. Go to admin/config/regional/language and add another language. You can choose any language, but prefer to add Catalan, since that one has the least amount of untranslated strings in https://localize.backdropcms.org currently
  3. Go to admin/config/regional/translate/translate and try to search for image library or image or library -> "No strings available."
  4. Head to https://localize.backdropcms.org and download the translation .po for the language you added in step 2. Make sure to select the one for the most recent version of Backdrop.
  5. Go to admin/config/regional/translate/import and import the translations you downloaded.
    • make sure that you select the right language in the "Import to" option
    • select the "Strings in the uploaded file replace existing ones ..." option, to make sure that everything is imported
  6. Import.
  7. Go back to admin/config/regional/translate/translate and search for image library -> you are getting more results now, including the string Select from Image Library (which is hardcoded - see #6511) ...but you are not getting the plain Image Library string, which is the label of the image_library view.
  8. Repeat the same for other views, but select something that has more chances to be "unique" - like promoted for instance -> you get many strings with that word, however the "Promoted cards" label for the promoted_cards view is not there.
  9. Create a custom view, and give it a unique name, like ABC 123. Repeat the search -> nothing 👎🏼

@indigoxela if what you say about views strings always being translatable, then shouldn't the labels of the image_library, promoted_cards etc. views be available for translation then? Something is definitely not working as expected. Am I missing something important here?

klonos commented 3 months ago

...if I'm doing this whole thing wrong, then I'm happy to be shown how it should be done properly. The goal is to be able to translate views labels/descriptions for starters.

indigoxela commented 3 months ago

@klonos multilingual can be a bit tricky for starters.

There's multiple ways, how Locale picks up strings. The one that applies to views is visiting the view via UI. At the moment, the view got imported, but the interface hasn't been visited, yet, Locale isn't aware of the new strings. To make it aware, visit the view (admin UI or a page...).

It's also necessary to have more than one language enabled on a site. Otherwise views_plugin_localization_core::save_string won't add the string and Locale won't be aware of it.

klonos commented 3 months ago

Thank you for providing all that insight @indigoxela ...it saves me a lot of time 🙏🏼

The one that applies to views is visiting the view via UI. At the moment, the view got imported, but the interface hasn't been visited, yet, Locale isn't aware of the new strings. To make it aware, visit the view (admin UI or a page...).

That's very interesting 🤔 @laryn mentioned the same in the Zulip thread:

You need to load some pages that use t() after that's all enabled, I believe.

So I tested that, and it still doesn't work for me. I visited the Views listing page, the configuration forms for the image_library and promoted_cards views, the pages/dialogs these views are producing. Yet, when I go back to admin/config/regional/translate/translate and search for "promoted" or "library", the labels of these views are not coming up in the results. I'm curious: when you search for these terms in the sites you are managing, do the views names come up?

It's also necessary to have more than one language enabled on a site.

Yes 👍🏼 ...my initial testing was done with only English, but I have also enabled other languages after that and tested again and again. I currently have for example English, Catalan and Greek enabled + imported their most recent .po files from https://localize.backdropcms.org. Still, the views labels are not showing up for me 🤷🏼

Specifically about the fact that you need more than one language, I agree, but we are not making that clear. We are showing elements in the UI that we should not be showing when only one language is enabled, but I am leaving all that for #6610 - I don't want to derail this issue here with all that.

indigoxela commented 3 months ago

FTR, I just jumped in here for a short hint, how to trigger string addition in Locale. Neither do I want to go further into details, nor do I want to start (or get involved in) any issue re rewriting our multilingual system. :laughing:

Just a short hint... and gone again. :wave:

klonos commented 3 months ago

Thanks again @indigoxela 🙏🏼 👋🏼

FTR (for others that come to this thread here): all I'm trying to do is to translate the name of even one single view. At the moment, I cannot do that. I have explained the steps that I am following. If I am doing something wrong, then please let me know what that is. I think that I have followed the right steps, which is now driving me crazy. So some sanity check please.

olafgrabienski commented 3 months ago

@klonos I've checked the issue, and indeed I wasn't able to translate the view name or a views display name.

Other strings are however translatable after adding them to a view. For instance:

klonos commented 3 months ago

Thanks for taking the time to test and confirm @olafgrabienski 🙏🏼 ...can you please clarify what you mean by this?:

... view name or a views display name

...I'm assuming that by one of them you mean the "Human-readable name" field, but what is the other thing that is not translated?

image

olafgrabienski commented 3 months ago

@klonos Sure, as soon you have more displays than the Default display, the displays get a name, e.g. Block, Feed etc. See screenshot below.


Display name (editing in the modal):

klonos commented 3 months ago

Thanks for clarifying @olafgrabienski 🙏🏼 ...one of the bullet points in your earlier reply though is "Display title", which you mention as being translatable. What is that then?