Filter Comments in the language of the node - multilingual

I put the comments on nodes but I'm puzzled about the fact that the comments are not filtered by language. And I don't find a solution about that.
When I'm on a french page, I got the comments in french but also in chinese.
Also when you post a new comment on a chinese page, stating that the comment is in chinese, there's a redirection to the default language of the node (here in french). I fixed this problem with a hook...
But I still have a mixed language of contents whatever the language node is. I tried different hook (hook_comment_view_alter or hook_comment_load) and I see the comments before rendering but I'm not able to remove the comment in different language of the page I'm on. So is there a way to filter the comments on the basic Drupal8 comment system ?

My complete solution here :
function hook_query_comment_filter_alter(Drupal\Core\Database\Query\AlterableInterface $query) {
$clangcode = \Drupal::service('language_manager')->getCurrentLanguage(\Drupal\Core\Language\LanguageInterface::TYPE_CONTENT);
$query->condition('langcode', $clangcode->getId());
}
You can strip the namespace with some "use".

I found the solution using hook_query_TAG_alter (so hook_query_comment_filter_alter for the comments).
see here :
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%21database.api.php/function/hook_query_TAG_alter/8.3.x

Related

What obfuscation is this?

I am currently a student working on a topic related to internet links and found this :
https://verinfopaypai.com/
When I put this set on the browser's search bar or when I copy it paste here it puts a link:
https://verinfopaypai.com/
This link is not mine and I am not linked to this link, I stumbled upon it by chance.
Is there any way to find out what obfuscation it is?
Thank you for your help
This isn't really obfuscation it's simply html entity encoding.
Each &#{number}; block represents a character in html.
You can see more about this here. https://mothereff.in/html-entities

TYPO3: How can I translate content elements within articles for news?

I am using the news extension: news and have enabled the content element rendering for my articles via extension setup (Use content element relation). This works great and redacteurs can use content elements in the news articles, too.
Furthermore I have localized and translated all the articles So if I switch the language in frontend then the translated articles will show up, but the content elements within this translated articles are still in the default language and not translated. So it seems that the translation of the content elements is not working for me.
For this reason I have checked the language of the content elements within the translated articles again, but the language settings of this content elements looks right:
I don't know what I am doing wrong and hope you can help me?
System:
TYPO3 7.6.12
news 4.3.0
UPDATE
I have found the following ticket: https://forge.typo3.org/issues/67905 and I have tried a updated version of the typoscript in this ticket, but it don't work for me, but maybe is this right way to get the content elements translated, too. Any idea?
I have found the solution :). News use RECORDS for content element rendering. So I have to add some typoscript.
setup.txt or setup area
config {
sys_language_overlay = 1
}

Google maps PlaceDetails in different language than English

i wanted to ask you if there is a way to get the google maps place details in a different language than English. I use AngularJs and i created a directive in which i perform the below steps:
User types in an autocomplete field
I get the results, i parse them and then I try to get the details like this:
service = new google.maps.places.PlacesService(theMap.map);
service.getDetails({
placeId: placeId,
key: googleMapsAPIKey,
language: 'el'
}, function(place) {
myLangAddressComponents = place.address_components;
});
The problem is that myLangAddressComponents information is still in English.
Any help would be appreciated.
Based on the documents regarding Optional Parameters: language,
The language code, indicating in which language the results should be returned, if possible. Note that some fields may not be available in the requested language. See the list of supported languages and their codes. Note that we often update supported languages so this list may not be exhaustive.
I think that there is no problem in your code, it is just not yet available in the requested language. I hope this clear some issues you've encountered. :)
Keep in your mind that you are passing the map instance in the PlacesService. As I saw from experimenting if the map is localized in el then the results would be also in el.

Cakephp with Translate Behavior

I have setted the translate behavior and it work fine, but I need something more.
If I haven't translated the fields, I need that the find() return me fields in default languge (this case eng).
How I could do it?
By default, if cake cannot find the language translations for the given language, it will default to what is set in the application. So this should already be working. Confirm that you have all of the english translations filled out. If this is still not working, you will need to provide some code and examples of what is not working.

CakePHP: I can't understand this in translate behavior

in cakebook on page http://book.cakephp.org/view/1331/Defining-the-Fields there is a sentence what I am not able interpret:
When defining fields for TranslateBehavior to translate, be sure to omit those fields from the translated model's schema. If you leave the fields in, there can be issues when retrieving data with fallback locales.
Can somebody explain me in a more simple way than it is in originally?
I think I have language problem as english is not my native :P
It means that in the following case:
class Article extends AppModel
{
var $actsAs = array('Translate' => array('title'));
}
You should not have the field Article.title (i.e. articles.title) in your database, otherwise you'll have trouble at some point.
Basically, when you design your table you plan to translate, omit those fields you want to translate.
Hope that helps!
I've never used that behaviour and I have to say that I would be looking elsewhere for an explanation of how to use it as I too (and I'm English) am having trouble understanding it.
My guess is that you need to ensure that there are no fields in the i18n table with the same name as a field that you are translating, i.e. if you are translating Post.name you must be careful not to have i18nTable.name
I don't use the console and there is no explanation of the required name or structure of the i18n table, so my comment is guesswork but I hope that it is in someway helpful.

Resources