Modx multilingual is not working

I am trying to add a multilingual system to my site. but when I try to visit the “bn” URL it redirects to the home URL.
Site URL: http://modx.maisto-design.de/

this is my context settings

here is my .htaccess file

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(en|bn)/favicon.ico$ favicon.ico [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(en|bn)/assets(.*)$ assets$2 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(en|bn)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]

What extra (XRouting, LangRouter, etc.) do you use to switch the context?
Or do you use a custom plugin?

I have tried XRouting and custom plugins as well but none is working.
you can recommend one of them and write the .haccess file as needed.
Thanks in advance

Maybe try also adding the setting http_host to your context.


If you are using the extra XRouting or LangRouter then use the default RewriteRule in your .htaccess.

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

For LangRouter follow the instructions in the documentation.


For a custom plugin (and the current RewriteRule in .htaccess) maybe try the code from this page:

<?php 
if($modx->context->get('key') != "mgr"){
    /* grab the current langauge from the cultureKey request var */
    switch ($_REQUEST['cultureKey']) {
        case 'bn':
            /* switch the context */
            $modx->switchContext('bn');
            break;
        default:
            /* Set the default context here */
            $modx->switchContext('web');
            break;
    }
    /* unset GET var to avoid
     * appending cultureKey=xy to URLs by other components */
    unset($_GET['cultureKey']);
}

@halftrainedharry

  • How can I add/display a form with multiple languages?
    I kept the fields label and placeholder static.
    Should I make them dynamic to translate the text?

  • Besides, how can I validate each field with translated error text/message

  • how do validate email and phone fields with a pattern?

  • and how to require email or phone, both are not required but one is.

Thanks

Maybe use lexicon tags ( [[%...]] ) in your form, for the parts that are language-specific.

Take a look at the FormIt Validators documentation.
There exists for example a built-in validator “regexp”, or you could write a custom validator.

Write a custom validator for this
Take a look at this post: