backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 40 forks source link

Automatic translation downloading not available during installation #6717

Closed olafgrabienski closed 1 month ago

olafgrabienski commented 1 month ago

Description of the bug

When I try to install Backdrop in another language, I get a requirements problem: "The German translation is not available." The same happens with other languages (other than English).

Steps To Reproduce

Note: This seems to be an issue which happens only in certain hosting environments. See the "Additional information" section below.

To reproduce the behavior:

  1. Prepare a Backdrop 1.29.0 installation: database, code directory, etc.
  2. Go to the (sub)domain of your environment, and run the installer.
  3. Choose a language other than English, e.g. Spanish or German. The URL should contain a langcode, like in https://test.example.com/core/install.php?langcode=de
  4. Hit "Save and continue".

Actual behavior

You see a page with title "Requirements problem" and the following message:

Translation. The German translation is not available. The German translation file is not available at the translation server. Choose a different language or select English and translate your website later.

Screenshot:

Expected behavior

Backdrop is installed in the chosen language. (This is a new feature introduced with Backdrop 1.29.)

Additional information

(a) In a related Zulip thread we were discussing if this is a hosting environment issue. I was however able to reproduce the issue with two different shared hosting services.

(b) When I continue the installation in English, everything works as usual, and after the installation I'm able to download and install modules via the user interface.

Technical info:

indigoxela commented 1 month ago

Our current trouble is reliable reproduction.

On some environments this problem occurs, but not on others. Ideally we'd figure out the culprit on some hosting. Otherwise it's tricky to fix.

I'm one of those who can't reproduce it at all. Guessing... something goes wrong in install_check_localization_server() - unclear, what and why.

@olafgrabienski do you have a playground webspace with failure? One that really doesn't matter to you? Can you edit one core file to sneak in some debug() code?

olafgrabienski commented 1 month ago

Can you edit one core file to sneak in some debug() code?

Yes, I have a testing site. Which code?

indigoxela commented 1 month ago

Which code?

Oops, this is trickier, that I thought. At this early stage both, debug() and var_dump() output gets silently swallowed. :grimacing:

die() seems to work.

So, let's be rude:

In file core/includes/install.core.inc around line 1570:

  $response = backdrop_http_request($uri, $options);
  if ($response->code != 200) {
    die("This fails with $uri and response code is {$response->code}");
    $online = FALSE;
    return $online;
  }

Add the line with die() - that means, PHP will completely stop there and output just a single line...

This also means, the site won't install at all, but that shouldn't be a problem.

olafgrabienski commented 1 month ago

Thanks for the debug code. The result (this time I tried to install in Italian):

This fails with https://localize.backdropcms.org/files/l10n_packager/all/backdropcms/backdropcms-1.29.0.it.po and response code is 404

indigoxela commented 1 month ago

Ohhhh.... :bulb:

Now I get it. It's the version string, that makes this fail. Silly me, I tested with a dev (1.x) - unaware that dev works as opposed to regular stable installs. :grimacing:

indigoxela commented 1 month ago

Here's in incomplete PR for early testing: https://github.com/backdrop/backdrop/pull/4873

@olafgrabienski this should fix the problem with installing - as long as this particular translation file already exists (that's why this still needs work).

This also means: it's not at all related to hosting environments. It just worked for people testing with dev versions. This never worked for stable releases, because of the faulty (unstripped) version pattern.

indigoxela commented 1 month ago

Updated to a more complete approach: https://github.com/backdrop/backdrop/pull/4873

This now also works, if the translation file hasn't been generated, yet - be it because major.minor version's still dev (or preview release) or whatever. It falls back to the generic download, if that exists.

olafgrabienski commented 1 month ago

@indigoxela - I guess I have just tested the PR before you made the update. I was however able to install Backdrop in German. Does it make sense to test the updated PR, or not (may be not possible at the moment, as the translation files are available)?

indigoxela commented 1 month ago

I guess I have just tested the PR before you made the update.

Oops, can happen. :shrug: Many thanks for verifying, though. :wink:

Does it make sense to test the updated PR...

Absolutely. I had to switch the logic quite a bit, to better account for version specific translation files (existing or not existing yet, fallback...).

That the fallback works, can now be tested with a recent dev (it's now 1.30.x-dev and that should fall back to a translation file like backdropcms-1.x.de.po).

olafgrabienski commented 1 month ago

Okay, I'll test again later ... if nobody beats me to it.

argiepiano commented 1 month ago

Thanks, @indigoxela . I've tested locally and WFM:

  1. Downloaded the codebase for Backdrop 1.29.0
  2. Selected Español. As expected, I got the language unavailable error
  3. Patch Backdrop 1.29.0 with the patch provided here
  4. Attempted installing with Español. It worked 👍🏽
indigoxela commented 1 month ago

For testers - if you get the chance, you can also verify the file name of the downloaded file. It's in /files/translations.

Just to make sure, you got the right version/variant. :wink: It's not essential, just nice to know.

argiepiano commented 1 month ago

For testers - if you get the chance, you can also verify the file name of the downloaded file. It's in /files/translations.

Checked on the file name: backdropcms-1.29.es.po

Seems correct.

olafgrabienski commented 1 month ago

Tested the PR with 1.30.x-dev, works like a charm!

Name of the downloaded language file: backdropcms-1.x.de.po

quicksketch commented 1 month ago

This is utmost priority for us. Having a headline new feature not work is bad.

quicksketch commented 1 month ago

I found just one minor improvement that could be made in the PR: https://github.com/backdrop/backdrop/pull/4873#discussion_r1788878574 It should not affect the functionality but it would be great if @indigoxela could approve the change.

Tested this by checking out the branch, setting the version line in bootstrap.inc to the following (a version that clearly does not exist):

define('BACKDROP_VERSION', '1.31.0');

Then tested install.php on 1.x (which could not find the translation) and then on this branch, which found and used the 1.x translation. This all looks good to me!

indigoxela commented 1 month ago

I found just one minor improvement that could be made in the PR...

Great idea - I wasn't aware of that constant. Merged. :+1:

quicksketch commented 1 month ago

Merged https://github.com/backdrop/backdrop/pull/4873 into 1.x and 1.29.x. Thank you @indigoxela, @olafgrabienski, @argiepiano, and @hosef for fixing this issue!