WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#6742 closed enhancement (fixed)

Add hook for translating English

Reported by: Viper007Bond Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version: 2.5
Component: I18N Keywords: has-patch
Focuses: Cc:

Description

I want to be able to make __('foo') return bar, even if the blog is in English. If WordPress is in any other language besides English, I think you can just use the "gettext" filter to do this. However, my blog is in English, so you can't.

Attached patch adds a backwards compatible pre-translating hook for allowing plugins to switch phrases before they are translated.

It also passes the domain to "gettext" filter for the hell of it.

Attachments (1)

6742.patch (546 bytes) - added by Viper007Bond 6 years ago.

Download all attachments as: .zip

Change History (8)

Viper007Bond6 years ago

comment:1 westi6 years ago

Can you not create a translation file even for an English blog.

i.e set WP_LANG to en_Viper and have a en_Viper.mo file.

comment:2 pishmishy6 years ago

  • Milestone 2.6 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Agreeing with Westi here. Nothing forces you not to use English in translation files. Since there's no response I'll presume that you've tried this method and been successful. Please let us know if there's problems with this approach though.

comment:3 Viper007Bond6 years ago

  • Milestone set to 2.7
  • Resolution invalid deleted
  • Status changed from closed to reopened

Sorry, seemed to be missed westi's response.

I'm talking about a plugin here, not my own personal blog.

However, I honestly can't remember what I was trying to do at the time. I think I was trying to use the default widgets page for managing the dashboard and didn't want to use an output buffer.

So yeah, reopening for feedback, but not hard set on wanting it as I can just use an output buffer to modify strings. Still though, having a pre-filter much like you can do with get_option() would be handy and I don't see any harm except maybe extra CPU cycles.

comment:4 pishmishy6 years ago

I don't see the harm either, but not convinced I see the need =)

comment:5 caesarsgrunt6 years ago

  • Priority changed from lowest to normal
  • Severity changed from trivial to normal

I have wanted this on a few occasions too, so as to avoid output buffering to change strings without filters such as the comments page header.
PLEASE include this, I've been wanting it for ages! :)

comment:6 westi6 years ago

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

(In [9211]) Allow plugins to mangle translations of english strings as well as translated strings. Fixes #6742.

comment:7 westi6 years ago

Slightly different change there but that now passes all strings through the one filter so plugins can have there way translation or no translation.

Note: See TracTickets for help on using tickets.