Making WordPress.org

Opened 9 days ago

Closed 3 days ago

#8459 closed defect (bug) (fixed)

Plugin Directory: Register business model term names for contextual translations

Reported by: isaeedam Owned by: obenland
Priority: normal Milestone:
Component: Plugin Directory Keywords: i18n
Cc:

Description

The Community and Commercial navigation tabs on localized Plugin Directory pages remain untranslated.

Examples:

On both pages, the general directory navigation is translated, but the business model tabs remain as “Community” and “Commercial”.

In the current Plugin Directory code, plugin business model terms are translated in plugin-directory/class-i18n.php using:

translate_with_gettext_context(

html_entity_decode( $term->name ),
'Plugin Business Model',
'wporg-plugins'

);

However, the static_strings() method does not register the corresponding term names with this context. It currently registers the business model descriptions, but not the contextual term names themselves.

The Persian GlotPress project contains unrelated or differently-contextualized strings such as Community, Commercial, community, and commercial, but there is no source string registered with the exact context Plugin Business Model. Therefore, those existing translations cannot be relied upon for the taxonomy-term translation path used by the directory navigation.

Relevant current code:
​https://github.com/WordPress/wordpress.org/blob/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-i18n.php

The shared navigation code also replaces a navigation item's configured label with the taxonomy term name when a term is supplied:
​https://github.com/WordPress/wporg-mu-plugins/blob/trunk/mu-plugins/blocks/navigation/index.php

Proposed fix:

Add the following strings to I18n::static_strings() before the business model descriptions:

Business model terms.
_x( 'Community', 'Plugin Business Model', 'wporg-plugins' );
_x( 'Commercial', 'Plugin Business Model', 'wporg-plugins' );

This should expose the exact contextual strings to the translation extraction process without changing the navigation behavior.

Expected result:
Locale teams should be able to translate the Community and Commercial business model term names through GlotPress, and the translated labels should appear on localized Plugin Directory pages.

Change History (5)

#1 @dineshinau
5 days ago

PR: ​https://github.com/WordPress/wordpress.org/pull/1070

This adds the two missing strings to I18n::static_strings() in plugin-directory/class-i18n.php, as proposed in the description:

_x( 'Community', 'Plugin Business Model', 'wporg-plugins' );
_x( 'Commercial', 'Plugin Business Model', 'wporg-plugins' );

Tested locally with the Plugin Directory wp-env environment. Running wp i18n make-pot on the plugin with --domain=wporg-plugins now outputs both strings with the Plugin Business Model context. No change to navigation behavior.

Note: I wasn't able to verify the translated labels on a localized page locally, since the Plugin Directory's title translation depends on GlotPress tables that aren't available in the local environment. The strings will need to be picked up by GlotPress after merge/deploy before locale teams can translate them.

#2 @isaeedam
5 days ago

Thank you, @dineshinau, for looking into this!
I had already submitted a PR for this request. Sharing it here for reference:
​https://github.com/WordPress/wordpress.org/pull/1054

#3 follow-up: @dineshinau
5 days ago

Hi @isaeedam, sorry about that! I missed that you had already opened a PR and should have checked before picking this up. I've closed my duplicate PR (#1070), so ​https://github.com/WordPress/wordpress.org/pull/1054 is the one to follow.

#4 in reply to: ↑ 3 @isaeedam
5 days ago

Replying to dineshinau:

Hi @isaeedam, sorry about that! I missed that you had already opened a PR and should have checked before picking this up. I've closed my duplicate PR (#1070), so ​https://github.com/WordPress/wordpress.org/pull/1054 is the one to follow.

Thank you for your understanding!

#5 @obenland
3 days ago

  • Owner set to obenland
  • Resolution → fixed
  • Status new → closed

In 15366:

Plugin Directory: Register business model term names for i18n

Props isaeedam, williampatton, dineshinau.
Closes ​https://github.com/WordPress/wordpress.org/pull/1054.
Fixes #8459.

Note: See TracTickets for help on using tickets.