Download the PHP package webo3/laravel-translator without Composer

On this page you can find all versions of the php package webo3/laravel-translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-translator

Laravel Translator

A Laravel package that provides artisan commands to scan, export, import and auto-translate translation strings. It extracts translation keys from your source code, manages JSON language files, supports CSV and XLIFF workflows for working with translators, and can automatically translate using the Google Translate API.

Supported translation functions

Function File types Example
__() PHP, JS, TS, Vue __('Hello world')
Lang::get() PHP Lang::get('messages.welcome')
@lang() PHP (Blade) @lang('Please login')
$t() JS, TS, Vue $t('Vue key')
.t() JS, TS, Vue i18n.t('My key')

Quote handling

Installation

Package auto-discovery is enabled for Laravel >= 5.5. For older versions, register the provider manually in config/app.php:

Configuration

Publish the configuration file to specify which languages to manage:

This creates config/webo3-translator.php with the following options:

Usage

1. Scan and extract translations

Scans *.php, *.js, *.ts and *.vue files in the configured scan_paths for translation function calls. Extracts unique keys and creates/updates a JSON file for each configured language.

Clean unused keys

Add the --clean option to detect and remove translation keys that are no longer used in your source files:

This will scan your code, then compare existing keys in each language JSON file against the keys found in source. Unused keys are listed in a table and you are prompted for confirmation before they are removed.

2. Export translations

Reads all language JSON files and exports them in the configured format.

CSV format (default)

Exports a single translations.csv file with a UTF-8 BOM for Excel compatibility:

key en fr
Hello world Hello world Bonjour le monde
Goodbye Goodbye Au revoir

Untranslated values (where the value equals the key) appear as empty cells.

XLIFF format

Set 'format' => 'xliff' in your config. Exports one XLIFF 1.2 file per target language (e.g. translations-fr.xlf). The first language in your languages array is used as the source language.

XLIFF is the industry standard format supported by professional translation tools (SDL Trados, memoQ, Phrase, Crowdin, etc.).

3. Import translations

Reads the exported file(s) and merges the translated values back into the JSON language files.

4. Auto-translate with an API

Automatically translates untranslated keys using a translation API and saves the results directly to your JSON language files.

First, install the Google Translate package:

Then run:

This translates all untranslated keys (where value equals the key) from the source language to every other configured language.

Options

Option Description
--lang=fr,es Only translate specific target languages
--force Re-translate keys that already have translations
--driver=google_free Override the translation driver from config
--batch-size=50 Number of strings per API call (default: 50)

Placeholder preservation

The command automatically preserves Laravel and Vue placeholders during translation:

These are masked before sending to the API and restored in the translated result.

Case deduplication

Keys that differ only in letter case (e.g. "Hello", "hello", "HELLO") are deduplicated into a single API call. The translated result is then adjusted to match each variant's casing (uppercase, lowercase, title case).

Configuration

Two config keys control auto-translation:

Custom drivers

You can register your own translation driver by binding it in the service container:

Then use it with --driver=my_driver or set 'translation_driver' => 'my_driver' in config.

Typical workflow

  1. Write code using __('key'), $t('key'), etc.
  2. Run php artisan translations:scan to extract all keys
  3. Either:
    • Auto-translate: Run php artisan translations:translate to translate via API
    • Manual workflow: Export → send to translator → import:
      1. php artisan translations:export
      2. Send the file(s) to your translator
      3. php artisan translations:import

Using translations in Vue

Install the vue-i18n package:

Set up vue-i18n in your app.js:

Then use $t() or i18n.t() in your templates:

Testing

License

MIT


All versions of laravel-translator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webo3/laravel-translator contains the following files

Loading the files please wait ...