Potx has added support for extracting translatables from Drupal 8 shipped config. But l10n_server needs to override some of its behaviour, before it can use it.
Specifically, when scanning a module, potx needs to find its dependencies (including core) in the local filesystem. L10n_server should try to use a database instead, so that there is no need to extract all its dependencies into the local filesystem.

There was an original implementation using database in potx, which is available at https://www.drupal.org/node/1933988#comment-10352733 . I'll try to make an initial patch here, based on that code, soon.

Comments

herom created an issue. See original summary.

gábor hojtsy’s picture

gábor hojtsy’s picture

gábor hojtsy’s picture

Status: Active » Needs review
StatusFileSize
new1.1 KB

So I rolled out potx updates to l.d.o due to other fixes and without this integration code, it fatals out and does not work at all. :/ I *think* we need this minimal code to make them work together for now.

  • Gábor Hojtsy committed d8b164d on 7.x-1.x
    Issue #2607956 by Gábor Hojtsy: Support for Drupal 8 shipped config (...
gábor hojtsy’s picture

Status: Needs review » Active

Rolled this out for now. That seems to work for now as a hotfix.

herom’s picture

Status: Active » Needs review
StatusFileSize
new8.76 KB

I've ported the code from https://www.drupal.org/node/1933988#comment-10352733 .
Unfortunately, I don't have a l10n_server installation to actually test this out (although I do expect it to work).

I don't know what the next step should be here. Maybe someone could try to test this out, until I get the chance to set up a l10n_server install.

gábor hojtsy’s picture

Title: Support for Drupal 8 shipped config » Server support for Drupal 8 shipped config across projects (contributed modules)
drumm’s picture

Status: Needs review » Needs work
StatusFileSize
new10.03 KB

I tested this by building out shipped-localize.dev.devdrupal.org, clicking 'Start over' for the latest release at https://shipped-localize.dev.devdrupal.org/admin/l10n_server/projects/re..., and running cron.

The attached patch changes:

  • Whitespace and trailing-comma-in-array cleanups.
  • Put a full copy of the schema in l10n_drupal_update_7100(). Update functions should have a snapshot of the schema at that point in time, and l10n_drupal_schema() will change in the future.
  • l10n_drupal_parsed_module_data's pid column wasn't actually used. I removed it and made the primary key module_name.
  • db_merge() needs values to be serialized before they go in.

To do:

  • I see l10n_drupal_parsed_module_data's module_version column exists, but is not used. If it should be used, I expect it will go in the table's primary key. Otherwise, remove it.
  • Could be an artifact of my testing, but I didn't see parsed_schema get populated at all.
  • I think _l10n_drupal_schema_load() should fall back to the potx default if it doesn't have the processed schema in the DB. We won't be parsing the D8 projects in any particular order, so there will be plenty of things parsed before their dependencies. This manifests as:
    array_merge(): Argument #2 is not an array potx.inc:2694
    array_merge(): Argument #2 is not an array potx.inc:2695
    array_merge(): Argument #2 is not an array potx.inc:2696
    array_merge(): Argument #2 is not an array potx.inc:2697
    array_merge(): Argument #1 is not an array potx.inc:2694
    array_merge(): Argument #1 is not an array potx.inc:2695
    array_merge(): Argument #1 is not an array potx.inc:2696
    array_merge(): Argument #1 is not an array potx.inc:2697
    in_array() expects parameter 2 to be array, null given potx.inc:2300
    in_array() expects parameter 2 to be array, null given potx.inc:2301
    in_array() expects parameter 2 to be array, null given potx.inc:2300
    in_array() expects parameter 2 to be array, null given potx.inc:2301
    in_array() expects parameter 2 to be array, null given potx.inc:2300
    in_array() expects parameter 2 to be array, null given potx.inc:2301
    in_array() expects parameter 2 to be array, null given potx.inc:2300
    in_array() expects parameter 2 to be array, null given potx.inc:2301
    in_array() expects parameter 2 to be array, null given potx.inc:2300
    in_array() expects parameter 2 to be array, null given potx.inc:2301
herom’s picture

Status: Needs work » Needs review
StatusFileSize
new1.85 KB
new9.75 KB

Thanks for the testing and fixes.

Some fixes were required in potx. You can follow them here: #2615930: Fix integration issues with l10n_server. They are already committed, so you can get the latest dev version, and try again.

  • module_version isn't used here, so I removed it. But it will be needed later in dependency resolution, so if a module's dependency is foobar (=8.x-1.2), we should load exactly that version's config schema. I can bring them back, if you want.
  • Re parsed_schema wasn't being populated, it's fixed in the potx issue above.
  • Re _l10n_drupal_schema_load() fall back, we need to differentiate between module not found in database, and module found but has no schema. NULL is used for the former, and the fallback array for the latter.

Also made 2 fixes in the patch here. Interdiff attached.

drumm’s picture

Looks good. I still don't have anything stored in parsed_schema, but maybe I haven't parsed an interesting module yet. I do see the fixes should improve it.

I recommend also removing l10n_drupal_schema_reverse_lookup's unused lid column. The primary key can be either array('schema_key') or array('schema_key', 'module_name'), depending on whether schema_key is unique or not. The module_name column should be shortened to 'length' => '255'. This will let the SELECT queries hit a key, and we won't have a potentially confusing ID that doesn't match up to anything else.

herom’s picture

Leaving a message here, since I couldn't reach anyone on IRC.

@drumm, can you double-check that the latest "dev" version of potx is installed on the test server? I'm afraid that it might not have been re-packaged between my fix commit, and your testing in #11.

I've been able to test the same db/queries code here locally with some tricks, and it's working fine (populating parsed_schema), so wanted to make sure.

gábor hojtsy’s picture

I wanted to help figure out the version number. The dev site does not have the original drupal.org passwords. I requested a new password (multiple times) but the email did not arrive. Finally I tried to ssh in as explained in https://www.drupal.org/node/1018084 but that is asking for a local password (which I don't believe I have, I use ssh keys to log in to d.o servers).

drumm’s picture

From IRC - I got Gábor's SSH access fixed and confirmed the dev site is on potx fd41357.

herom’s picture

StatusFileSize
new2.53 KB
new11.3 KB

Fixed some more errors reported by @drumm.
I got a local l10n_server running (finally!), and tested this with some D8 modules (e.g. migrate_plus), and shipped config was being extracted fine. Also fixed the l10n_drupal.files connector in the meantime, and made a small fix in potx (https://www.drupal.org/node/2615930#comment-10601826) which prevented extracting schema from modules that had no shipped config.

drumm’s picture

Have you had a chance to look through this from #11?

I recommend also removing l10n_drupal_schema_reverse_lookup's unused lid column. The primary key can be either array('schema_key') or array('schema_key', 'module_name'), depending on whether schema_key is unique or not. The module_name column should be shortened to 'length' => '255'. This will let the SELECT queries hit a key, and we won't have a potentially confusing ID that doesn't match up to anything else.

herom’s picture

StatusFileSize
new1.8 KB
new11.09 KB

sorry, totally missed that.
I don't think there is a guarantee that schema_key is unique, so made them both the primary key.

Status: Needs review » Needs work

The last submitted patch, 17: 2607956-17.patch, failed testing.

drumm’s picture

Status: Needs work » Needs review
StatusFileSize
new11.09 KB

The same patch, now with DrupalCI testing enabled for the project.

Status: Needs review » Needs work

The last submitted patch, 19: 2607956-17.patch, failed testing.

The last submitted patch, 19: 2607956-17.patch, failed testing.

drumm’s picture

DrupalCI's full console output includes:

Specified key was too long; max key length is 767 bytes

An index on each column, without a primary key, will be okay for this table.

drumm’s picture

Status: Needs work » Needs review
StatusFileSize
new5.78 KB

This patch replaces that primary key with the two indexes.

Status: Needs review » Needs work

The last submitted patch, 23: 2607956.patch, failed testing.

drumm’s picture

Status: Needs work » Needs review
StatusFileSize
new11.22 KB

That patch was incomplete, I missed the added file.

hestenet’s picture

A dev site with the latest dev version of potx and @Drumm's patch applied to l10n_server is available here: https://potx-localize-localize.dev.devdrupal.org/

gábor hojtsy’s picture

Status: Needs review » Needs work
+++ b/connectors/l10n_drupal/l10n_drupal.potx.inc
@@ -0,0 +1,174 @@
+ * Initialize potx to run locally, e.g. by drush.
+ *
+ * @param string $module_path
+ *   Path to the module that is being parsed by potx.
+ */
+function _l10n_drupal_potx_init() {

All these docs look incorrect based on the code.

gábor hojtsy’s picture

BTW otherwise the patch looks fine to me.

herom’s picture

Status: Needs work » Needs review
StatusFileSize
new1.14 KB
new11.03 KB

Fixed the docs.

  • Gábor Hojtsy committed bffa5b5 on 7.x-1.x
    Issue #2607956 by herom, drumm, Gábor Hojtsy: Server support for Drupal...
gábor hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Yay, thanks! Committed this one, looking into deploying it.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

The last submitted patch, 9: 2607956.diff, failed testing.

The last submitted patch, 25: 2607956.patch, failed testing.

Status: Fixed » Needs work

The last submitted patch, 29: 2607956-29.patch, failed testing.

herom’s picture

Status: Needs work » Fixed
gábor hojtsy’s picture

Issue tags: +needs drupal.org deployment

Add deployment tag. Will do this tomorrow.

drumm’s picture

Issue tags: -needs drupal.org deployment

I believe this was deployed to production.

gábor hojtsy’s picture

Yes it was, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.