PHPackages                             vixen/laravel-lynguist - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. vixen/laravel-lynguist

ActiveLibrary[Localization &amp; i18n](/categories/localization)

vixen/laravel-lynguist
======================

1.1.0(2mo ago)018MITPHPPHP ^8.3

Since Feb 7Pushed 2mo agoCompare

[ Source](https://github.com/vixen-tech/laravel-lynguist)[ Packagist](https://packagist.org/packages/vixen/laravel-lynguist)[ RSS](/packages/vixen-laravel-lynguist/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (8)Versions (6)Used By (0)

Laravel Lynguist
================

[](#laravel-lynguist)

A Laravel package that automatically discovers and manages translation strings in your application. Scan your codebase for translation function calls, generate language files, and optionally sync with [lynguist.com](https://lynguist.com) for collaborative translation management.

> Works in tandem with NPM's package [@vixen-tech/lynguist](https://www.npmjs.com/package/@vixen-tech/lynguist).

Features
--------

[](#features)

- **Automatic Translation Discovery** - Scans PHP, Blade, JavaScript, Vue, and TypeScript files for translation function calls
- **Multi-Language Support** - Generates and manages JSON language files for multiple languages
- **Smart Merging** - Preserves existing translations when scanning for new strings
- **TypeScript Integration** - Auto-generates TypeScript declaration files for type-safe frontend translations
- **Cloud Sync** - Upload and sync translations with lynguist.com
- **Customizable** - Configure which directories to scan, file extensions to include, and translation functions to detect

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 12.x

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

[](#installation)

Install the package via Composer:

```
composer require vixen/laravel-lynguist
```

The package auto-registers via Laravel's service provider discovery.

Publish the configuration file:

```
php artisan vendor:publish --provider="Vixen\Lynguist\LynguistServiceProvider"
```

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

[](#configuration)

After publishing, configure the package in `config/lynguist.php`:

```
return [
    // Default/reference language
    'default_language' => 'en',

    // Languages to generate files for
    'languages' => ['en'],

    // Translation functions to search for
    'search_for' => ['__', 'lang', 'trans', 'trans_choice', 'transChoice', 'choice'],

    // Output directory for language JSON files
    'output_path' => lang_path(),

    // TypeScript declarations file path (set to false to disable)
    'types_path' => resource_path('js/types/translations.d.ts'),

    // Directories to scan for translations
    'scannable_paths' => [
        app_path(),
        resource_path('views'),
        resource_path('js'),
    ],

    // File extensions to scan (null for all files)
    'allowed_extensions' => ['php', 'js', 'jsx', 'ts', 'tsx', 'vue'],

    // Lynguist.com integration
    'connect' => [
        'api_token' => env('LYNGUIST_API_TOKEN'),
        'timeout' => env('LYNGUIST_TIMEOUT', 120),
    ],
];
```

> You can include in the config file only altered options, since they are merged with defaults.

Usage
-----

[](#usage)

### Scanning for Translations

[](#scanning-for-translations)

Run the scan command to discover all translation strings in your codebase:

```
php artisan lynguist:scan
```

This will:

1. Scan configured directories for translation function calls
2. Create/update JSON language files in your `lang/` directory
3. Generate TypeScript declarations (if configured)

To also upload translations to lynguist.com (this requires an API key):

```
php artisan lynguist:scan --upload
```

### Supported Translation Functions

[](#supported-translation-functions)

The package detects the following translation functions by default:

**PHP/Blade:**

```
__('welcome-message')
trans('greeting')
trans_choice('items', $count)
lang('settings.timezone')
```

**Blade Directives:**

```
@lang('page-title')
@choice('notifications', $count)
```

**JavaScript/Vue:**

```
__('frontend-string')
trans('greeting', { name: 'Jane' })
transChoice('pluralized-key', count)
```

### Language File Output

[](#language-file-output)

The scan creates JSON files for each configured language (e.g., `lang/en.json`):

```
{
    "greeting": null,
    "items": null,
    "welcome-message": null
}
```

Keys with `null` values are untranslated. Add your translations:

```
{
    "welcome-message": "Welcome to our application!",
    "greeting": "Hello",
    "items": "{0} No items|{1} One item|[2,*] :count items"
}
```

Existing translations are preserved when re-scanning and then sorted alphabetically.

### Programmatic Usage

[](#programmatic-usage)

You can also use the package programmatically via the facade:

```
use Vixen\Lynguist\Facades\Lynguist;

// Scan directories for translation terms
$terms = Lynguist::scan([
    app_path(),
    resource_path('views'),
]);

// Store terms to language files
Lynguist::store($terms);

// Get translations for a language
$translations = Lynguist::translations('en');

// Merge new terms with existing translations
$merged = Lynguist::merge($terms, 'en');

// Generate TypeScript declarations
Lynguist::generateTypeScriptFile($terms);
```

TypeScript Integration
----------------------

[](#typescript-integration)

When `types_path` is configured, the package generates TypeScript declarations for type-safe frontend translations:

```
// resources/js/types/translations.d.ts (configurable)
interface LynguistTranslations {
    'greeting': string
    'items': string
    'welcome-message': string
}
```

This enables autocomplete and type checking for translation keys in your frontend code.

Cloud Sync with Lynguist.com
----------------------------

[](#cloud-sync-with-lynguistcom)

To sync translations with [lynguist.com](https://lynguist.com):

1. Add your credentials to `.env`:

    ```
    LYNGUIST_API_TOKEN=your_api_token
    LYNGUIST_TIMEOUT=120
    ```
2. Upload existing translations:

    ```
    php artisan lynguist:upload
    ```

    Or include the `--upload` flag when scanning:

    ```
    php artisan lynguist:scan --upload
    ```
3. Download translations from Lynguist.com:

    ```
    php artisan lynguist:download
    ```
4. Create your callback endpoint:

    ```
    use Illuminate\Http\Request;
    use Vixen\Lynguist\Lynguist;

    class SyncController extends Controller
    {
        public function sync(Request $request, Lynguist $lynguist)
        {
            $lynguist->sync($request->input('translations'));

            return response([
                'message' => 'Updated!',
            ]);
        }
    }
    ```

Custom Translation Functions
----------------------------

[](#custom-translation-functions)

To detect custom translation functions, add them to the `search_for` config:

```
'search_for' => [
    '__',
    'trans',
    'myCustomHelper',
    'Label', // Supports class/attribute names too
],
```

License
-------

[](#license)

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

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance85

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

Total

5

Last Release

80d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05ca9e5f22ddfbacac280fe76010f41a245cce7916d37ba5ad5d6b873ad63f29?d=identicon)[atorscho](/maintainers/atorscho)

---

Top Contributors

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

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/vixen-laravel-lynguist/health.svg)

```
[![Health](https://phpackages.com/badges/vixen-laravel-lynguist/health.svg)](https://phpackages.com/packages/vixen-laravel-lynguist)
```

###  Alternatives

[illuminate/translation

The Illuminate Translation package.

6938.0M572](/packages/illuminate-translation)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

725173.2k14](/packages/tallstackui-tallstackui)[elegantly/laravel-translator

All on one translations management for Laravel

6333.1k](/packages/elegantly-laravel-translator)

PHPackages © 2026

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