Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

Qtranslate-x plugin integration

Open albertso opened this issue 11 years ago • 2 comments

The Translation Extension is an admirable implementation of multilanguage support, which is a lot to say being it just one of the many amazing features this framework has to offer.

As far as I've seen, it works very similar to other plugins like WPML, which stores different languages as separate entries, with a field to indicate language, and a field with a common id that relates them all. This approach is ok, it's very versatile, and best of all, it works. But, versatility comes at a cost.

You may argue that a page can vary the layout on different languages, or you may want a different menu tree for each language, or different widget arrangements, but usually, it's more practical to keep design consistent across all languages, and it's easier to mantain.

The "problem" with WPML approach, is database bloating with repeated meta. This data has to be manually kept consistent when making changes, multiplying the cost of site manteinance. There are many fields that usually don't need language specific treatment. For example _wp_page_template, or other custom meta, and there are cases where it's unclear, like featured_image

I prefer the qtranslate approach, keeping a single entry per item, storing all languages on the same field using shortcodes "[:en]english[:es]spanish", and let the plugin handle dynamic language switching, filtering, etc.

This apporach allows us to store design as part of the content on a single page, keeping rows, columns and layout consistent across languages, keeping one single set of metadata, using shortcodes to translate only the parts that require it.

The good thing is, this almost works out of the box. The latest version of qtranslate-x has a neat feature, where you can write a comma separated list of of fields that should have translation enabled in the backend. This way any custom field can be specified as translatable, tailored to the client, and the plugin handles language switching dynamically. I managed to enable translation for fields created with Unyson, it works exactly as it should, and it's customizable. If it only were for one problem.

It doesn't work for fields loaded with ajax, like the fields in the popups displayed by the Page Builder shortcodes. It would be nice to be able to translate accordions, sliders, etc. I've tried to enable translation for the text field in the Text Box shortcode, by adding fw-option-type-text as translatable field, but haven't succeeded.

It seems qtranslate has js that checks after page load and hooks all the translatable fields it found.

I have to find the way to make this occur in the event of a Unyson popup appearing. I think this event generates here, but I'm not sure. Also, I just noted that the latest version of qtranslate-x has an "integration framework" for plugins to declare what fields should be translatable. I should check if that works for ajax fields too.

If anyobody else is interested in this: https://qtranslatexteam.wordpress.com/integration/

And here is an example of a plugin that integrates qtranslate with ACF, which does exactly this, for ACF ajax loaded fields, and another example integrating it to Visual Composer, if that helps.

I thought about posting this on the qtranslate-x forum, but they'll probably need to know how is the popup being created, which is probably best to be asked here.

I'm just laying out some ideas. Can somebody help? I would love to see these two plugins work together nicely!

albertso avatar Jul 09 '15 05:07 albertso

I've read about a half of your post here. I think if the site is more complex, wpml or any other similar extension is the very bloat you speak of, in most cases of complex websites, multiple WP installations should handle multiple languages. WPML and such are great for a simple, corporate/portfolio site to have in 2-3 languages, or else, see amazon.de amazon.com amazon.it => complete different sites for complete different languages.

You can make the code "sing your favorite song" but will never be a perfect solution in 100% of the cases.

thednp avatar Aug 26 '15 01:08 thednp

https://github.com/ThemeFuse/Unyson/issues/1603

ghost avatar Aug 19 '16 11:08 ghost