The easiest way of doing this is by using the free plugin called Loco Translate, which offers the ability to change text strings that are hardcoded in themes and plugins.
Te beauty of this plugin is that you can generate a WordPress language file that is physically stored and after you’re done with it, you can simply disable the plugin.
First install & activate Loco Translate.
Most “cart” text strings are located in “WooCommerce” plugin and “Rey Core”, so you will need to scan these 2 plugin and search them.
- First, scan in WooCommerce. Quick recording here https://d.pr/v/2qVP7W .
- Then, scan in Rey Core plugin . Quick recording here https://d.pr/v/pSVvHA .
Things to remember:
- Always make sure to select System as translation path, so that when plugins get updated, you won’t have your translation file overwritten.
- When scanning for text strings, some of them are option titles from admin. In general make sure to change a text when you see it in the frontend.
What other ways are there?
Another way is through some custom code, using WordPress’s built in `gettext
` filter, however it’s one of the most exhausting filters in WP which can affect performance. You can read more about it here Translating Rey theme and Core plugin .
In fact, at some point i started working on adding text input option fields in the theme options, with all these “cart” texts, however it meant using this filter i mentioned and because the compromise is too big, decided now to go this route.