1

Let's say I have this in my bootstrap.php file in a cakePHP application:

Configure::write('Config.language', 'eng');

How can I dynamically change the value of that configuration variable based on user action in a controller of my application? I tried to do the same thing that I did above here in my controller, but that didn't work

Any help?

2
  • 1
    The code you posted is correct. Does Configure::read('Config.language'); not return what you expect? Define "didn't work". Commented Jun 7, 2012 at 18:17
  • Well that part's fine, he's trying to change it later on in the execution. Something from this question may help: stackoverflow.com/questions/10132465/… Commented Jun 7, 2012 at 18:19

1 Answer 1

0

Try Configure::write('Config.language', 'dut'); for e.g.

This answer from the question suggested by @Ryan Pendleton shows a somewhat correct way to use this directive. It should be used in the AppController because it gets loaded first - as the parent of all other controllers in the application itself. I used "somewhat correct" because it is best to validate the language codes ('eng', 'fre', 'dut') in the app/config/routes.php file - go here for more information.

Also do check out this: Internationalization-Localization explanation.

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

Comments

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.