Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi!

I have a session variable for the currently used language. I want it to influence
this string in couch settings file.
Code: Select all
define( 'K_ADMIN_LANG', 'EN' );

I think, Couch doesn't read this definition in the run-time. It reads it only when login to admin panel is accessed. So, is there a way to inject a variable there? Something like
Code: Select all
<?php
a. get & read my 'lang' session
b. if this lang is available in couch/lang: create a variable to store value, if not - create variable and store default 'EN'
c. ???
d. PROFIT

Please, help. Answer will be a great candidate to Tips&Tricks :)
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
This thread has some info viewtopic.php?f=2&t=8280

Code: Select all
<?php
  session_start();
  if (isset($_GET["lang"])) {
           $language = $_GET["lang"];
           }
      else if (isset($_SESSION["lang"])) {
                 $language = $_SESSION["lang"];
                 }
      else {
            $language = "EN";
             }
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
@trendoman, Couch not being a multi-user CMS, the admin-panel is usually accessed by only a single admin at any given time.

I wonder, this being the case, why would you want to use session to change the language used on the fly? Could you please tell us more about it?

Thanks.
It will be ultimately changed according to the website's language preference. It is weird to see website in french and then access admin in english, only because super-admin doesn't speak french.

It is easy. I tend to write in English and I like interface in it too. However, site owner expects it to be in her language. So, basically, I can set default language as owner's language. As for me - I will come to website first, it will detect my language automatically as english, set a session, then I will visit admin panel login and it will show me english, according to the 'changed on-the-fly' language setting.

Instead of session it can be a cookie.

KK wrote: accessed by only a single admin at any given time.
I wonder, this being the case, why would you want to use session to change the language used on the fly? Could you please tell us more about it?
Thanks.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
4 posts Page 1 of 1