Roots is an independent open source org, supported only by developers like you. We’ve been improving the WordPress developer experience since 2011, and your support keeps it independent.
Localizing the Sage WordPress Theme
Generating language files
Run yarn translate:pot from your theme directory to generate the language files. Then open the generated .pot file with Poedit, select "Create new translation", save .mo & .po files in the resources/lang folder with the correct name syntax (eg. fr_FR, en_US).
When adding/removing translations in templates, run yarn translate:update, then select "Catalog > Update from a POT file" in Poedit.
Loading language files
Add the following to app/setup.php:
add_action('after_setup_theme', function () {
load_textdomain( 'sage', get_template_directory() . '/resources/lang/' . determine_locale() . '.mo' );
});
Make sure language files exist in the resources/lang directory.
Polylang and Sage
- Install BenjaminMedia/wp-polylang-theme-strings
- Replace
__()withpll__()in your templates
Need to also translate strings from the app/ folder? See Sage_Polylang_Theme_Translation.
Last updated