Welcome Guest, Not a member yet? Register   Sign In
Check if my codeigniter 4 runs in multilingual mode.
#1
Exclamation 
(This post was last modified: 05-09-2021, 01:30 PM by sdiri.)

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  
Reply
#2

(This post was last modified: 05-06-2021, 11:33 AM by InsiteFX.)

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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 [font=Tahoma, Verdana, Arial, sans-serif] $ in_multilingual_mode = true;

I have a specific case for that.
Thank you 

[/font]
Reply
#4

(This post was last modified: 05-10-2021, 01:54 AM by InsiteFX. Edit Reason: Added array usage )

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();
  
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB