Make WordPress Core

Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#42747 closed enhancement (wontfix)

i18n: Add specific text domain processing to `makepot` tools

Reported by: jpry's profile JPry Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch
Focuses: Cc:

Description

In the tools/i18n/ directory of the core repo is a great set of tools. As a plugin developer, two of the most useful tools are the makepot.php and add-textdomain.php files.

As an enhancement, it would be nice if the makepot.php file was able to operate on a specific text domain. This obviously wouldn't be necessary for Core, but for plugins and themes it could be quite useful. In particular, it would be great to have in the following cases:

  • When including default WordPress strings in conjunction with custom strings.
  • When including 3rd-party bundled libraries, such as CMB2.
  • When trying to put together a single translation file that spans multiple plugins and even a theme in a single site (this is certainly an edge case, but I have worked with clients who have this need)

I have a working patch that allows passing a textdomain and processing that domain only.

I opened this ticket as the result of a discussion in Slack.

Attachments (1)

42747.patch (3.0 KB) - added by JPry 7 years ago.

Download all attachments as: .zip

Change History (7)

@JPry
7 years ago

#1 @JPry
7 years ago

  • Keywords has-patch added

#2 @JPry
7 years ago

With the attached patch, here's an example of extracting strings for the example textdomain:

php makepot-textdomain.php example wp-plugin path/to/plugin/root/ path/to/plugin/root/languages/example.pot

Omitting the path to the .pot file will create the file in the current directory.

Note that this works nearly identically to the current makepot.php file, and that file should continue to function without any issues.

Last edited 7 years ago by JPry (previous) (diff)

#3 follow-up: @bobbingwide
7 years ago

I'd just like to point out that I raised #41551 to officially support use of null for text domain name parameter.

My solution for shared libraries currently relies on the fact that makepot doesn't actually care what text domain you specify in your source. Shared library files use a text domain of null. I've implemented Just Translate It to merge translations into the null domain.

I hope your patch allows me to continue to extract strings regardless of the text domain.

Last edited 5 years ago by SergeyBiryukov (previous) (diff)

#4 in reply to: ↑ 3 @JPry
7 years ago

Replying to bobbingwide:

I hope your patch allows me to continue to extract strings regardless of the text domain.

This shouldn't break any current functionality, but I'd be grateful if you'd be willing to test my patch with your current workflow to see if it causes an issue.

#5 @pento
6 years ago

  • Version trunk deleted

#6 @ocean90
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

The i18n tools have been removed in favour of the WP-CLI integration, see [45686].

Last edited 5 years ago by ocean90 (previous) (diff)
Note: See TracTickets for help on using tickets.