CodeIgniter Forums
localization issue - 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: localization issue (/showthread.php?tid=79150)

Pages: 1 2


RE: localization issue - paliz - 05-04-2021

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']; 



RE: localization issue - eleumas - 05-11-2021

(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?


RE: localization issue - includebeer - 05-11-2021

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.


RE: localization issue - eleumas - 05-11-2021

(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!


RE: localization issue - InsiteFX - 05-12-2021

CodeIgniter 4 Language Localization