Created
August 25, 2023 20:43
-
-
Save Zodiac1978/41799f925688764b6dba0ad27eec2b08 to your computer and use it in GitHub Desktop.
Double every translation string for a given text domain for testing purpose.
This file contains 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 | |
/** | |
* Plugin Name: Double every translation | |
* Description: Double every translation string for testing purpose. | |
* Plugin URI: https://torstenlandsiedel.de | |
* Version: 1.0 | |
* Author: Torsten Landsiedel | |
* Author URI: https://torstenlandsiedel.de | |
* Licence: GPL 2 | |
* License URI: http://opensource.org/licenses/GPL-2.0 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
/** | |
* Double every translation for testing | |
* | |
* @param string $translated_text Output of the translation function. | |
* @param string $untranslated_text Original string in en_US. | |
* @param string $domain Textdomain. | |
* @return string Modified translation output (double string length). | |
*/ | |
function double_every_translation_length( $translated_text, $untranslated_text, $domain ) { | |
if ( 'antispam-bee' === $domain ) { | |
$translated_text = $translated_text . ' ' . $translated_text; | |
} | |
return $translated_text; | |
} | |
add_filter( 'gettext', 'double_every_translation_length', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment