Im trying to implement localization to a site Im currently building. My goal is to use the i18n Extension for Twig since thats my template engine of choose.
However, when I'm adding the extension the site just crashes, screen gets white, and returning an 500 error code. Log says 408 timeout. In the same function where I'm adding the extension i also adding another extension wich works great. I have successfully installed the extensions via Composer. (https://twig-extensions.readthedocs.io/en/latest/i18n.html)
What am i doing wrong?
Here's my function.php
<?php
/**
* Timber starter-theme
* https://github.com/timber/starter-theme
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
Timber::$dirname = array( 'templates');
/** Start Timber! */
class StarterSite extends Timber\Site {
/** Add timber support. */
public function __construct() {
add_theme_support( 'post-formats' );
add_theme_support( 'post-thumbnails' );
add_filter( 'timber_context', array( $this, 'add_to_context' ) );
add_filter( 'get_twig', array( $this, 'add_to_twig' ) );
add_filter('show_admin_bar', '__return_false');
define( 'WP_DEBUG', true );
parent::__construct();
}
function add_to_context( $context ) {
$context['site'] = $this;
return $context;
}
public function add_to_twig( $twig ) {
$twig->addExtension( new Twig_Extension_StringLoader() );
$twig->addExtension( new Twig_Extensions_Extension_I18n() ); // This line breaks the site
return $twig;
}
}
new StarterSite();