PHPackages                             hsm/lokale - 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. hsm/lokale

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

hsm/lokale
==========

Laravel Auto Locale Generator: Scan your Laravel project and automatically generate missing translation keys.

v1.1.6(6mo ago)7324MITPHPPHP ^7.4|^8.0

Since Feb 12Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/bahmankhah/lokale)[ Packagist](https://packagist.org/packages/hsm/lokale)[ RSS](/packages/hsm-lokale/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (13)Used By (0)

Lokale
======

[](#lokale)

**Lokale** is a Laravel package designed to automatically extract and generate translation files by scanning your source code for translation keys. It also supports syncing translations between different locales.

🧩 Installation
--------------

[](#-installation)

Install the package using Composer:

```
composer require hsm/lokale
```

⚙️ Configuration
----------------

[](#️-configuration)

This package uses Laravel's package discovery. If for some reason it's not auto-discovered, register it manually:

```
'providers' => [
    Hsm\Lokale\LokaleServiceProvider::class,
];
```

🚀 Usage
-------

[](#-usage)

### 1. Generate Locale Files

[](#1-generate-locale-files)

You can generate translation files by scanning your source code:

```
php artisan locale:make
```

#### Options

[](#options)

OptionDescription`--locale`Target locale to generate files for (default: value of `app.locale`).`--src`Directory to scan for translation keys (default: `app/`).`--default`Used for generating default translation placeholders (default: `default`).`--comment`Adds `@TODO` comments to missing translations with context information.`--output`Output directory for language files (default: `lang/`).`--no-placeholder`Do not generate placeholder values.#### Example

[](#example)

```
php artisan locale:make --locale=fr --src=app --comment
```

This will generate files like:

```
resources/lang/fr/messages.php
resources/lang/fr/auth.php

```

Each file will contain translation keys extracted from `__()`, `trans()`, or `trans_choice()` usage across your source code.

### 2. Sync Between Locales

[](#2-sync-between-locales)

You can synchronize translation files between two locales using:

```
php artisan locale:sync --from=en --to=fr
```

#### Options

[](#options-1)

OptionDescription`--from`Source locale. Required.`--to`Target locale. Required.`--output`Base directory for language files (default: `lang/`).`--comment`Adds `@TODO` comments for untranslated keys in target files.`--no-placeholder`Do not generate placeholder values.This is useful when adding new keys in one language and you want the same structure in another language.

### 3. Generate Attribute Translations

[](#3-generate-attribute-translations)

This command generates translation files for form request attributes:

```
php artisan locale:attributes --locale=fr
```

#### Options

[](#options-2)

OptionDescription`--locale`Target locale.`--src`Directory for form requests (default: `app/Http/Requests`).`--output`Output directory (default: `lang/`).`--comment`Add comments for missing translations.`--no-placeholder`Do not generate placeholder values.This helps to keep validation error messages localized and consistent.

🧠 How It Works
--------------

[](#-how-it-works)

- Scans PHP and Blade files for translation functions (`__()`, `trans()`, `trans_choice()`).
- Extracts keys and organizes them into proper translation files.
- Adds `@TODO` comments for untranslated placeholders when `--comment` is enabled.
- Generates modern, readable PHP array syntax.

📂 Output Example
----------------

[](#-output-example)

`resources/lang/fr/messages.php`

```
