PHPackages                             domprojects/codeigniter4-localize - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. domprojects/codeigniter4-localize

ActiveLibrary[Search &amp; Filtering](/categories/search)

domprojects/codeigniter4-localize
=================================

Locale management and URL localization filter for CodeIgniter 4 projects.

v1.0.1(2mo ago)03↓90%MITPHPPHP ^8.2CI passing

Since Apr 2Pushed 2mo agoCompare

[ Source](https://github.com/domProjects/codeigniter4-localize)[ Packagist](https://packagist.org/packages/domprojects/codeigniter4-localize)[ Docs](https://github.com/domProjects/codeigniter4-localize)[ RSS](/packages/domprojects-codeigniter4-localize/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Localize for CodeIgniter 4
==========================

[](#localize-for-codeigniter-4)

[![Packagist](https://camo.githubusercontent.com/a867c08cb45d30d26740130d5c8a7c36c84ec7eace877523ce6d85b49fd7354b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646f6d70726f6a656374732f636f646569676e69746572342d6c6f63616c697a653f6c6162656c3d5061636b6167697374)](https://packagist.org/packages/domprojects/codeigniter4-localize)[![License](https://camo.githubusercontent.com/8fd65c8617d1a26b6087a4fe2139ed232a6fa4ddceb3003d6a3ee00c84239960/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f646f6d50726f6a656374732f636f646569676e69746572342d6c6f63616c697a65)](https://github.com/domProjects/codeigniter4-localize/blob/main/LICENSE)[![PHPUnit](https://camo.githubusercontent.com/177e7bea63d7209c521639343d17072b1abe84e902dc9f4781c4efbda139140e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646f6d50726f6a656374732f636f646569676e69746572342d6c6f63616c697a652f706870756e69742e796d6c3f6272616e63683d6d61696e266c6162656c3d504850556e6974)](https://github.com/domProjects/codeigniter4-localize/actions/workflows/phpunit.yml)[![Psalm](https://camo.githubusercontent.com/fe159ceec905b2fdbcaa0a7f95c4781dba00fdfbbfbe46c59054b5ab03d4c119/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646f6d50726f6a656374732f636f646569676e69746572342d6c6f63616c697a652f7073616c6d2e796d6c3f6272616e63683d6d61696e266c6162656c3d5073616c6d)](https://github.com/domProjects/codeigniter4-localize/actions/workflows/psalm.yml)[![PHPStan](https://camo.githubusercontent.com/4f983a5cbcfdd914ad9574cac0f07e2dac4784d4bb97b1307c15a50eb85025e3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646f6d50726f6a656374732f636f646569676e69746572342d6c6f63616c697a652f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d5048505374616e)](https://github.com/domProjects/codeigniter4-localize/actions/workflows/phpstan.yml)

Locale management and URL localization filter for CodeIgniter 4.

This package adds a reusable localization filter that can:

- detect the visitor locale
- redirect root requests like `/` to `/{locale}`
- redirect requests without locale prefix to `/{locale}/...`
- persist the active locale in session and cookie
- validate locale segments against `Config\App::$supportedLocales`

Installation
------------

[](#installation)

```
composer require domprojects/codeigniter4-localize
```

How It Works
------------

[](#how-it-works)

The package registers a `localize` filter automatically through a `Registrar`.

It does not modify `app/Config/Filters.php` manually.

Configuration
-------------

[](#configuration)

The package uses two configuration sources:

1. `Config\App`
2. `domProjects\CodeIgniterLocalize\Config\Localize`

You should configure your project locales in `app/Config/App.php`:

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

Optional package behavior can be customized by creating:

```
app/Config/Localize.php

```

Example:

```
