Ticket #19852 (closed task (blessed): fixed)

Opened 5 weeks ago

Last modified 2 weeks ago

Don't load admin strings on the frontend

Reported by: nacin Owned by:
Priority: normal Milestone: 3.4
Component: I18N Version:
Severity: normal Keywords:
Cc: scribu, ocean90, pavelevap@…, frederic.demarle@…

Description

We should take the same approach as we did for multisite strings, and only load admin strings in the admin.

This should be handled in load_default_textdomain(). Additionally, includes/admin.php should load the admin mo file if it is not already loaded, in the case of the frontend calling on the admin bootstrap (which we, for example, do in admin-ajax).

This came out of #19832.

Attachments

19852-makepot.diff Download (3.6 KB) - added by ryan 5 weeks ago.
19852-makepot.2.diff Download (3.6 KB) - added by ryan 5 weeks ago.
Untested makepot.php patch
19852-makepot.3.diff Download (3.6 KB) - added by ryan 5 weeks ago.
Now with testing, but not much.
19852-makepot.4.diff Download (4.4 KB) - added by ryan 5 weeks ago.
With some fixes
19852-makepot.5.diff Download (4.8 KB) - added by ryan 5 weeks ago.
User and site admin in same pot. Dupe removal for net admin pot.
19852.diff Download (1.4 KB) - added by ryan 5 weeks ago.
First pass at loading the new mo files
19852.2.diff Download (1.4 KB) - added by ryan 4 weeks ago.
ms- back compat. Load admin-network- instead of network-admin-
19852.3.diff Download (1.5 KB) - added by ryan 4 weeks ago.
Now with less bugs

Change History

comment:1   ryan5 weeks ago

Here's a link to makepot.php for those not familiar with it:

 http://i18n.trac.wordpress.org/browser/tools/trunk/makepot.php

  • Cc scribu added
  • Cc ocean90 added

ryan5 weeks ago

ryan5 weeks ago

Untested makepot.php patch

comment:4   ryan5 weeks ago

Patch (totally untested) creates frontend, site admin, network admin, and user admin pots. The ms pot is dropped since it accounts for so few strings. The continents-cities pot is preserved.

comment:5   ryan5 weeks ago

Here are the new pots and their corresponding number of lines. The user admin pot has only two translatable strings.

  • wordpress-network-admin.pot: 1122
  • wordpress-site-admin.pot: 10634
  • wordpress-user-admin.pot: 20
  • wordpress.pot: 6701
  • Cc pavelevap@… added

comment:7   ryan5 weeks ago

> grep msgid wordpress-site-admin.pot | wc -l
2460

A fair number of strings. 1552 for wordpress.pot and 259 for wordpress-network-admin.pot.

comment:8 follow-up: ↓ 11   pavelevap5 weeks ago

I think that there will be special textdomain needed, which have to be manually added to particular strings?

Example:

wp-includes/general-template.php:

1) function register_admin_color_schemes() - contains strings for administration.

2) function get_search_form() - contains strings for frontend.

And other problem: Some general strings are same for frontend and backend, for example "Comments", etc. So, there will be need for adding them to both textdomain files.

ryan5 weeks ago

Now with testing, but not much.

comment:9   ryan5 weeks ago

The pots will be merged where necessary. Network admin, for example, will load and merge wordpress-network-admin.pot, wordpress-site-admin.pot, and wordpress.pot.

Last edited 5 weeks ago by ryan (previous) (diff)

Let's reduce it by one and end up with wordpress.pot, wordpress-admin.pot, and wordpress-admin-network.pot?

comment:11 in reply to: ↑ 8   nacin5 weeks ago

Replying to pavelevap:

1) function register_admin_color_schemes() - contains strings for administration.

All strings in wp-includes will be included in the main wordpress.pot, regardless of intended use. It won't add up to much.

And other problem: Some general strings are same for frontend and backend, for example "Comments", etc. So, there will be need for adding them to both textdomain files.

As there will be a hierarchy of includes (wordpress.pot is always included, wordpress-admin.pot is always included in the site/network/user admins, etc.) we can keep the string in only one pot, whichever is the superset.

But then there will be also many strings from admin loaded on frontend. Main purpose of this ticket was to minimize strings loaded on frontend. And now there will be also mess for translators - some admin strings together with all frontend strings. There was another ticket related to multisite strings: http://core.trac.wordpress.org/ticket/19831

There is only one good way - marking all frontend strings manually with special textdomain, I guess.

Last edited 5 weeks ago by pavelevap (previous) (diff)

The current makepot patch removes thousands of strings from the frontend pot. register_admin_color_schemes() and the handful of others that introduce backend only strings into the frontend are not worth worrying about.

ryan5 weeks ago

With some fixes

ryan5 weeks ago

User and site admin in same pot. Dupe removal for net admin pot.

ryan5 weeks ago

First pass at loading the new mo files

The patch looks good to me, except the call to non-existant $this->wp_user_admin($dir, null); in wp_core().

Next up is updating all of the potbot related scripts, creating new GlotPress projects for the new pots, and moving strings to the right projects.

ryan4 weeks ago

ms- back compat. Load admin-network- instead of network-admin-

ryan4 weeks ago

Now with less bugs

In [19772]:

Load the new admin and network admin mo files, if present. see #19852

  • Cc frederic.demarle@… added

In [19787]:

Load admin-$locale.mo in setup-config.php. see #19852, see #18180.

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

Next up is updating all of the potbot related scripts, creating new GlotPress projects for the new pots, and moving strings to the right projects.

We're all done here.

Note: See TracTickets for help on using tickets.