Last active
August 29, 2015 14:01
-
-
Save pagelab/b5f197b7badbf40adb5a to your computer and use it in GitHub Desktop.
Using gettext/ngetext to replace array of words in wp admin
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 | |
| add_filter( 'gettext', 'wps_translate_words_array' ); | |
| add_filter( 'ngettext', 'wps_translate_words_array' ); | |
| function wps_translate_words_array( $translated ) { | |
| $words = array( | |
| // 'word to translate' = > 'translation' | |
| 'Posts' => 'Article', | |
| 'Post' => 'Articles', | |
| 'Pages' => 'Stuffing', | |
| 'Media' => 'Upload Images', | |
| 'Links' => 'Blog Roll', | |
| ); | |
| $translated = str_ireplace( array_keys($words), $words, $translated ); | |
| return $translated; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment