WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#8128 closed defect (bug) (fixed)

Some plural strings need contextual disambiguation for translation purposes

Reported by: hervada Owned by: nbachiyski
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.7
Component: I18N Keywords: i18n needs-patch
Focuses: Cc:

Description

As Xavier Borderie pointed out at wp-polyglots [1] there are some strings that cannot be correctly localised because their are used in different contexts (See Xavier's posting for examples.)

[1] http://comox.textdrive.com/pipermail/wp-polyglots/2008-November/002890.html

These are all the conflicting strings:

#: wp-admin/edit-pages.php:76 wp-admin/includes/post.php:730
#, php-format
msgid "Published <span class=\"count\">(%s)</span>"
msgid_plural "Published <span class=\"count\">(%s)</span>"

#: wp-admin/edit-pages.php:77
msgid "Scheduled pages"

#: wp-admin/edit-pages.php:77 wp-admin/includes/post.php:731
#, php-format
msgid "Scheduled <span class=\"count\">(%s)</span>"
msgid_plural "Scheduled <span class=\"count\">(%s)</span>"

#: wp-admin/edit-pages.php:78
msgid "Pending pages"
msgstr "Pàgines pendents"

#: wp-admin/edit-pages.php:78 wp-admin/includes/post.php:732
#, php-format
msgid "Pending Review <span class=\"count\">(%s)</span>"
msgid_plural "Pending Review <span class=\"count\">(%s)</span>"

#: wp-admin/edit-pages.php:79 wp-admin/includes/post.php:733
msgid "Drafts|manage posts header"

#: wp-admin/edit-pages.php:79 wp-admin/includes/post.php:733
#, php-format
msgid "Draft <span class=\"count\">(%s)</span>"
msgid_plural "Drafts</a> <span class=\"count\">(%s)</span>"

#: wp-admin/edit-pages.php:142 wp-admin/edit.php:129 wp-admin/upload.php:195
#: wp-admin/users.php:281
#, php-format
msgid "All <span class=\"count\">(%s)</span>"
msgid_plural "All <span class=\"count\">(%s)</span>"

#: wp-admin/includes/post.php:734
#, php-format
msgid "Private <span class=\"count\">(%s)</span>"
msgid_plural "Private <span class=\"count\">(%s)</span>"

Attachments (3)

contextual-ngettext.diff (1.9 KB) - added by nbachiyski 7 years ago.
Adds a ngettext variant, which supports contexts
plural-context-part-0.diff (2.7 KB) - added by nbachiyski 7 years ago.
Plural post/page differentiation for edit-pages.php
plural-context-part-1.diff (4.5 KB) - added by nbachiyski 6 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 follow-up: @hervada7 years ago

I have found 2 problems trying to solve this:

  1. The ngettext() function, which is used to give the singular/plural form for most of the above strings, does not know about context pipes. I think we must create a new function e.g. _nc() which does the combination of _c() and ngettext(), that is, it gives the singular/plural form according to amount and stripes out everything from the pipe | character.
  1. At edit-pages.php:76 there is no direct call to ngettext but an array such as:

array(('Published'), ('Published pages'), ngettext_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>'))

comment:2 @xibe7 years ago

  • Cc xibe added
  • Keywords i18n added

This was already mentionned by me here in March 2007, but I didn't push it then - only wishing for it to be included in the next major version.

The discussion about it on wp-polyglots received some good tractions from the Italian, Catalan, Arabic and Hebrew members. This would most probably be helpful to all Latin languages, at least.

While Francesc (hervada) seems to have hit a wall with the solution I thought of, could this still be achieved for 2.7?

comment:3 @westi7 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

I believe this is a dupe of #8154 which is getting a lot of work done on it.

Closing as such.

Please re-open if I an incorrect.

comment:4 follow-up: @hervada7 years ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

No, this is not a duplicate of #8154, the problem is similar but it referes to other places and the type of solution proposed there does not fit the problem at this ticket because of the 2 Problems I mentioned above. Thus I am reopening this ticket.

comment:5 in reply to: ↑ 4 @westi7 years ago

Replying to hervada:

No, this is not a duplicate of #8154, the problem is similar but it referes to other places and the type of solution proposed there does not fit the problem at this ticket because of the 2 Problems I mentioned above. Thus I am reopening this ticket.

Cool. No Problem.

@nbachiyski7 years ago

Adds a ngettext variant, which supports contexts

@nbachiyski7 years ago

Plural post/page differentiation for edit-pages.php

comment:6 in reply to: ↑ 1 @nbachiyski7 years ago

Replying to hervada:

I have found 2 problems trying to solve this:

  1. The __ngettext() function, which is used to give the singular/plural form for most of the above strings, does not know about context pipes. I think we must create a new function e.g. _nc() which does the combination of _c() and __ngettext(), that is, it gives the singular/plural form according to amount and stripes out everything from the pipe | character.

See contextual-ngettext.diff.

  1. At edit-pages.php:76 there is no direct call to __ngettext but an array such as:

array(__('Published'), __('Published pages'), __ngettext_noop('Published...

Later __ngettext() is called on the computed values, not the literal strings. See plural-context-part-0.diff

comment:7 @ryan7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [9887]) Contextual ngettext from nbachiyski. fixes #8128

comment:8 @nbachiyski7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Some more patches are needed, this was just proof of concept.

comment:9 @nbachiyski6 years ago

  • Milestone changed from 2.7 to 2.8

Changing so many strings after RC1 isn't a good idea. Leaving for 2.8.

comment:10 @Denis-de-Bernardy6 years ago

any traction?

comment:11 @nbachiyski6 years ago

  • Owner changed from anonymous to nbachiyski
  • Status changed from reopened to new

Somehow it wasn't assigned to me and I didn't fix the rest of it.

Most of the strings were fixed in the big new contexts move, but there are several left. Attaching a patch.

comment:12 @ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11137]) Plural contexts. Props nbachiyski. fixes #8128

Note: See TracTickets for help on using tickets.