Bottelet/
translation-checker
g4t.io

Translation Checker

130 stars by Yannick Lyn Fatt

A translation checker package for Laravel, find, add, and translate missing strings

README from Bottelet/translation-checker Open on GitHub →

Translation Checker

Easily translate missing translations with AI, find missing translations you forgot to add to your language files, and maintain translations in your project. It provides a set of commands to help with language files, ensuring consistency and completeness across your translations. It works with Laravel and supports various frontend frameworks like Vue.js, React, and Svelte.

This package is only intended for Laravel's recommended approach to handle translation files. See Laravel Docs

How it works

  1. Scan Source Files: The system looks through your code for strings that need translation.
  2. Check Language Files: It then checks if these strings exist in your language files.
  3. Use AI to translate missing keys: It adds the missing key with empty values if there is no translation service used.

Example:

lang.json

{
  "test.value": "Value"
}

lang.php

return [
  'test.value' => 'Value',
];

TestClass.php

class TestClass
{
    public function getValue()
    {
        return __('translate this string');
    }
}
php artisan translations:check en

lang.json

{
  "test.value": "Value",
  "translate this string": null
}

lang.php

return [
  'test.value' => 'Value',
  'translate this string' => null,
];

The reason we default to null when no translation service are used is because it defaults to the key used in the function call.

Quick Start

Install the package via composer:

  composer require bottelet/translation-checker --dev

Usage

Translation Checker provides several commands to manage your translations. The most versatile is the check command:

  php artisan translations:check en 

You can also easily find all sync translations between all files:

  php artisan translations:sync en

This will take all translations from the source files and sync them to all your other language files.

For detailed information on all available commands and their usage, refer to the documentation.

Testing

Run the tests with:

  ./vendor/bin/phpunit

Run PHPStan to check for code quality:

  ./vendor/bin/phpstan

Documentation

For full documentation, visit our GitHub documentation page.

If you encounter any issues or have suggestions, please create an issue on GitHub.

License

The MIT License (MIT). Please see License File for more information.

More from the ecosystem

marcreichel/
laya-php
g4t.io
3 53

LayaPHP: Self-Hosted Text Classification for PHP and Laravel

Classify text in PHP without an LLM bill: typed decisions in 100+ languages, self-hosted. Laravel-ready SDK for Laya, a Jev AI alternative.

ai classification decision-engine
marcreichel/laya-php via Laravel News
Josh-Dovey/
postcodes-laravel
g4t.io
5 9

Postcodes for Laravel: GB Postcode Lookup and Geography Data

Postcodes for Laravel adds typed GB postcode lookups, validation, geography data, distance searches, and test fakes through the GB Postcodes API.

Josh-Dovey/postcodes-laravel via Laravel News
RedberryProducts/
mailbox-for-laravel
g4t.io
4 115

Mailbox for Laravel: Preview and Test Rendered Email

Mailbox for Laravel captures outgoing mail in a local dashboard and lets you test rendered HTML, recipients, and attachments with fluent assertions.

RedberryProducts/mailbox-for-laravel via Laravel News