PHPackages                             kilic-berkay/laravel-translation-integrity-checker - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. kilic-berkay/laravel-translation-integrity-checker

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

kilic-berkay/laravel-translation-integrity-checker
==================================================

A Laravel package to check translation integrity by detecting duplicates, missing translations, and unused keys

12PHPCI passing

Since Aug 23Pushed 8mo agoCompare

[ Source](https://github.com/kilic-berkay/laravel-translation-integrity-checker)[ Packagist](https://packagist.org/packages/kilic-berkay/laravel-translation-integrity-checker)[ RSS](/packages/kilic-berkay-laravel-translation-integrity-checker/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Translation Integrity Checker
=====================================

[](#laravel-translation-integrity-checker)

A comprehensive Laravel package for checking translation integrity by detecting duplicate keys, missing translations, and unused keys in your Laravel applications.

Features
--------

[](#features)

- 🔍 **Duplicate Key Detection**: Find duplicate translation keys in PHP array and JSON language files
- 🚫 **Missing Key Detection**: Scan your codebase for translation function calls and identify missing translations
- 🗑️ **Unused Key Detection**: Find translation keys that exist but are not used in your code
- 📊 **Multiple Output Formats**: Get results in table, JSON, or text format
- 🎯 **CI/CD Ready**: Fail-on-error options for automated pipelines
- ⚙️ **Highly Configurable**: Customize paths, file patterns, and translation function patterns

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

[](#installation)

### Via Composer

[](#via-composer)

```
composer require kilic-berkay/laravel-translation-integrity-checker
```

### Manual Installation

[](#manual-installation)

1. Clone this repository into your project
2. Add the package to your `composer.json`:

```
{
    "require": {
        "kilic-berkay/laravel-translation-integrity-checker": "*"
    },
    "repositories": [
        {
            "type": "path",
            "url": "./Translation Integrity Checker"
        }
    ]
}
```

3. Run `composer install`

### Service Provider Registration

[](#service-provider-registration)

The package will auto-register with Laravel. If you need to manually register it, add the service provider to your `config/app.php`:

```
'providers' => [
    // ...
    KilicBerkay\TranslationIntegrityChecker\TranslationIntegrityCheckerServiceProvider::class,
],
```

### Publish Configuration (Optional)

[](#publish-configuration-optional)

```
php artisan vendor:publish --tag=translation-integrity-checker-config
```

Usage
-----

[](#usage)

### Basic Commands

[](#basic-commands)

#### Check for Duplicate Keys

[](#check-for-duplicate-keys)

```
# Check for duplicate translation keys
php artisan lang:check-duplicates

# With custom language path
php artisan lang:check-duplicates --lang-path=/custom/lang/path

# Output in JSON format
php artisan lang:check-duplicates --format=json

# Fail on error (useful for CI/CD)
php artisan lang:check-duplicates --fail-on-error
```

#### Check for Missing Keys

[](#check-for-missing-keys)

```
# Check for missing translation keys
php artisan lang:check-missing

# With custom source paths
php artisan lang:check-missing --source-paths=app --source-paths=resources/views

# Output in text format
php artisan lang:check-missing --format=text
```

#### Check for Unused Keys

[](#check-for-unused-keys)

```
# Check for unused translation keys
php artisan lang:check-unused

# With custom configuration
php artisan lang:check-unused --lang-path=/custom/lang --source-paths=app
```

#### Run All Checks

[](#run-all-checks)

```
# Run all checks
php artisan lang:check-all

# Skip specific checks
php artisan lang:check-all --skip-unused

# Custom configuration for all checks
php artisan lang:check-all --lang-path=/custom/lang --source-paths=app --format=json
```

### Example Output

[](#example-output)

#### Duplicate Keys Check

[](#duplicate-keys-check)

```
🔍 Checking for duplicate translation keys...
❌ Duplicate translation keys found:

Locale: en
File: auth.php
┌─────────────┬─────┐
│ Key         │ Count│
├─────────────┼─────┤
│ auth.failed │ 2    │
│ auth.throttle│ 3   │
└─────────────┴─────┘

```

#### Missing Keys Check

[](#missing-keys-check)

```
🔍 Checking for missing translation keys...
❌ Missing translation keys found:

Locale: en
┌─────────────────┐
│ Missing Key     │
├─────────────────┤
│ auth.new_user   │
│ validation.email │
└─────────────────┘

```

#### Unused Keys Check

[](#unused-keys-check)

```
🔍 Checking for unused translation keys...
⚠️  Unused translation keys found:

Locale: en
┌─────────────────┐
│ Unused Key      │
├─────────────────┤
│ old.translation │
│ deprecated.key  │
└─────────────────┘

```

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

[](#configuration)

The package configuration file (`config/translation-integrity-checker.php`) allows you to customize:

### Language Files Path

[](#language-files-path)

```
'lang_path' => resource_path('lang'),
```

### Source Paths to Scan

[](#source-paths-to-scan)

```
'source_paths' => [
    app_path(),
    resource_path('views'),
    resource_path('js'),
    base_path('routes'),
],
```

### File Patterns

[](#file-patterns)

```
'file_patterns' => [
    '*.php',
    '*.blade.php',
    '*.vue',
    '*.js',
    '*.ts',
],
```

### Translation Function Patterns

[](#translation-function-patterns)

```
'translation_patterns' => [
    // Laravel translation helpers
    '/__\s*\(\s*[\'"]([^\'"]+)[\'"]\s*\)/',
    '/trans\s*\(\s*[\'"]([^\'"]+)[\'"]\s*\)/',
    '/@lang\s*\(\s*[\'"]([^\'"]+)[\'"]\s*\)/',

    // Vue.js i18n patterns
    '/\$t\s*\(\s*[\'"]([^\'"]+)[\'"]\s*\)/',

    // JavaScript i18n patterns
    '/i18n\.t\s*\(\s*[\'"]([^\'"]+)[\'"]\s*\)/',
],
```

### Excluded Paths

[](#excluded-paths)

```
'excluded_paths' => [
    base_path('vendor'),
    base_path('node_modules'),
    base_path('storage'),
    base_path('bootstrap/cache'),
],
```

CI/CD Integration
-----------------

[](#cicd-integration)

### GitHub Actions

[](#github-actions)

```
name: Translation Integrity Check

on: [push, pull_request]

jobs:
  translation-check:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: '8.1'

    - name: Install dependencies
      run: composer install --prefer-dist --no-progress

    - name: Run translation integrity checks
      run: php artisan lang:check-all --fail-on-error
```

### GitLab CI

[](#gitlab-ci)

```
translation-check:
  stage: test
  script:
    - composer install --prefer-dist --no-progress
    - php artisan lang:check-all --fail-on-error
  only:
    - merge_requests
    - main
```

### Jenkins Pipeline

[](#jenkins-pipeline)

```
pipeline {
    agent any

    stages {
        stage('Translation Check') {
            steps {
                sh 'composer install --prefer-dist --no-progress'
                sh 'php artisan lang:check-all --fail-on-error'
            }
        }
    }
}
```

Environment Variables
---------------------

[](#environment-variables)

You can configure the package behavior using environment variables:

```
# Output format (table, json, text)
TRANSLATION_CHECKER_OUTPUT_FORMAT=json

# Fail on errors (true/false)
TRANSLATION_CHECKER_FAIL_ON_ERRORS=true

# Verbose output (true/false)
TRANSLATION_CHECKER_VERBOSE=false
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Translation Patterns

[](#custom-translation-patterns)

Add custom patterns to detect your specific translation function calls:

```
'translation_patterns' => [
    // Your custom patterns
    '/myCustomTrans\s*\(\s*[\'"]([^\'"]+)[\'"]\s*\)/',
    '/translate\s*\(\s*[\'"]([^\'"]+)[\'"]\s*\)/',
],
```

### Excluding Specific Files

[](#excluding-specific-files)

```
'excluded_paths' => [
    base_path('vendor'),
    base_path('node_modules'),
    base_path('storage'),
    base_path('bootstrap/cache'),
    base_path('tests'), // Exclude test files
],
```

### Multiple Language Paths

[](#multiple-language-paths)

If you have translations in multiple locations, you can run checks for each:

```
# Check main language files
php artisan lang:check-all --lang-path=resources/lang

# Check package language files
php artisan lang:check-all --lang-path=vendor/package/lang
```

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

1. **No language files found**: Ensure your `lang_path` configuration points to the correct directory
2. **Missing translations not detected**: Check that your `translation_patterns` match your actual function calls
3. **Performance issues**: Consider excluding large directories like `vendor` and `node_modules`

### Debug Mode

[](#debug-mode)

Enable verbose output to see detailed information:

```
php artisan lang:check-all --verbose
```

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Support
-------

[](#support)

For support, please open an issue on GitHub or contact the maintainers.

Changelog
---------

[](#changelog)

### v1.0.0

[](#v100)

- Initial release
- Duplicate key detection
- Missing key detection
- Unused key detection
- Multiple output formats
- CI/CD integration support

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance42

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90% 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/973797a38e8a33469aa59b00d0c85c1713af0aa602921534c7351b776d0e096a?d=identicon)[kilic-berkay](/maintainers/kilic-berkay)

---

Top Contributors

[![whowww](https://avatars.githubusercontent.com/u/111494509?v=4)](https://github.com/whowww "whowww (9 commits)")[![kilic-berkay](https://avatars.githubusercontent.com/u/10053404?v=4)](https://github.com/kilic-berkay "kilic-berkay (1 commits)")

### Embed Badge

![Health badge](/badges/kilic-berkay-laravel-translation-integrity-checker/health.svg)

```
[![Health](https://phpackages.com/badges/kilic-berkay-laravel-translation-integrity-checker/health.svg)](https://phpackages.com/packages/kilic-berkay-laravel-translation-integrity-checker)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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