qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
553 stars 104 forks source link

Code for using swirly brackets as global language tag. #282

Open herrvigg opened 6 years ago

herrvigg commented 6 years ago

Issue by raxdev Saturday Oct 10, 2015 at 00:12 GMT Originally opened as https://github.com/qTranslate-Team/qtranslate-x/pull/282


In response to support thread on Wordpress.org - https://wordpress.org/support/topic/is-it-possible-to-use-different-language-separator-than-and?replies=4

Below please find the code for substituting [ for { as language tags. As for the code structure, I went along the suggestions, also added simple UI for db conversion and a new advanced option to use alternative language tag {.


raxdev included the following code: https://github.com/qTranslate-Team/qtranslate-x/pull/282/commits

herrvigg commented 6 years ago

Comment by johnclause Sunday Oct 11, 2015 at 06:00 GMT


Thank you very much, we need to finish a couple of other things first. Did you test it? Does it indeed help? Please, try using the latest qtx from GitHub when testing. Is there a way for you to list the steps to reproduce an example of an actual problem you are solving with it?

herrvigg commented 6 years ago

Comment by raxdev Sunday Oct 11, 2015 at 10:57 GMT


I did test it and it does help a lot! I used latest trunk code from GitHub with my modifications and experienced no issues with qtx working in the swirly bracket mode. In general, the problem this patch solves is that it allows for qtx to be used alongside Visual Composer-type plugins that don't allow [ ] characters to be entered into text fields. This is fundamentally not qtx issue, as the problem is related to other plugin' code and lack of their support for "[" or "]" (or shortcodes in attributes), but letting QTranslate-X to use different language tag separator allows to bypass the problem (and probably expand potential QTX reach).

To see that Visual Composer breaks when you use such characters, you don't even need to install QTX - just a VC demo site will sufice. Repro steps:

  1. Create a demo site http://vcpreview.com/
  2. Edit Homepage with Visual Composer
  3. Edit first custom heading - set the text value to [:en]Visual Composer is #1 Most Popular[:]
  4. Edit second custom heading - set the text value to [ This is Great ]
  5. Update the page - see Text value being reset to empty string after the save for both edited entries.

On my test site I have following QTX integrations plugins active:

The main benefit for me to be able to use "Editor Raw Mode" and create one layout for a single page, with all text entries containing all language translations that I want.

Also - I did not test this - but the way I adjusted the code, the switch to "{" should be fully reversible, should someone wish to fall back to the default setting.