No Code Attached Yet bug
avatar sanek4life
sanek4life
13 Feb 2020

Steps to reproduce the issue

  1. Go to any article, category, tag or menu
  2. Click on the Association button.
  3. Select the desired category
  4. You will see categories not only in the selected language, but also in other languages

Expected result

  • Only show categories that match the selected language

Actual result

  • Categories are displayed in all, in any languages, regardless of which language has been selected

изображение

System information (as much as possible)

Joomla 3.9.15, PHP 7.2.26, MySQL 5.5.64

Additional comments

I now worked on a site that has more than 300 categories, more than 5000 articles and I am adding a new language on the website. I believe that if a specific language was selected, then categories should be displayed only in a specific language in this field. It is very difficult to constantly flip through all these categories and accidentally not click on another language, especially if the category name does not have a translation.

for example: categories such as iOS and Android in any language will be written in English and this makes it difficult to search and choose. Not all categories can be translated into another language.

avatar sanek4life sanek4life - open - 13 Feb 2020
avatar joomla-cms-bot joomla-cms-bot - change - 13 Feb 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 13 Feb 2020
avatar infograf768
infograf768 - comment - 13 Feb 2020

will look tomorrow but I am not sure we can solve this.

avatar richard67
richard67 - comment - 13 Feb 2020

@infograf768 We would have to re-populate or modify the category selection dropdown list after each change of the language. Am not sure either if we can do that. Or does showon also work for the option values of lists? That would be really cool, but I don't think it does. Will not help anyway as we can't add showon dynamically, I guess.

avatar sanek4life
sanek4life - comment - 13 Feb 2020

We would have to re-populate the category selection dropdown list after each change of the language. Am not sure either if we can do that.

изображение

In Joomla, this is already provided for articles. If during editing two articles you click on button Change Target, then we will see only articles for a particular language, and we will not see articles for another language. I think that this can also be done for categories, so that when choosing a particular language, only those categories that correspond to that language are shown. I think this is have the logic and rightly so.

изображение

@infograf768 I do not have to choose between articles for different languages, I see in this window only articles for a particular selected language.

I am not a developer, but I think it is possible to do this using javascript or similar technology. This will help a lot for editing articles and this will be the right decision.

avatar richard67
richard67 - comment - 13 Feb 2020

@sanek4life I see. But as far as I understand you mean with "Editing 2 articles" not the normal article edit view but the comparison view of the Multilingual Associations Component, right?

avatar sanek4life
sanek4life - comment - 13 Feb 2020

@sanek4life I see. But as far as I understand you mean with "Editing 2 articles" not the normal article edit view but the comparison view of the Multilingual Associations Component, right?

Yes. look at my first comment and first screenshot.

there are many articles in one language on my website. and now I am translating these articles into another language and I constantly see a mixture of categories for different languages in this field.

avatar richard67
richard67 - comment - 13 Feb 2020

Ah yes ... sometimes I am a bit slow .. thanks for clarification.

avatar infograf768
infograf768 - comment - 14 Feb 2020

The situation is very different.

The modal uses the forcedLanguage parameter (whether using Target in com_associations or using Select when editing an item).

In the Category field, we have a list of categories which is not filtered BUT the assigned language for each category IS displayed.
In the OP original screenshot one can see for example
Category (en-uk) (en-GB) where (en-GB) has been added by code to specify which language is assigned to this category.

So, if a category has the same name in en-GB or ru-RU, it will show and there is no confusion.
One will get iOS (en-GB and iOS (ru-RU).

Is it possible, when editing articles, to already filter the category list in com_associations depending on the Target language (knowing that only both categories set to ALL languages and the Target language should display) is a real question.

And, as I said, not sure we can.
If we could then it should also work (when the language filter is on) when editing a simple article via com_content, once the article language is saved and it is not set to ALL languages.

avatar infograf768
infograf768 - comment - 14 Feb 2020

BTW, that field is called categoryedit.
File is /administrator/components/com_categories/models/fields/categoryedit.php

avatar sanek4life
sanek4life - comment - 14 Feb 2020

Language settings on my website, if the screenshots confused you:

изображение

I use only 2 languages on my website: en-GB and ru-RU

изображение

I changed the flag for language en-GB. And I shortened the names from en-GB to en & from ru-RU to ru.

I followed @google’s recommendations for the correct language name on my website: https://support.google.com/webmasters/answer/189077

Supported language/region codes

The value of the hreflang attribute identifies the language (in ISO 639-1 format) and optionally a region (in ISO 3166-1 Alpha 2 format) of an alternate URL. (The language need not be related to the region.) For example:

  • de: German language content, independent of region
  • en-GB: English language content, for GB users
  • de-ES: German language content, for users in Spain

⚠️ Do not specify a country code by itself. Google does not automatically derive the language from the country code. You can specify a language code by itself if you want to simplify your labeling. Adding the country code after the language to restrict the page to a specific region. Examples:

  • be: Belarusian language, independent of region (not Belgium French)
  • nl-be: Dutch for Belgium
  • fr-be: French for Belgium

For language script variations, the proper script is derived from the country. For example, when using zh-TW for users in Taiwan, the language script is automatically derived (in this example: Chinese-Traditional). You can also specify the script itself explicitly using ISO 15924, like this:

  • zh-Hant: Chinese (Traditional)
  • zh-Hans: Chinese (Simplified)

Alternatively, you can also specify a combination of script and region—for example, use zh-Hans-TW to specify Chinese (Simplified) for Taiwanese users.

avatar infograf768
infograf768 - comment - 14 Feb 2020

This is unrelated.
I am now looking if I can filter the categories.
be patient please.

avatar infograf768
infograf768 - comment - 14 Feb 2020

Please test replacing the file /administrator/components/com_categories/models/fields/categoryedit.php by this one (after unzipping it);

categoryedit.php.zip

avatar infograf768
infograf768 - comment - 14 Feb 2020

@richard67
The diff is

diff --git a/administrator/components/com_categories/models/fields/categoryedit.php b/administrator/components/com_categories/models/fields/categoryedit.php
index 96bc7bd..8a68505 100644
--- a/administrator/components/com_categories/models/fields/categoryedit.php
+++ b/administrator/components/com_categories/models/fields/categoryedit.php
@@ -192,4 +192,13 @@
 		}
 
+		// When multilang is enabled, filter categories depending on item language
+		$extensionItemLanguage = $this->form->getValue('language');
+
+		if (JFactory::getApplication()->isClient('administrator') && JLanguageMultilang::isEnabled()
+			&& $extensionItemLanguage && $extensionItemLanguage != '*')
+		{
+			$query->where($db->quoteName('a.language') . ' IN (' . $db->quote($extensionItemLanguage) . ',' . $db->quote('*') . ')');
+		}
+
 		// Filter on the published state
 		$query->where('a.published IN (' . implode(',', ArrayHelper::toInteger($published)) . ')');

I think it should be BC. Can you test?

avatar infograf768
infograf768 - comment - 14 Feb 2020

Example of result
Screen Shot 2020-02-14 at 10 20 26

avatar infograf768
infograf768 - comment - 14 Feb 2020

Hmm
@richard67

Indeed, this would work for a new article but you are right

@infograf768 We would have to re-populate or modify the category selection dropdown list after each change of the language. Am not sure either if we can do that. Or does showon also work for the option values of lists? That would be really cool, but I don't think it does. Will not help anyway as we can't add showon dynamically, I guess.

So, it is possible to use this when associations are at state and language is already defined but changing language in a pure edit (for article as example), would not work...

Trying to figure how to solve this.

avatar MostafaHamedAbdelmasoud
MostafaHamedAbdelmasoud - comment - 14 Feb 2020

i have replaces it, there is not difference as shown.

it shows all categories too from all lang.

Screenshot (1)

avatar infograf768
infograf768 - comment - 14 Feb 2020

Anyway the patch should only be useful in com_associations and has to be modified (if possible)
No idea why it does not work for you. cache issue? file not really replaced?

avatar infograf768
infograf768 - comment - 14 Feb 2020

@MostafaHamedAbdelmasoud
You are right. If the language is not saved yet it does not work.

avatar MostafaHamedAbdelmasoud
MostafaHamedAbdelmasoud - comment - 14 Feb 2020

it is working now like a charm 👍

avatar MostafaHamedAbdelmasoud
MostafaHamedAbdelmasoud - comment - 14 Feb 2020

Anyway the patch should only be useful in com_associations and has to be modified (if possible)
No idea why it does not work for you. cache issue? file not really replaced?

do you mean this feature should only work in (com_associations) option and shouldn't work in any option else, like (com_content) option....etc?

avatar infograf768
infograf768 - comment - 14 Feb 2020

My patch is not good at all.

  1. It will not work when creating a new article as the language is not saved yet (whether in com_associations or normal edit)
  2. If an article language is modified, the category field may be emptied but the article may be saved and closed with the old category when editing an article directly.

So we need to limit it to com_associations and make it work also for new item.

  1. The problem is that the item is loaded in an iframe.
  2. the target language is in the Iframe itself.

Will try to find a solution, but not sure...

avatar MostafaHamedAbdelmasoud
MostafaHamedAbdelmasoud - comment - 14 Feb 2020

1- yes we can limit it to com_associations, i will find a solution too.
2- and you are right....we can't make it for a new item like new article as we want to select language first..... but we can handle it from jquery select the language first then show categories part depending on this language.
.
i want to work on it too; to get familiar with code and know how the components connect with each others

avatar jwaisner jwaisner - change - 14 Feb 2020
Status New Confirmed
avatar Hackwar Hackwar - change - 21 Feb 2023
Labels Added: No Code Attached Yet bug
Removed: ?
avatar Hackwar Hackwar - labeled - 21 Feb 2023

Add a Comment

Login with GitHub to post a comment