0

I have code and want to change language on click, there is code:

// define('APP_LANG', 'en');
// setlocale(LC_ALL, 'en_EN');

 define('APP_LANG', 'ka');
 setlocale(LC_ALL, 'en_EN');

// define('APP_LANG', 'fr');
// setlocale(LC_ALL, 'fr_FR');

I want to change app_lang and setLocale on click.

How can I do that with also html toggle button?

1 Answer 1

2

You can't change const variables dynamically, read this

So, you can store your language setting in $_SESSION and change that with ajax. Every time user makes the request, you should check this setting and select the translation according to this.

Sign up to request clarification or add additional context in comments.

1 Comment

So i can't change language by dropdown like menu bar?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.