Trouble loading translations in Sage 8

Sooo, I’m working on a sage 8.5.4 project, and I can’t for the life of me locate any documentation about how to properly configure localization/translations in that version of sage, even after checking out the links provided in this thread.

Any help here would be hugely appreciated… it’s pretty challenging that an archival documentation for prior versions of the software simply aren’t available — makes supporting/extending legacy projects pretty challenging when they need a bit of extension/enhancement, but don’t have the budget to tackle a full-on migration to the newest version.

Is there a specific issue you’re running into re: localization/translation?

Since Sage 8 uses more-or-less standard WordPress templating, just with heavy use of includes, I think WordPress’s localization tools should work with it: https://developer.wordpress.org/themes/functionality/localization/ There are also a number of community-contributed translations for Sage 8: https://github.com/roots/sage-translations

Thanks for your response, @alwaysblank !!!

Well — it’s the first time I’m attempting to implement a language localization in WP (I had the good fortune of spending years working in tandem with another dev who was bilingual, and who handled localization setup on the sites we built which needed it, so never had to tackle it myself… until now).

Background:

  • Wordpress Multisite.
  • English lang site is default, and has been live for a couple of years
  • French lang site is on subdomain (fr.domain.com), and is set to french language (wplang = fr_FR)
  • French lang site has been essentially parked, awaiting development and content resources for the past couple of years, but now needs to go live, leveraging the same theme as the EN/primary site on the network (but with different site content — my issue pertains only to theme/interface translation, NOT multilingual published content, as the content itself will be unique.

Issue #1:
Thus far, I’ve imported the sage.pot file that comes with 8.5.4 in the /lang folder into PoEdit, and implemented translations for all of the default strings — and subsequently saved out .po & .mo files from PoEdit, into the /lang folder alongside the .pot file. Initial testing is showing that the translations aren’t being used when the page is viewed. My simple test case is the 404 template, which is showing the default/EN text, rather than the translated string from the files PoEdit generated.

Having perused the Sage 9 docs, and seeing that it’s necessary to create a Yarn task to render the lang files in that version, I’m assuming that there’s an equivalent/necessary configuration for Sage 8.5.4/Gulp? But I cant find any documentation on what’s required, if that’s the case — or what the solution is if that’s not it…?

Issue #2:
Am I correct in assuming that once I do manage to get the above working properly, translating any custom strings that I’ve added to the theme is simply a matter of expanding the default sage translations (sage.po) to incorporate those new strings per my theme’s requirements?

Thanks again — this has been driving me a bit nuts.

I’m afraid I can’t be much more help since I’m not very familiar w/ localization, but I’ve split your question off into its own topic, which should help get more eyes on it.

Thanks, @alwaysblank — much appreciated. I’ll edit the original post to make it make more sense as a standalone inquiry.

Have a great weekend,
T

What version of WordPress are you using? WPLANG is for v3.9.2 and below. Since v3.9.3 you should change the default site language in Settings > General > Site Language.

You can use sage translation files from roots/sage-translations as pointed out by @alwaysblank and put them in the /lang folder alongside the .pot file. Then check if you are loading the theme textdomain in lib/setup.php load_theme_textdomain('sage', get_template_directory() . '/lang');

If you want to use your own theme textdomain you can put all the sage translation files in their own directory /lang/sage and your own .mo .po files in /lang/yourtextdomain folder, keeping both sage.pot and yourtextdomain.pot y the /lang folder. Then in lib/setup.php load textdomains as follow:

load_theme_textdomain('sage', get_template_directory() . '/lang/sage');
load_theme_textdomain('yourtextdomain', get_template_directory() . '/lang/yourtextdomain');

The rest of the work is done from PoEdit. I haven’t done this in a while since I prefer to use WPML, but sure did back in 2013 :slight_smile: and remember to be like setting up Properties y the Catalogue menu and then “Update from sources”.

1 Like