How to i18n slugs for templates?

Filter template_include:

add_filter( 'template_include', 'prefix_translate_template' );

function prefix_translate_template( $template )
{
    if ( 'category-' . __( 'news', 'your_textdomain' ) . '.php' === $template )
        return 'category-news.php';

    return $template;
}

But I think templates based on slugs are not a good idea in that case.

Leave a Comment