Created
September 5, 2016 21:05
-
-
Save GaryJones/0dabf830e44099aa049747fa87c3374f to your computer and use it in GitHub Desktop.
Translate specific WP string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Untested, but should give you an idea. | |
| add_filter( 'gettext', 'claire_rename_color_to_colour' ); | |
| /** | |
| * Rename the exact WP string "Color" to "Colour". | |
| * | |
| * Doesn't affect non-exact strings. | |
| * | |
| * @link https://core.trac.wordpress.org/browser/tags/4.6/src/wp-includes/l10n.php#L105 | |
| * | |
| * @param string $translation Translated text. | |
| * @param string $orignal_text Text to translate. | |
| * @param string $domain Text domain. Unique identifier for retrieving translated strings. | |
| */ | |
| function claire_rename_color_to_colour( $translation, $original_text, $domain ) { | |
| // Target WP strings by excluding anything with a textdomain. | |
| if ( ! is_null( $domain ) ) { | |
| return; | |
| } | |
| if ( 'Color' === $original_text ) { | |
| $translation = 'Colour'; | |
| } | |
| return $translation; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment