2 localizations inside a WordPress theme

I’m building a theme which includes a separate “section” and I want to make both the theme and the separate section localizable. However, I don’t want to have them under the same textdomain.

Would someone advise against doing this? Could there be any issues?

Read More

I don’t want to have the separate section as a plugin.

This is what could appear inside e.g. functions.php:

__('String', 'themename');
__('Another string', 'somethingelse');

Related posts

Leave a Reply

1 comment

  1. Technically, this is possible. You can load as many language files as you want:

    load_theme_textdomain( 'text_domain_1', get_template_directory() . '/languages/td1' ) );
    load_theme_textdomain( 'text_domain_2', get_template_directory() . '/languages/td2' ) );
    

    In terms of performance it may be useful if want to separate front-end and back-end translations.

    But it is the wrong solution if do this to manage plugin code that you have moved into a theme. For example the notorious contact form, shortcodes or a dashboard widget – these parts should be handled by real plugins.

    TL;DR: It depends on the problem you want to solve.