Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard Exclude URLs from Translation #1412

Open
sonich2401 opened this issue Jul 24, 2024 · 1 comment
Open

Wildcard Exclude URLs from Translation #1412

sonich2401 opened this issue Jul 24, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@sonich2401
Copy link

Is your feature request related to a problem? Please describe.
I am redoing my website using the Bricks editor/theme. Whenever I am in the editor and I am finished with doing the translation manually using [:en]English Text[:ja]Japanese Text[:] and I save, it works. On the front end the translation works. However, when I want to make an edit, qTranslate-XT will translate the string in the editor. Instead of keeping the raw [:en]English Text[:ja]Japanese Text[:] it will replace it in the editor with "Japanese Text” because I have a Japanese computer. This essentially erases all of my translations whenever I want to make an edit.

Describe the solution you'd like
Have an option to exclude wildcard URLs from being translated. I would like to exclude URLs with ...

*bricks=run

… in the url from being translated.

Describe alternatives you've considered
I contacted Bricks support and they said that if qTranslate-XT could exclude bricks=run from the url it would fix the issue. Otherwise I could add it to their idea board. See support post here

Debug info [if applicable]

{
  "PHP_VERSION": "7.4.33",
  "WP_VERSION": "6.5.5",
  "QTX_VERSION": "3.15.2",
  "Plugins": [
    "Beaver Builder Plugin (Lite Version) 2.5.5.5",
    "Jetpack 11.4.1",
    "Plugin Detective - Troubleshooting 1.2.3",
    "qTranslate-XT 3.15.2",
    "The Events Calendar 6.0.1.1",
    "WP Multibyte Patch 2.9"
  ]
}

@sonich2401 sonich2401 added the enhancement New feature or request label Jul 24, 2024
@sonich2401
Copy link
Author

I was able to find a band-aid patch to make this work. However, I have never ever programmed in PHP so I am sure I made a mistake here and the obvious flaw is that it only works for my specific case but I am sure this is a good starting point for this so I thought I would share this with anyone who might need it.

I edited qtranxf_isMultilingual in src/language_blocks.php to the following...

function qtranxf_isMultilingual( ?string $str ): bool {
    if(isset($_SERVER['QUERY_STRING'])){
        if(! is_null($_SERVER['QUERY_STRING'])){
            if($_SERVER['QUERY_STRING'] !== ''){
	            if(preg_match( "/bricks=run/i",  $_SERVER['QUERY_STRING']) === 1){
		            return false;
                    }
	    }
        }
    }

    $lang_code = QTX_LANG_CODE_FORMAT;
    return ! is_null( $str ) && preg_match( "/<!--:$lang_code-->|\[:$lang_code]|{:$lang_code}/im", $str );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant