PHPackages                             smartness/translation-client - 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. smartness/translation-client

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

smartness/translation-client
============================

Laravel package to pull translations from SmartPMS Translation Manager

v1.0.7(3mo ago)0158↑100%MITPHPPHP ^8.1|^8.2|^8.3

Since Feb 3Pushed 3mo agoCompare

[ Source](https://github.com/smartpricing/php-translation-client)[ Packagist](https://packagist.org/packages/smartness/translation-client)[ RSS](/packages/smartness-translation-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (9)Used By (0)

Smartness Translation Client
============================

[](#smartness-translation-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3a49ea46cec6ba0cc3b44622e3b3f028465e19812de215e5c8a8c49896ba78d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d6172746e6573732f7472616e736c6174696f6e2d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smartness/translation-client)[![Total Downloads](https://camo.githubusercontent.com/dfc9bfff2d94ea6b816e016581cf17c0e3b0ec1003be423f77c4c4211c78d12e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736d6172746e6573732f7472616e736c6174696f6e2d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smartness/translation-client)

A Laravel package to synchronize translations between your Laravel application and a centralized translation management system. Pull translations from the server or push local translations back to keep everything in sync.

Features
--------

[](#features)

- 🚀 **One Command Install** - Get started in seconds
- 🔄 **Bi-directional Sync** - Pull and push translations with simple commands
- 🌍 **Multi-language** - Support for all languages
- 📦 **Laravel Compliant** - Generates proper Laravel translation files with nested arrays
- ⚡ **CI/CD Ready** - Perfect for automated deployments
- 🔒 **Secure** - API token authentication
- 🎯 **Smart Filtering** - Filter by language, status, or specific files
- ⬆️ **Push Support** - Send local translations back to the server

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

[](#requirements)

- PHP 8.1 or higher
- Laravel 10, 11, or 12

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

[](#installation)

Install via Composer:

```
composer require smartness/translation-client
```

The package will automatically register itself via Laravel's package auto-discovery.

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

[](#configuration)

### Step 1: Publish Configuration (Optional)

[](#step-1-publish-configuration-optional)

```
php artisan vendor:publish --tag=translation-client-config
```

This creates a `config/translation-client.php` file where you can customize settings.

### Step 2: Configure Environment Variables

[](#step-2-configure-environment-variables)

Add these variables to your `.env` file:

```
# Required: Your API token
TRANSLATION_API_TOKEN=your_api_token_here

# Required: API endpoint URL
TRANSLATION_API_URL=https://your-translation-service.com/api

# Optional: Override default settings
TRANSLATION_OUTPUT_DIR=  # Default: lang_path()
TRANSLATION_FORMAT=php   # Options: php, json, raw
TRANSLATION_STATUS=approved  # Filter: approved, pending, rejected
TRANSLATION_TIMEOUT=30   # HTTP timeout in seconds
```

**Note:** You'll receive your API token and endpoint URL from your translation service administrator.

Usage
-----

[](#usage)

### Pulling Translations (Download)

[](#pulling-translations-download)

Pull all translations from the server:

```
php artisan translations:pull
```

Pull translations for a specific language:

```
php artisan translations:pull --language=en
```

Preview changes without saving (dry-run):

```
php artisan translations:pull --dry-run
```

Test API connection:

```
php artisan translations:pull --test
```

#### Advanced Pull Options

[](#advanced-pull-options)

```
# Override format for this pull
php artisan translations:pull --format=json

# Override status filter
php artisan translations:pull --status=approved

# Combine multiple options
php artisan translations:pull --language=de --status=approved --dry-run
```

### Pushing Translations (Upload)

[](#pushing-translations-upload)

Push all local translations to the server:

```
php artisan translations:push
```

Push translations for a specific language:

```
php artisan translations:push --language=en
```

Push a specific translation file:

```
php artisan translations:push --language=en --file=messages
```

Preview without actually pushing:

```
php artisan translations:push --dry-run
```

Overwrite existing translations on the server:

```
php artisan translations:push --overwrite
```

Use a custom translation directory:

```
php artisan translations:push --dir=/path/to/translations
```

#### Advanced Push Options

[](#advanced-push-options)

```
# Combine multiple options
php artisan translations:push --language=en --file=auth --overwrite

# Preview what will be pushed
php artisan translations:push --dry-run --language=de
```

Output Structure
----------------

[](#output-structure)

The package creates translation files following Laravel's standard structure:

```
lang/
├── en/
│   ├── messages.php
│   ├── validation.php
│   └── auth.php
├── de/
│   ├── messages.php
│   ├── validation.php
│   └── auth.php
└── es/
    ├── messages.php
    ├── validation.php
    └── auth.php

```

### Example Generated File

[](#example-generated-file)

```
