-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate taxonomy terms #2934
Comments
@herbdool I think, this is a must have for multilingual sites. Any work in progress here? |
@bjoern-st I do not have any work in progress. Do you want to take a stab at this? I imagine it can be similar to the approach in #225 -- easier to implement and also easier for end users to understand. Anything more complex could go into contrib. |
@herbdool I'm not sure if I like the contrib idea. Taxonomy belongs to core so it should be translatable by default in core. |
@bjoern-st I think you misunderstand me. I'm not saying all taxonomy translation should be in contrib, just the more complicated ways of translating taxonomy. If you take a look at the issue linked above for menu translation @quicksketch took the approach of allowing for locale translation for menu items -- all menu items will be translatable. But he didn't implement "translation sets" which is more complicated and confusing to most people. My opinion is that the same approach is good for taxonomy. |
@herbdool Okay, I really didn't get that point. |
@herbdool @olafgrabienski |
@bjoern-st That sounds like it might work. Though a simpler version wouldn't have translation sets, which nodes use. I took a look through the PR and didn't see where you mention "using the node title from the underlying / translated node to create the translated menu item." |
@herbdool To understand the simple approach which would be similar to the current approach regarding menu items (#225), I'm trying to reformulate @quicksketch's approach described in #225 (comment), here for taxonomy terms:
So, it wouldn't be possible to translate a taxonomy term directly but to assign a language to a term and to create respective terms in another language, and these terms are not really 'connected' right? I guess that would work good with predefined vocabularies: first you create terms in different languages. Then, adding and translating node content, you just choose the terms created before in the languages you need. How would that work with free tagging? Let's say you add an English node and tag it with the term "example". How do we tell the term to be in English language as well? Should that happen automatically? Doesn't sound bad on first sight, but what about undefined language terms in this case? |
@bjoern-st @herbdool Regarding the different approaches (simple, without translation sets vs. like node translation) I'm double-minded at the moment: In my opinion, long-term it should be possible to just translate everything in Backdrop by simply using a "Translate" link, no matter how the translation is implemented technically. The node-like approach would allow such a behaviour in this case. If this approach is difficult to implement, or as long as it is controversial, I'd be very happy with a simple approach as well. |
@herbdool @olafgrabienski I see several pros for that approach:
What do you think? |
@bjoern-st Thanks for sharing your submodule idea! Are you suggesting it for any of the above mentioned approaches --simple, without translation sets vs. like node translation -- or to a particular one? So far I'm not sure about the idea... Depends also on the translation approach:
I'd suggest to decide about the translation approach first (and to discuss the submodule idea later). There are still open questions even for the simple translation approach, e.g. how would it work with free tagging, see #2934 (comment). (Going to tag the issue with "needs feedback".) |
I've taken an initial stab at this backdrop/backdrop#2360. I believe this was the simplest approach to implement. Since we don't want to put too many different ways of translating into core, either we stick with this approach and leave taxonomy locale for contrib, or we leave this for contrib and add ability to translate the terms as strings in locale to core. Like menu item translating this just provides the basic ability to set a language for a term. It doesn't provide ability to put terms into translation sets. This to could be left for contrib if we want to take that approach. The PR still needs some work: existing tests need to pass and maybe write some new. But it can be manually tested before that. |
I cannot say much from a technical approach view, since this is way over my head. My main concern is multilingual D7 sites being ported to Backdrop. If we can accomodate that, then I am assuming it'd be fine. |
...@herbdool I have done a very rough pass and left some comments in the PR. Do you plan to add an option to enable multilingual support per vocabulary? |
The intent of this PR, similar to the intent of the multilingual menus, is not to replicate all the functionality of i18n but of providing a basic option in core. So that means that some sites can be upgraded to Backdrop but others not. It all depends on the multiple, complex options they used in i18n. @klonos, what do you mean by "option to enable multilingual support per vocabulary"? Currently the PR just focuses on the terms. A term can be "undefined" by default or it can be a language. |
@herbdool in the content type configuration form, there is an option to enable multilingual support: ...if this option is not enabled, then the language selection dropdown menu is not shown in the node add/edit form for that content type. I would expect the same functionality to be available per vocabulary. |
As I saw in the sandbox site, the option is now available in the PR. |
Impressions from my look at the sandbox I've created a couple of test posts, first in a vanilla site, then with enabled multilingual support in a vocabulary and later also with multilingual in the post content type. With multilingual support, the language filter on the term page of a vocabulary works fine! The filter options are: "All languages", "English", "Italian" and so on, depending of the enabled languages on the site. As the filter help text explains, Terms with the "All" language will be shown in every language. In my opinion, to manage vocabularies with many terms, it would be useful to also have "only" options for the single languages: "Only English" and so on. In an early comment above I've asked how we would set the language of taxonomy terms if editors create terms via the tag style widget. Here's an idea: When a person writes a post and if she sets the language of the post, then the tags of the post should be set to the same language. Testing the sandbox, actually (and first unconsciously), I expected such a behaviour. @herbdool What do you think about it? That's all for the moment. Let me know when I should have a look at specific other parts of the PR! |
Thanks Olaf for reviewing.
|
I have given the PR sandbox a go and it works really good @herbdool 👍 Here are my comments:
I have not tested the tokens, nor deleting/adding languages or disabling the language module, nor how translation works. The autocomplete thing is tough to answer because it is per use case 😑 Thanks for your work on this so far @herbdool 🙏 |
Thanks for your reply @herbdool!
NB: the latter alias was only displayed in the respective field of the Edit form; when I viewed the term, it wasn't aliased (but was like |
Thanks for the feedback. I'll try tweak things a bit more. By the way, @olafgrabienski I took a look at the link you pasted https://www.drupal.org/project/i18n/issues/2506981. It looks like it addresses one part of it, which is the easy part: when saving the node it will set the language of new terms based on the node language (if it's set). However, it's missing the part of what existing terms to show in the autocomplete. That's the tricky part because the node language could change in the middle of selecting terms. I don't think there's any easy solution for this part. Alternatively, we could not even try: allow them to select existing terms regardless of language. Or, allow them to only select existing terms based on the interface. The latter seems too convoluted to me. |
...I know I am not helping, but wanted to point out that we would not be having such issues if we were using translation sets. We would be using the "main" or "source" versions of the terms in the autocomplete if no translated versions available, and when rendering content, we'd link the translated version for the current language. Just sayin' |
@klonos I'm not sure if that's true. This isn't as simple as showing a node; this is a reference between two entities. Showing the "translated version" in the autocomplete would mean that it would need to use the interface and not the chosen language of the node. And it seems it would mean that the term ids saved would always be the source id, or alternatively the term ids would switch depending on the interface. I'm not sure if we'd want that. I think if it were that easy then D7 would have already had it figured out. |
Hmmm, ...I don't claim to have deep knowledge of i18n and l10n; this is just how I remember things used to work. But it's been many years since last time I've touched a multi-lingual site and my memory is most likely failing me ...plus back then I would not even "dare" look at the code and try to understand it. ...it was just my first steps into Drupal-land and hesitant surface-scratching of php coding. I guess what I am trying to say is that I have faith in you @herbdool ...please carry on 😄 |
@klonos I'm not saying I am 100% certain but my feeling is that it's complicated. I took a look at adding automatic help text to autocomplete tags on front end. I can't tell if it is possible or if it's recommended (e.g. how does a site builder remove the text if they need to?). On the post content type a tags field is created on install with some "Enter a comma-separated list of words..." text, but on any other term fields created there is no automatic help text. I can see the usefulness of this but looks like it is up to the site builder to ensure the field text on the front end reflects what the user needs. |
@herbdool, thanks for updating the PR! I've seen that the setting "Follow interface language" isn't anymore on the Field settings but on the general field configuration page, and now it can be changed even if there is already data for the field in the database. I think that's a great improvement! (The title of backdrop/backdrop@bfc7cb4, "Move setting to widget", is a bit misleading though. Did you first consider to move it to the Widget type tab? That would be an even better place in my opinion but if it's difficult, the general tab seems also fine to me.)
Thanks also for your thoughts on interface vs. content language above - #2934 (comment) - and on the PR page - backdrop/backdrop#2360 (comment). Being able to use content language as an alternative, would be great, even if only for new terms and not for term suggestions in the autocomplete widget. I see that it's tricky for term suggestions, and I have no idea how to handle it. (If others have ideas, we can still make follow-up improvements.) Speaking of follow-ups: Do you plan to add a setting for using content language in this issue, or would you prefer a follow-up for content language related features? |
@olafgrabienski I can change it in here to follow content for new terms. It is much easier and simpler for new terms than for autocomplete. It's not possible to show on the widget tab AFAIK. That is reserved solely for switching widgets. I moved the setting to |
@herbdool I've tested the updated PR, see backdrop/backdrop#2360 (comment). Apart of that, I guess there was a misunderstanding in the discussion about following interface vs. following content language. Based on the state of the PR where terms were following the interface language, I thought that following the content language would be an additional approach, leaving the interface approach as an option e.g. for people who upgrade from Drupal 7 / i18n and don't want to change the behaviour. |
The "Follow content language" checkbox should not be available if the multilingual support is not enabled in the vocabulary. Right @herbdool? |
Tested the PR again, it works generally good now! If the checkbox "Follow content language" on a content type is enabled, the language of new terms becomes the same as the content language (or "All", if no content language is set). I agree with @klonos that the checkbox on the content type shouldn't be available if the vocabulary isn't configured for multilingual support. (Or, we could make it available but not editable in this case, and add a hint to the vocabulary setting.) Speaking of vocabulary configuration: The span element with the setting summary for the "Multilingual support" tab is empty, irrespective if multilingual support is enabled or not. |
@klonos @olafgrabienski yes, it won't assign language to terms if it's not enabled on the vocabulary but it's not possible, or at least not easy, to make the checkbox depend on the vocabulary. That's because the vocabulary select is on the same form as the checkbox. It would have to be some fancy JS which I don't know if we use anywhere else since generally these need to be usable without JS. We could just make a note on the help text. |
@olafgrabienski can you explain more what you mean by empty span? |
@herbdool Sure, I'll try: it's the description text usually found in the vertical tabs which changes depending on the setting. Here's a screenshot where I've highlighted the element and its markup on the "Permissions" tab. You'll see that in comparison the text is missing on the "Multilingual support" tab: |
@olafgrabienski okay I've fixed that. @klonos I've edited the description. If you're okay with it now (and my reasoning for why the follow_content_language can't be improved much further) then are you okay with RTBCing this? |
Yep, RTBC 👍 ...I might take a crack at figuring out if there's an easy way to have the checkbox be disabled if multilingual is not enabled, but that can be a follow-up 😉 |
I agree as well, and thanks for your work, @herbdool ! So, potential follow-ups would be:
|
@olafgrabienski thanks! Your first and second follow-ups are both tricky. The first would require JS and I'm not sure if that's a good idea if it's hasn't been done somewhere else in field settings already. The vocabulary isn't readily available to the widget settings. The last one I'm not sure is important to most people. You convinced me that following the content language was more intuitive and more likely to be assumed. But it could be a contrib module. |
I've merged backdrop/backdrop#2360 into 1.x for 1.12.0! Thanks @herbdool, @olafgrabienski, @klonos, and @bjoern-st! You guys really rocked it to put this together! |
Describe your issue or idea
Like @quicksketch's pared down approach for menu items #225 perhaps we can approach taxonomy terms the same way.
This would mean terms have a language but we leave translation sets for contrib.
PR by @herbdool: backdrop/backdrop#2360
The text was updated successfully, but these errors were encountered: