Perhaps it's just me but I'm having difficulties in getting plurals working in D7 using the 7.x-2.0 version of the module.

To be more specific I see that plurals are no longer stored as separate entries within the database and instead are concatenated using the L10N_UPDATE_PLURAL_DELIMITER ('\03') character and stored within a single row. The result of which is not only missed translations for plural strings but also their respective singular counterparts.

In addition, manual editing of plural translations using the translation interface UI is problematic with respect to the aforementioned L10N_UPDATE_PLURAL_DELIMITER character.

Any suggestions would be greatly appreciated.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dan Kennard’s picture

Title: Issues with plurals » Broken plural handling
Dan Kennard’s picture

Issue summary: View changes
Sutharsan’s picture

Assigned: Unassigned » Sutharsan

You are the first reporting this, but you may be very right. I think this is an omission and due to the use of Drupal 8 code in this version. I need to look into this.

Jim Kirkpatrick’s picture

This affects us too...

Seems we have a choice:

  1. Fix this module: which might involve not using the delimited storage of plurals - probably a reasonable change
  2. Patch core to be more D8-like: which is slightly smelly but possibly a good solution.

@Sutharsan which way do you lean, any thoughts on the best approach? We can spend dev time on a patch for this, but would like a steer from you as to the best direction. Thanks.

Gábor Hojtsy’s picture

@Jim: Drupal 7 is frozen in terms of its API so the module should be fixed to store plurals as core expects.

Dan Kennard’s picture

Edit - Made some progress on this one. Patch forthcoming over the next day or so

Dan Kennard’s picture

Hopefully this will do the job in that plural strings are now stored separately. I've added a drush command which will attempt to fix previously imported D8 style plurals but perhaps it would be better to place the logic within an update hook?

Dan Kennard’s picture

Version: 7.x-2.0 » 7.x-2.x-dev
Status: Active » Needs review
Jim Kirkpatrick’s picture

Status: Needs review » Reviewed & tested by the community

Patch at #7 works for us, thanks Dan!

FreekVR’s picture

Thanks, the patch in #7 is working for us as well :)

Sutharsan’s picture

The update function should also be available for non-drush users, as it fixes plural strings for all.

I will fix code style and some minor stuff in a separate patch.

Sutharsan’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
13.37 KB
10.32 KB

Fixed some code style, naming, interface strings, white space and other minor stuf.

Remaining todo's

  • Only warn / skip if the translation is customized.
  • Add actual context support.
  • Is it possible to fix these string via the translation interface?
Sutharsan’s picture

Assigned: Sutharsan » Unassigned
idebr’s picture

+++ b/l10n_update.install
@@ -367,3 +524,24 @@ function l10n_update_update_7203() {
+  if (l10n_update_get_d8_plural_strings() !== FALSE) {
...
+    }
+  }
+  else {

The if is closed prematurely on line 542. This results in a parse error in the install file:

Parse error: syntax error, unexpected 'else' (T_ELSE) in [...]/l10n_update.install on line 538

Sutharsan’s picture

I want to release a 7.x-2.1 shortly and like to include this fix. Is there anyone here who want to finish this patch?

Sutharsan’s picture

Assigned: Unassigned » Sutharsan
FileSize
13.34 KB

Rerolled

Sutharsan’s picture

Assigned: Sutharsan » Unassigned
Status: Needs work » Needs review
FileSize
19.84 KB
24.83 KB

I discovered that the writer classes were not capable of handling D7 style plurals yet. The changes in the above patches only handled the the plural delimiter, but not the difference in database table fields and not the additional database records for plurals for languages with > 1 plural form.

Further I decided to drop the drush support of D8 to D7 string conversion in favor of hook_update_N. Once the update script is executed, I see no more need for running the conversion again via drush.

All togehter it turned out to be a total rewrite of the patch.

  • Sutharsan committed 1c73e9b on 7.x-2.x
    Issue #2501315 by Sutharsan, Dan Kennard: Broken plural handling
    
Sutharsan’s picture

Status: Needs review » Reviewed & tested by the community

I've tested the patch with two languages. One with multiple plurals (Arabic) and one with 2 plurals (Hungarian).

  • Added the languages with latest 7.x-1.x module
  • Added the languages with latest 7.x-2.x module. Applied the patch and performed update.
  • Added the languages with latest 7.x-2.x module after applying the patch

All cases resulted in the same records in the locales_source and locales_target tables.

Sutharsan’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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