PHPackages                             fereron/yii2-js-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. fereron/yii2-js-localize

ActiveLibrary

fereron/yii2-js-localize
========================

JsLocalizator is a Yii2 extension aiming to port the native Yii2 translations module to javascript.

020JavaScript

Since Oct 19Pushed 5y agoCompare

[ Source](https://github.com/fereron/yii2-js-localize)[ Packagist](https://packagist.org/packages/fereron/yii2-js-localize)[ RSS](/packages/fereron-yii2-js-localize/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Yii2-js-localize
================

[](#yii2-js-localize)

Yii2-js-localize is a Yii2 extension aiming to port the native Yii2 translations module to javascript. Language files can be published and used within javascript in almost the same way as Yii2 does server side. Currently supported are placeholders and plural forms (including expressions).

Usage
-----

[](#usage)

Translations can be used in javascript:

```
Yii.t('app','My non-translated text');

```

Make sure there is a translation available to see the results.

Examples
--------

[](#examples)

(for demo purposes the default language is English, it could be any language)

Simple translation:

```
Yii.t('app','Hello world');  // Hello World

```

Simple translation with custom language:

```
Yii.t('app','Hello world','','fr');  // Bonjour tout le monde
Yii.t('app','Hello world','','de');  // Hallo Welt

```

Placeholder:

```
Yii.t('app','Hello {name}',{name:'Michael'}); // Hello Michael

```

Multiple placeholders:

```
Yii.t('app','Hello {firstname} {lastname}', {firstname:'Michael', lastname:'Jackson'}); // Hello Michael Jackson

```

Plural forms:

```
Yii.t('app','Apple|Apples',0); // Apples
Yii.t('app','Apple|Apples',1); // Apple
Yii.t('app','Apple|Apples',2); // Apples

```

Plural forms with placeholders:

```
Yii.t('app','{n} Apple|{n} Apples',0); // 0 Apples
Yii.t('app','{n} Apple|{n} Apples',1); // 1 Apple
Yii.t('app','{n} Apple|{n} Apples',2); // 2 Apples

```

Plural forms with expressions:

```
Yii.t('app','0#No comments, be the first!|1#One comment|n>1#{n} comments',0); // No comments, be the first!
Yii.t('app','0#No comments, be the first!|1#One comment|n>1#{n} comments',1); // One comment
Yii.t('app','0#No comments, be the first!|1#One comment|n>1#{n} comments',2); // 2 comments

```

Plural forms with expressions and placeholders:

```
Yii.t('app','0#{name} has no mail|1#{name} has one mail|n>1#{name} has {n} mails',{n:0, name:'Pete'}); // Pete has no mail
Yii.t('app','0#{name} has no mail|1#{name} has one mail|n>1#{name} has {n} mails',{n:1, name:'Pete'}); // Pete has one mail
Yii.t('app','0#{name} has no mail|1#{name} has one mail|n>1#{name} has {n} mails',{n:2, name:'Pete'}); // Pete has 2 mails

```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5af64dc3b402fcab8bb5e086c1851488525840d22290d99914458ceed9e2641d?d=identicon)[fereron](/maintainers/fereron)

---

Top Contributors

[![fereron](https://avatars.githubusercontent.com/u/25907593?v=4)](https://github.com/fereron "fereron (5 commits)")

### Embed Badge

![Health badge](/badges/fereron-yii2-js-localize/health.svg)

```
[![Health](https://phpackages.com/badges/fereron-yii2-js-localize/health.svg)](https://phpackages.com/packages/fereron-yii2-js-localize)
```

PHPackages © 2026

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