-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drush does not implement language negotiation #4610
Comments
I'm not sure Drush core needs to care about language negotiation. Perhaps @Sutharsan has input? |
Not sure. For me the issue is though the following:
Please notice that there's a mismatch between the resolved current language and the language in which the string is printed. This is taken care of in Drupal Core here: https://api.drupal.org/api/drupal/core%21modules%21language%21src%21EventSubscriber%21LanguageRequestSubscriber.php/function/LanguageRequestSubscriber%3A%3AsetLanguageOverrides/8.9.x |
I think this is opening a can of worms, let's not do it thoughtlessly. Language negotiation depends on context, your example code uses the user. But there are more scenarios one should consider. Two I can think of now: 1. As far as I can find out now, Drush uses the default language. Which I think is a good starting point (as it has proven to be). Core's language negotiation is specific for the web interface, and many options do not apply to CLI (URL, session, browser). I think there is room for a better control over the Drush language, but it should work with different 'contexts' than Drupal core. It should work with default language, interface language and, although of a lower priority, content language too. Whether or not this should be in Drush core, is not up to me. But I think a separate (new) project could do the same and has the freedom to investigate the various use cases and scenario's it should support. |
We are having an ugly bug here, that maybe is related: Wrong language field labes, (only) after drush cr [#3221375] | Drupal.org Unfortunately, @zaporylie's pre-command hook component linked above does not fix the issue, nor did some derivatives i made (that e.g. alway bootstrap full). |
Why was this closed? Is this something that won't be fixed or does this not happen? Cause we have an issue regarding webform data export through drush where this is the basis of the problem. |
I agree that this issue should be reopened and resolved in some way. I am using drush to export products from commerce site. I have multilanguage site where every language has own domain so I am using domain as negotiation for correct language. Also I am using currency exchange module to resolve correct currency and price based on language. The plugin mentioned in issue description worked fine for me. |
I have the case when a non-English website is developed by a big international team. Everything is translated from English, but the default language is not English. English is not even available for anonymous users. |
We have seen from experience that language differences acting weirdly where imports do not seem to be entirely completed. This results in language changes in CI which we cannot replicate locally. To address this we have tried the following: - Digging through issues queues. The following issues have not provided any answers yet: - https://www.drupal.org/project/drupal/issues/3103440 - https://www.drupal.org/project/drupal/issues/3221375 - drush-ops/drush#4610 - Trying out https://github.com/zaporylie/drush-current-language Running drush config-import twice seems make the problem go away but we do not want to go there yet. To address the situation we limit changes to the default language configuration. Checking the configuration here is at least better than what we have now.
Describe the bug
In the HTTP Request context, the translation_manager's default language is set via LanguageRequestSubscriber but in CLI context this doesn't seem to happen. I observed this when I've noticed that all emails sent with Drush don't follow the current (negotiated) language.
Not sure whether this should be a core or drush issue but imho should be fixed in one of those 2 places (probably here).
To Reproduce
drush ev "var_dump((string) t('Front page'))"
<- string should be translated but it is notExpected behavior
When casting TranslatableMarkup to string, the text should be in the current language, as resolved by language_negotiator.
Actual behavior
When casting TranslatableMarkup to string, the text is in the site's default language.
Workaround
Adding the following to DrupalBoot8 did the trick:
one can also install this drush plugin: https://github.com/zaporylie/drush-current-language
System Configuration
Additional information
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: