Welcome Guest, Not a member yet? Register   Sign In
localization issue
#11

go to  app config ci4 

in this  exmple  two lang en ,fa 

so use Accept-Language header. = en or fa, ... change back end lng 
PHP Code:
public $defaultLocale 'en';

    
/**
     * --------------------------------------------------------------------------
     * Negotiate Locale
     * --------------------------------------------------------------------------
     *
     * If true, the current Request object will automatically determine the
     * language to use based on the value of the Accept-Language header.
     *
     * If false, no automatic detection will be performed.
     *
     * @var boolean
     */
    
public $negotiateLocale true;

    
/**
     * --------------------------------------------------------------------------
     * Supported Locales
     * --------------------------------------------------------------------------
     *
     * If $negotiateLocale is true, this array lists the locales supported
     * by the application in descending order of priority. If no match is
     * found, the first locale will be used.
     *
     * @var string[]
     */
    
public $supportedLocales = ['en','fa']; 
Enlightenment  Is  Freedom
Reply
#12

(This post was last modified: 05-11-2021, 12:09 AM by eleumas.)

(05-04-2021, 02:13 AM)InsiteFX Wrote: Read this may help you to understand what were talking about.

Multilanguage Database Design in MySQL

Thanks for your link. I have always used language file in Codeigniter. In Codeigniter 3 was very easy and all worked perfectly.
In Codeigniter 4 i'm having some problems and all is more complicated.

So, my question is always the same.
How can i use localization in Codigniter 4 (Controller and Routes)?
Why localization is been implemented if i have to use a database for build a simple multilingual site?
Reply
#13

You don’t have to use a database. It’s useful if you have long text like blog articles in multiple languages. But for single words or sentences you can still use language files like in CI3. The only thing that changed in CI4 I think is the routing with {locale} in the URL.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#14

(05-11-2021, 04:31 AM)includebeer Wrote: You don’t have to use a database. It’s useful if you have long text like blog articles in multiple languages. But for single words or sentences you can still use language files like in CI3. The only thing that changed in CI4 I think is the routing with {locale} in the URL.
 Thanks for reply @includebeer.

No there are some difference. I would like find an example because the documentation is poor. I searched on Google but there isn't anything. I would like understand how to set a controller and routes.

I have used localization and it works perfectly but there are some problems and i'm not understanding if i wrong something or if there are possible bug in CI 4.

Someone has a project with localization to show me please? A little example...THANKS!
Reply
#15

CodeIgniter 4 Language Localization
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