CodeIgniter Forums
Check if my codeigniter 4 runs in multilingual mode. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Check if my codeigniter 4 runs in multilingual mode. (/showthread.php?tid=79177)



Check if my codeigniter 4 runs in multilingual mode. - sdiri - 05-05-2021

Hi, How do I know if CI4 is running in multilingual mode?
in other words how to know if segment 1 of url presents the key of the language not another variable?
because the methode 
PHP Code:
$this->request->getLocale() 
always returns the a value ...
if no language key founded it return the default value of:
PHP Code:
$defaultLocale 
In this casenothing guarantees me that the returned value corresponds to a key of a languagecontroller or if the site works in multilungue mode or not.
I think even if I use 
PHP Code:
$this->request->getLocale() in_array( this-> request-> config-> supportedLocales)... 
that does not give a guarantee!

Please How to be sure of my mode?

Thank you all  


RE: Check if my codeigniter 4 runs in multilingual mode. - InsiteFX - 05-06-2021

The multi-language in CodeIgniter should only be used for internal errors and strings.
all major new web browsers now support multi-language and they should do the conversion.

You can change the <html lang="en". to a different language and the web browser should pick it up.


RE: Check if my codeigniter 4 runs in multilingual mode. - sdiri - 05-09-2021

(05-06-2021, 11:30 AM)InsiteFX Wrote: The multi-language in CodeIgniter should only be used for internal errors and strings.
all major new web browsers now support multi-language and they should do the conversion.

You can change the <html lang="en". to a different language and the web browser should pick it up.

Thanks, but I am working on a back-end solution with 3 different languages.

Maybe, I didn't explain it to you well!

My problem is whether the current page uses the language key or if the key is just a variable.

How can I add a boolean variable when Codeigniter parses the fisrt key as a language key and that variable should be callable anywhere in my program.
For example: $ in_multilingual_mode = false;
When CodeIgniter interprets the first segment as a key the variable turns it would change to  $ in_multilingual_mode = true;

I have a specific case for that.
Thank you 




RE: Check if my codeigniter 4 runs in multilingual mode. - InsiteFX - 05-10-2021

You may need to use the _remap method.

Remapping Method Calls

PHP Code:
public function _remap($method$params = array())
  {
      $method 'process'.ucwords($method);
      if (method_exists($this$method))
      {
          return call_user_func_array(array($this$method), $params);
      }
      show_404();