Skip to content

Instantly share code, notes, and snippets.

@dancameron
Last active July 16, 2018 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dancameron/99c687cc4b812cb0b867 to your computer and use it in GitHub Desktop.
Save dancameron/99c687cc4b812cb0b867 to your computer and use it in GitHub Desktop.
Translating Strings in Sprout Invoices
<?php // don't add this line, since your functions.php file already starts with it.
/**
* Example filter will translate/change the string "Description".
* "Description" can be changed to whatever string you'd like to translate/change
* just make sure to change the function name so you don't have any conflicts.
*/
function si_change_strings( $translations, $text, $domain ) {
if ( 'sprout-invoices' === $domain ) {
// Change "Description"
if ( 'description' === strtolower( $text ) ) {
return 'Beschrijving';
}
// add more conditions, changing as many strings as you'd like
}
return $translations;
}
add_filter( 'gettext', 'si_change_strings', 10, 3 );
@dancameron
Copy link
Author

dancameron commented Jul 16, 2018

function si_change_strings( $translations, $text, $domain ) {
	if ( 'sprout-invoices' === $domain ) {
		// Change "Description"
		if ( 'print to pdf' === strtolower( $text ) ) {
			return 'Download Invoice';
		}
		// add more conditions, changing as many strings as you'd like
	}
	return $translations;
}
add_filter( 'gettext', 'si_change_strings', 10, 3 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment