Skip to content

Instantly share code, notes, and snippets.

@bordoni
Created December 8, 2019 04:05
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 bordoni/477cbb50a0151aa552a09ecc87ff20ac to your computer and use it in GitHub Desktop.
Save bordoni/477cbb50a0151aa552a09ecc87ff20ac to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Tribe Events Extension: Test Translations
* Version: 1.0.0
* Author: Modern Tribe, Inc.
* License: GPL version 3 or any later version
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*
* This plugin is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
function tribe_modify_translation( $translation, $domain ) {
$domains = [
'tribe-common',
'the-events-calendar',
'tribe-events-calendar-pro',
'tribe-events-filter-view',
];
if ( ! in_array( $domain, $domains ) ) {
return $translation;
}
return $domain;
}
add_filter( 'gettext', function( $translation, $text, $domain ) {
return tribe_modify_translation( $translation, $domain );
}, 100, 3 );
add_filter( 'gettext_with_context', function( $translation, $text, $context, $domain) {
return tribe_modify_translation( $translation, $domain );
}, 100, 4 );
add_filter( 'ngettext', function( $translation, $single, $plural, $number, $domain ) {
return tribe_modify_translation( $translation, $domain );
}, 100, 5 );
add_filter( 'ngettext_with_context', function( $translation, $single, $plural, $number, $context, $domain ) {
return tribe_modify_translation( $translation, $domain );
}, 100, 6 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment