WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#6951 closed enhancement (fixed)

load_theme_textdomain should allow one to specify directory

Reported by: filosofo Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: I18N Keywords: load_theme_textdomain l10n i18n has-patch needs-testing
Focuses: Cc:

Description

Currently, you have to put .mo files in the top-most part of the theme directory, which can make things kind of crowded. It would be good to be able to specify another directory, so one could organize them in a sub-directory.

My patch preserves existing behavior by default, but adds an extra argument for load_theme_textdomain for the directory path.

Attachments (1)

theme_l10n_directory.diff (610 bytes) - added by filosofo 6 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Viper007Bond6 years ago

I think it might be worthwhile to force the translation file to be somewhere inside the theme's folder. That way theme developers with bad habits and practices can't have it be located elsewhere.

I propose $path should be a relative to the current theme's directory.

comment:2 filosofo6 years ago

Viper007Bond, what sort of bad habits and practices do you have in mind? I'm not disagreeing, just unaware. Most of the time it seems like people with bad practices won't use l10n at all.

I also thought it might occasionally be handy to keep l10n files outside the theme directory. Say, for example, that you've standardized the text of all your themes, and you allow users to switch themes.

comment:3 Viper007Bond6 years ago

That's a good point (a global file).

I was trying to avoid theme authors setting the localization directory to like /wp-includes/languages/ or something.

comment:4 strider726 years ago

It should certainly _default_ to being relative to the theme directory.

+1 on this.

comment:5 jacobsantos6 years ago

  • Component changed from General to i18n
  • Keywords needs testing added
  • Milestone changed from 2.9 to 2.7
  • Type changed from defect to enhancement

The patch should still commit, sending to 2.7 since it would be nice and it has a patch.

comment:6 jacobsantos6 years ago

  • Keywords needs-testing added; needs testing removed

comment:7 ryan6 years ago

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

(In [9212]) Add optional path arg to load_theme_textdomain(). Props filosofo. fixes #6951

Note: See TracTickets for help on using tickets.