Best location for theme translation files

The question:

I usually store language files in /languages folder that is located in theme folder and it’s also recommended location by WordPress as well. However, it still doesn’t look like the best solution because files will be overwritten after theme updates.

load_theme_textdomain function allows to specify a different location and I’ve been thinking to put languages folder inside of /uploads folder in order to prevent overwriting after theme updates. That folder will be created right after theme activation and language files will be copied there.

My question is, do you think this is a good solution or there is a better way that I’m missing?

I appreciate your insight about this matter.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Own theme

If you are using your own theme, no need to worry about, because /languages folder is in your control that way. 🙂

Other’s theme

But your concern is about other’s theme and you want to apply your translations into that theme, then the best way is to make a Child Theme. Because you are actually modifying that theme. Make your languages files and put them into your child theme’s /languages/ folder, and that’s all.

If the parent theme is already translation-ready, it’ll catch everything. But if it’s not, then make a functions.php and show the translation-files’ path:

load_theme_textdomain( 'theme-textdomain', get_stylesheet_directory() . '/languages' );

Note the get_stylesheet_directory() here, it’s because we are showing the active theme’s path. 🙂


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment