Ryan Fung
Ryan Fung

Reputation: 2217

CodeIgniter - What is the proper way to reload my current webpage after getting a change language request

I am current using CodeIgniter 2.2.2

I have no problem loading different language in CodeIgniter. The only problem I have is how would I go and populate those new language file into client's webpage? What code should I use in the controller to reload client's current page?

What I have so far is a session variable storing where the user's "last page visited" and load that page everytime inside my switchLanguage controller. But this way, client's url will be switched to the name of the controller that I am using. I would like user to remain their current url.

Any idea guys?

Upvotes: 1

Views: 764

Answers (2)

Maxim Colesnic
Maxim Colesnic

Reputation: 465

href="?lang=en"

href="?lang=ru"

$lang = $this->input->get('lang');

Upvotes: 0

Andrew Surzhynskyi
Andrew Surzhynskyi

Reputation: 2776

The question is, why do you need to reload the page with php code? There is two ways how you can change language:

  1. AJAX call from JavaScript. If you do it that way and language was successfully changed than reload page with JavaScript code:

    location.reload();
    
  2. Link that leads to a url that routes us to the change language controller. You can change the language first of all, and after that load all the stuff: data, language, views, etc.

P.S. Please post your code when you are asking for help, otherwise people trying to answer your question can only guess.

Upvotes: 1

Related Questions