Repository: pimcore/pimcore (language: php)

Issue:
[Bug]: language in grid view with localizedfields has no effect
### Pimcore version

11.2.2

### Steps to reproduce

1. Open a data object grid view with objects containing localizedfields on https://demo.pimcore.fun/admin/
3. Switch *Current language* by editing the grid view to e.g. *German*
4. Apply settings.

### Actual Behavior

English titles still shown:

![Screenshot 2024-04-17 at 17 09 12](https://github.com/pimcore/pimcore/assets/279826/612b7742-e82d-41ef-a6d2-2a688144b18f)

### Expected Behavior

German text should show for the localizedfields:
![Screenshot 2024-04-17 at 17 09 34](https://github.com/pimcore/pimcore/assets/279826/b0852c4d-87f6-4b5f-8667-fa744d1e2a57)



Discussion / hints:
The inverse is also true, change the user interface language to German and the grid language to English and the grid will show German text:

![Screenshot 2024-04-17 at 17 13 50](https://github.com/pimcore/pimcore/assets/279826/3765dead-2875-4039-b0a6-15dc5a2cf1f6)

This is still in 11.2.3
and you still could provide a PR to speed things up :smile: 
We have already fixed it with patches in our projects, it's just a FYI if you missed it.
maybe I got the sharing idea of open source wrong, but it would be great if you could share your patch in form of PR also to others.
I don't think you got it wrong. … not to rehash the entire discussion from a few months ago, but the gist is; Until Pimcore walks the walk of the talk they talk there is unfortunately negative value in participating past this level.
Hey Niklas! I sense some frustration—hope it’s not lingering from our lively ‘Open-Source vs. Commercial’ chat a while back! I really value our discussions and your insights. Just a reminder that our doors (and windows) are wide open, and we’re here to play fair and keep things light. Let’s keep the conversation going! Wishing you a truly wonderful weekend. If you’re up for a walk or a chat, or just need to catch some fresh air, give me a shout anytime. Let’s keep things upbeat! Hang loose, 💜 Dietz 

Fix patch:
diff --git a/models/DataObject/Service.php b/models/DataObject/Service.php
index 67c693c25a6..4580e532d85 100644
--- a/models/DataObject/Service.php
+++ b/models/DataObject/Service.php
@@ -393,7 +393,7 @@ public static function gridObjectData(AbstractObject $object, array $fields = nu
                         if (in_array($key, Concrete::SYSTEM_COLUMN_NAMES)) {
                             $data[$dataKey] = $object->$getter();
                         } else {
-                            $valueObject = self::getValueForObject($object, $key, $brickType, $brickKey, $def, $context, $brickDescriptor);
+                            $valueObject = self::getValueForObject($object, $key, $brickType, $brickKey, $def, $context, $brickDescriptor, $requestedLanguage);
                             $data['inheritedFields'][$dataKey] = ['inherited' => $valueObject->objectid != $object->getId(), 'objectid' => $valueObject->objectid];
 
                             if ($csvMode || method_exists($def, 'getDataForGrid')) {
@@ -641,13 +641,13 @@ public static function getFieldForBrickType(ClassDefinition $class, string $bric
      *
      * @return \stdClass value and objectid where the value comes from
      */
-    private static function getValueForObject(Concrete $object, string $key, string $brickType = null, string $brickKey = null, ClassDefinition\Data $fieldDefinition = null, array $context = [], array $brickDescriptor = null): \stdClass
+    private static function getValueForObject(Concrete $object, string $key, string $brickType = null, string $brickKey = null, ClassDefinition\Data $fieldDefinition = null, array $context = [], array $brickDescriptor = null, string $requestedLanguage = null): \stdClass
     {
         $getter = 'get' . ucfirst($key);
         $value = null;
 
         try {
-            $value = $object->$getter(AdminTool::getCurrentUser()?->getLanguage());
+            $value = $object->$getter($requestedLanguage ?? AdminTool::getCurrentUser()?->getLanguage());
         } catch (\Throwable) {
         }
 
@@ -687,7 +687,7 @@ private static function getValueForObject(Concrete $object, string $key, string
         if ($fieldDefinition->isEmpty($value)) {
             $parent = self::hasInheritableParentObject($object);
             if (!empty($parent)) {
-                return self::getValueForObject($parent, $key, $brickType, $brickKey, $fieldDefinition, $context, $brickDescriptor);
+                return self::getValueForObject($parent, $key, $brickType, $brickKey, $fieldDefinition, $context, $brickDescriptor, $requestedLanguage);
             }
         }
 


Test patch: