Skip to content

Instantly share code, notes, and snippets.

@Zodiac1978
Created August 25, 2023 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zodiac1978/41799f925688764b6dba0ad27eec2b08 to your computer and use it in GitHub Desktop.
Save Zodiac1978/41799f925688764b6dba0ad27eec2b08 to your computer and use it in GitHub Desktop.
Double every translation string for a given text domain for testing purpose.
<?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