The main problem with this is that this means that when a test enables a language or module through the UI and locale.module is enabled, it tries to download translations. I think that might be slowing down a few tests right now (assumption, have not checked if that is actually true).
Fixing it is easy.
- Verify that this is actually the case (Run a test that tests the language UI locally, look at the debug output check if there is a translations downloaded message)
- Define a setting (config(), not variable_get()), default it to TRUE. No UI necessary at this point (can be discussed separately)
- Adjust testing profile .install to set it to FALSE.
- Verify that the translations are still downloaded by efault for you (a re-install might be necessary to update the config defaults)
- Re-run test and verify that there is no such message anymore. Write a simple test for this (add an assertNoText or similar)
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff-1887480-11-13.patch | 1.41 KB | webflo |
#13 | locale-disable-import-1887480-13.patch | 3.02 KB | webflo |
#11 | locale-disable-import-1887480-11.patch | 2.08 KB | Sutharsan |
#9 | locale-disable-import-1887480-9.patch | 2.54 KB | Sutharsan |
Comments
Comment #1
Sutharsan CreditAttribution: Sutharsan commentedSome time ago I heard an other use case for not automatically importing translation. When enabling a module using drush users may not want to download the translation immediately. With the current setup Drush has no way realize this situation. A state variable or the mentioned config() setting would be enough for Drush to do this (in the future).
Comment #2
YesCT CreditAttribution: YesCT commentedThe install has a message telling people to install english to avoid phoning home. I wonder if installed in English and then a language is added later, do people get a similar warning about automatic translation downloads? Could locale module expose such a config setting in the UI also to control that in general? (Maybe it does already? Need to check.)
This looks like a good issue for people to jump in to help with, challenging but not epic. :)
Comment #3
vijaycs85Look like @Berdir assumption is true. Here is the trace:
Comment #4
Gábor HojtsyWell, if your update checking is set to local files only, then it will not phone home or download .po files in any way when adding new languages. See
admin/config/regional/translate/settings
on your site. I think having a prompt as part of the language addition process is too excessive to ask for this. Notifying people that their site will automatically get translations might be interesting (as YesCT notes). But asking them whether they want it sounds out of place to me.Comment #5
BerdirI don't think we need a UI prompt either, that's not what this issue is about.
All I want is to prevent that automated tests are trying to download translations when languages are enabled in tests, except when explicitly testing for that. Can we use the existing setting for that? Should it maybe default to local and only be set to something else manually/in the installer/standard profile?
Comment #6
Gábor HojtsyI think we generally want real life use of locale to enable this by default, because people want their site be translated. The goal of this feature, is so they get the interface translated effortlessly. If we put in more barriers just to make the testing system simpler, that is not a good trade-off :) The enabling of the feature can be made conditional of it being in the test system or something along those lines.
Comment #7
BerdirThis is now causing weird test failures as you can see in #1905152-63: Integrate config schema with locale, so shipped configuration is translated.
Which makes this probably even major as it's not only a performance problem but can also cause unexpected site effects.
Discussed this in IRC, maybe we can just add an overridden locale.settings.yml to the testing profile or, if that doesn't work (it might not yet but probably should?), add a condition check to locale_install().
Comment #8
Gábor HojtsyThe reason it causes fails there is because we use a concrete real life langcode for the test, which most other tests don't do to avoid any other real-life logic to kick in. We are modifying our test there to use the xx langcode like almost all tests do. I still fully agree this should be fixed.
Comment #9
Sutharsan CreditAttribution: Sutharsan commentedThis patch introduces a setting (without an interface) that controls the translation import. Using this importing the translation upon module enable, theme enable, language add can be inhibited.
Comment #10
Sutharsan CreditAttribution: Sutharsan commentedNo test provided yet.
Comment #11
Sutharsan CreditAttribution: Sutharsan commentedRe-rolled the patch. We should disable the configuration with this variable too. But that needs input whether this has unwanted side effects.
Comment #13
webflo CreditAttribution: webflo commentedFixed syntax error and rerolled.
Comment #14
Gábor HojtsyLooks like the proposed change is fully implemented. Nice! Will be good for testing use.
Comment #15
alexpottCommitted dc6aeae and pushed to 8.x. Thanks!
Comment #16
alexpottCommitted dc6aeae and pushed to 8.x. Thanks!
Comment #17
BerdirWe need a follow-up to disable this check in the tests and only enable it when we actually want to test it. Because every test that adds languages through the UI currently triggers this process. Opened #2031175: Translation imports take a lot of time in tests even when not needed
Comment #19
Gábor HojtsyYay, this will be very useful.
Comment #20
Sutharsan CreditAttribution: Sutharsan commentedunassigning