I have worked on multilingual Drupal sites quite a lot but some things still come as a surprise. I have used entity query in some cases but today I did encounter an issue where something did not work correctly.
So, there was a component on the page, which showed some news. Easy enough, let's build it with entity query this time and skip Views. Everything looks fine and seems to work just fine until a bug report comes in saying that making one of the news translations sticky brings it up in the default language.
I did check the basics like the sticky attribute is translatable and there were no visual issues on the code, the language code conditional was specified as well. I did some Googling around and found a hint - sort fields do use language code as a third argument.
So yeah, just setting the language code fixed the issue, an example is also below.
$news_query = \Drupal::entityQuery('node')
->accessCheck(FALSE)
->condition('type', 'news')
->condition('status', 1)
->condition('langcode', $lang_code, '=')
->range(0, 12)
->sort('sticky', 'DESC', $lang_code)
->sort('created', 'DESC', $lang_code)
->execute();
My original assumption was that lancode condition is already good enough which already limits things, but most likely the entity query does generate more complex queries where langcode condition does not apply.