PHPackages                             comfyphp/lang - 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. [Framework](/categories/framework)
4. /
5. comfyphp/lang

AbandonedArchivedLibrary[Framework](/categories/framework)

comfyphp/lang
=============

Multiple languages extension for ComfyPHP

v1.1.1(2y ago)19MITPHPPHP &gt;=8.0

Since Jun 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/comfyphp/lang)[ Packagist](https://packagist.org/packages/comfyphp/lang)[ Docs](https://github.com/comfyphp/lang)[ RSS](/packages/comfyphp-lang/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

ComfyPHP Multiple Languages Extension
=====================================

[](#comfyphp-multiple-languages-extension)

This is an extension for ComfyPHP framework to enable the function using multiple languages.

Default &amp; Recommended Directory Structure
---------------------------------------------

[](#default--recommended-directory-structure)

```
├── src
│   └── langs
│       ├── en
│       │   └── index.json
│       ├── zh-Hans
│       │   └── index.json
│       └── zh-Hant
│           └── index.json
└── comfy.lang.config.php

```

Before Using it
---------------

[](#before-using-it)

As this is an extension for ComfyPHP, All dependencies required in ComfyPHP and ComfyPHP itself is needed to use this extension.

Download / Install
------------------

[](#download--install)

To use this extension, you can install it with Composer.

```
composer require comfyphp/lang
```

Usage
-----

[](#usage)

### Initialize

[](#initialize)

ComfyPHP will search for all the languages base on the `CONFIG_LANG_PATH` settings in `comfy.lang.config.php`.

You can add the following line into somewhere and import it into every files later, here we take `src/pages/_init.php` for example:

```
$lang = new ComfyPHP\Lang();
```

### Create JSON

[](#create-json)

Create separate JSON files for each language you want to support. And Place these files into the languages folder. For example, create the following files:

`src/langs/en/index.json`:

```
{
    "hello": "Hello!"
}
```

`src/langs/en/special.json`:

```
{
    "setting": {
        "title": "Settings",
        "info": "This is the Settings page."
    }
}
```

### Usage

[](#usage-1)

In the files where you want to use the multiple languages extension, add the following code to require the file which you initialized the lang extension and enable the function to use those languages:

```
$root = $GLOBALS["ROOT"];
$pagePath = $GLOBALS["CONFIG_PAGE_PATH"];
require_once "$root/$pagePath/_init.php";
$l = $lang->useLanguage();
```

You can now use language strings in your code. When you write `$l("hello")`, the extension will look for the key `hello` in the `index.json` file. If you write `$l("special:setting.info")`, the extension will search for the key `info` under the `setting` key in the `special.json` file.

```
echo $l("hello");
echo $l("special:setting.info");
```

Reserved Variables of the Extension
-----------------------------------

[](#reserved-variables-of-the-extension)

```
$GLOBALS["CONFIG_LANG_PATH"];
$GLOBALS["CONFIG_LANG_PROVIDER"];
$GLOBALS["CONFIG_LANG_FALLBACK"];
$GLOBALS["CONFIG_LANG_PARAM"];
$GLOBALS["CONFIG_LANG_PARAM_NAME"];
$GLOBALS["CONFIG_LANG_COOKIE"];
$GLOBALS["CONFIG_LANG_COOKIE_NAME"];
$GLOBALS["CONFIG_LANG_COOKIE_DOMAIN"];
$GLOBALS["CONFIG_LANG_COOKIE_TIME"];
```

License
-------

[](#license)

This project is MIT licensed, you can find the license file [here](./LICENSE).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Total

3

Last Release

972d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c3fce3d05e241aaae6c34437e10648e3e192b1c7f4bc4d8c88df499930cfe176?d=identicon)[alpheustangs](/maintainers/alpheustangs)

---

Top Contributors

[![alpheusmtx](https://avatars.githubusercontent.com/u/26622568?v=4)](https://github.com/alpheusmtx "alpheusmtx (7 commits)")

---

Tags

comfortablecomfortablycomfyphpextensionframeworklanguagelanguagesmultiple-languagesphpphp-frameworkphpframeworklanguagelanguageslangmultiplecomfycomfyphpcomfortablecomfortably

### Embed Badge

![Health badge](/badges/comfyphp-lang/health.svg)

```
[![Health](https://phpackages.com/badges/comfyphp-lang/health.svg)](https://phpackages.com/packages/comfyphp-lang)
```

###  Alternatives

[laravel-lang/common

Easily connect the necessary language packs to the application

1463.1M21](/packages/laravel-lang-common)[laravel-lang/publisher

Localization publisher for your Laravel application

2167.7M24](/packages/laravel-lang-publisher)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
