PHP code example of domprojects / codeigniter4-localize

1. Go to this page and download the library: Download domprojects/codeigniter4-localize library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

domprojects / codeigniter4-localize example snippets


public string $defaultLocale = 'en';
public array $supportedLocales = ['en', 'fr'];



namespace Config;

use domProjects\CodeIgniterLocalize\Config\Localize as BaseLocalize;

class Localize extends BaseLocalize
{
    public bool $redirectRoot = true;
    public bool $redirectMissingLocale = true;
    public string $invalidLocaleBehavior = '404';

    public array $excluded = [
        'api/*',
        'assets/*',
        'favicon.ico',
        'robots.txt',
    ];
}

$routes->useSupportedLocalesOnly(true);

$routes->group('{locale}', static function ($routes) {
    $routes->get('/', 'Home::index');
    $routes->get('about', 'Pages::about');
});
text
app/Config/Localize.php
text
src/
  Config/
    Localize.php
    Registrar.php
  Filters/
    Localize.php