- Status changed to Fixed
almost 2 years ago 11:09am 19 January 2023 Automatically closed - issue fixed for 2 weeks with no activity.
As reported in #3024767-50: Drupal.t() doesn't inherit parent translations. → by julien.sibi → , who also provided the attached patch:
Hi,
on my local drupal instance working with 2.0-rc3, i still don't get inherited translations in drupalTranslations DOM variable.
In my language_hierarchy_configuration, i have some local languages inheriting parents languages. In my example 'at-de' is inheriting 'de'.
in _locale_rebuild_js (core locale module) . I can see this :
// Construct the array for JavaScript translations. // Only add strings with a translation to the translations array. $conditions = [ 'type' => 'javascript', 'language' => $language->getId(), 'translated' => TRUE, ]; .. foreach (\Drupal::service('locale.storage')->getTranslations($conditions) as $data) { $translations[$data->context][$data->source] = $data->translation; }
so when $conditions array is build, we get $conditions['translated'] to TRUE.
it will lead to call dbStringSelect in StringDatabaseStorageDecorator.php with same $conditions.
protected function dbStringSelect(array $conditions, array $options = []) { $query = $this->stringStorage->dbStringSelect($conditions, $options); // The 'translated' meta-condition bypasses fallbacks, since it is used for // querying specifically for a given language. if (!isset($conditions['translated'])) {
in this moment the condition on $conditions['translated'] will avoid building a query using JOIN to build translation js files..
My only way to get it working was to modify the condition as you can see it in this patch.
Am i missing something ?
Thanks Julien
Fixed
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Automatically closed - issue fixed for 2 weeks with no activity.