PHPackages                             survos/lingua-core - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. survos/lingua-core

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

survos/lingua-core
==================

Core identity utilities (hash/key calculation and canonicalization) shared across Survos Lingua, Babel, and server implementations.

2.0.182(5mo ago)0457—8.3%4MITPHPPHP ^8.4

Since Dec 14Pushed 2mo agoCompare

[ Source](https://github.com/survos/lingua-core)[ Packagist](https://packagist.org/packages/survos/lingua-core)[ GitHub Sponsors](https://github.com/kbond)[ RSS](/packages/survos-lingua-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (91)Used By (4)

Lingua Core
===========

[](#lingua-core)

**Lingua Core** is a small, framework-agnostic PHP library that defines the *canonical identity model* for translatable strings.

It is intentionally boring.

There are **no translators**, **no HTTP clients**, **no queues**, and **no storage** here.
Lingua Core exists to guarantee that every part of a multilingual system agrees on:

- how source strings are identified
- how translations are keyed
- how locales are normalized
- how hashes are derived (and remain stable)

This bundle is the lowest layer used by higher-level systems such as **Babel**, **Lingua**, and translation servers.

---

What Lingua Core Is
-------------------

[](#what-lingua-core-is)

Lingua Core provides:

- **Deterministic hash generation** for:
    - source strings
    - translation keys
- **Locale normalization**
- **Stable identity guarantees** across:
    - databases
    - queues
    - JSONL caches
    - HTTP boundaries
    - multiple applications

If two systems use Lingua Core, they will compute **the same keys** for the same inputs.

---

What Lingua Core Is *Not*
-------------------------

[](#what-lingua-core-is-not)

Lingua Core deliberately does **not** include:

- Translation engines (DeepL, LibreTranslate, etc.)
- Symfony services or configuration
- Doctrine entities
- Database access
- HTTP clients
- Caching
- CLI commands

Those belong in higher layers.

---

Core Concepts
-------------

[](#core-concepts)

### Source Key (`str_hash`)

[](#source-key-str_hash)

A **source key** uniquely identifies a string *in its source language*.

It is derived from:

- the original text
- the source locale

```
php
use Survos\Lingua\Core\Identity\HashUtil;

$strHash = HashUtil::calcSourceKey(
    'Museum of Things',
    'en'
);
```

This key is:

- deterministic
- content-based
- stable across systems
- safe to persist and share

---

### Translation Key (`tr_hash`)

[](#translation-key-tr_hash)

A **translation key** identifies a translation *of a specific source string* into a target locale.

It is derived from:

- the source key
- the target locale
- an optional namespace (engine or logical domain)

```
php
$trHash = HashUtil::calcTranslationKey(
    $strHash,
    'es',
    'babel'
);
```

Namespaces allow multiple translation systems to coexist without schema changes.

---

### Locale Normalization

[](#locale-normalization)

Locales are normalized consistently to avoid mismatches:

```
php
HashUtil::normalizeLocale('EN-us'); // 'en'
HashUtil::normalizeLocale('pt_BR'); // 'pt'
```

This ensures that `en`, `en_US`, and `en-us` do not silently diverge.

---

Why Hash-Based Identity?
------------------------

[](#why-hash-based-identity)

Lingua Core uses **content-addressed identity** rather than numeric IDs because:

- strings may originate in different systems
- strings may be discovered lazily
- translation may happen asynchronously
- systems may not share a database

A hash-based key lets you:

- insert without coordination
- upsert safely
- merge datasets
- cache translations in files
- move work across queues or services

---

Typical Usage (Higher Layers)
-----------------------------

[](#typical-usage-higher-layers)

Lingua Core is usually consumed indirectly.

Examples:

- **Babel Bundle**

    Uses source keys for `str.hash` and translation keys for `str_translation.hash`.
- **Lingua Bundle**

    Implements translation workflows, batching, dispatch, and integration with external engines.
- **Translation Servers / Workers**
    Consume Lingua Core hashes to translate at scale without sharing database IDs.
- **JSONL Translation Caches**
    Use hashes as stable primary keys for offline or file-based translation storage.
- **CLI / Batch Pipelines**
    Operate on hashes instead of database IDs to remain portable.

---

Design Guarantees
-----------------

[](#design-guarantees)

Lingua Core guarantees:

- **No breaking changes to hash algorithms** without a major version
- **Pure functions** (no I/O, no globals)
- **Framework independence**
- **Cross-language portability** (algorithms are trivial to reimplement elsewhere)

---

Versioning Policy
-----------------

[](#versioning-policy)

- Patch releases: bug fixes only
- Minor releases: additive helpers
- Major releases: identity semantics may change (rare, explicit)

If a hash algorithm ever changes, it will be treated as a **data migration event**, not a refactor.

---

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

[](#installation)

```
bash
composer require survos/lingua-core
```

Lingua Core has **no required dependencies** beyond PHP itself.

---

Philosophy
----------

[](#philosophy)

> Translation is not about strings.
> It is about identity.

Lingua Core exists so everything else can be opinionated, flexible, and replaceable—without ever disagreeing on *what* is being translated.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance81

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 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 ~0 days

Total

90

Last Release

154d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21b39551f92ed4143772c622f9e571589c5a72c96ab3c53fe67489ce0d83e806?d=identicon)[tacman1123](/maintainers/tacman1123)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

![Health badge](/badges/survos-lingua-core/health.svg)

```
[![Health](https://phpackages.com/badges/survos-lingua-core/health.svg)](https://phpackages.com/packages/survos-lingua-core)
```

###  Alternatives

[novus/nvd3

A reusable charting library written in d3.js

7.2k207.7k2](/packages/novus-nvd3)[aimeos/ai-controller-frontend

Aimeos business controller logic for frontend

966339.3k12](/packages/aimeos-ai-controller-frontend)[pugx/autocompleter-bundle

Add an autocomplete type to forms

93861.6k3](/packages/pugx-autocompleter-bundle)[innmind/immutable

Immutable PHP primitive wrappers

75218.0k74](/packages/innmind-immutable)[beacon-hq/bag

A comprehensive immutable value objects implementation

1789.1k3](/packages/beacon-hq-bag)[rcknr/nova-multiselect-filter

A Laravel Nova filter that allows multiple selection.

26275.0k2](/packages/rcknr-nova-multiselect-filter)

PHPackages © 2026

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