EvanAgee / vuejs-wordpress-theme-starter

A WordPress theme with the guts ripped out and replaced with Vue.
https://vuewp.com/
1.6k stars 282 forks source link

Compatible with WPML? #61

Open megansimpson opened 5 years ago

megansimpson commented 5 years ago

Hi Evan,

I'm excited to start working with this starter. Just getting into Vue.js too, so please bare with me. I've got a client whose site needs to have English and French, and we normally use WPML for that. How would this typically work with this Vue/WP setup? Or would it at all?

Thanks, and let me know if you need more info. Cheers

murray-bcoden commented 5 years ago

Hey Evan,

So there are a few approaches you can take with this one. Since you are using WPML I am guessing that in order for you to take advantage of the translations you will be required to add a custom hook that intercepts the API request before it is sent to the front end and translates it there.

Here is a reference to the available hooks in WPML. https://wpml.org/documentation/support/

Another option although is to do the translations in Vue. I found a great article on how to do this:

https://medium.com/hypefactors/add-i18n-and-manage-translations-of-a-vue-js-powered-website-73b4511ca69c

In this case, you would generate the translation file from the content stored in the WPML plugin. The benefit here would be that you would only have to generate that file when translations are added or changed. This provides ample opportunity to cache the translation file on the server or even locally.

In either case there some customization to the template and to WordPress will be required.

Hope that helps.