Download the PHP package kargnas/laravel-ai-translator without Composer

On this page you can find all versions of the php package kargnas/laravel-ai-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-ai-translator

Laravel AI Translator by kargnas

AI-powered translation tool for Laravel language files

Build Status Total Downloads Latest Stable Version License

Official Website

๐Ÿ”„ Recent Updates

Overview

Laravel AI Translator is a powerful tool designed to streamline the localization process in Laravel projects. It automates the tedious task of translating strings across multiple languages, leveraging advanced AI models to provide high-quality, context-aware translations.

Key benefits:

Whether you're working on a personal project or a large-scale application, Laravel AI Translator simplifies the internationalization process, allowing you to focus on building great features instead of wrestling with translations.

Key Features

Also, this tool is designed to translate your language files intelligently:

Do you want to know how this works? See the prompt in src/AI.

Custom Language Styles

In addition to standard language translations, this package now supports custom language styles, allowing for unique and creative localizations.

Built-in Styles

The package includes several built-in language styles:

These are automatically available and don't require additional configuration.

Custom Style Example: Reddit English

As an demonstration of custom styling capabilities, we've implemented a "Reddit style" English:

This style mimics the casual, often humorous language found on Reddit, featuring:

Example configuration:

Creating Custom Styles

You can create your own custom language styles by adding new entries to the locale_names and additional_rules in the configuration. This allows you to tailor translations to specific audiences or platforms.

These custom styles offer creative ways to customize your translations, adding a unique flair to your localized content. Use responsibly to enhance user engagement while maintaining clarity and appropriateness for your audience.

Prerequisites

Installation

  1. Install the package via composer:

  2. Add the Claude API key to your .env file:

    You can obtain an API key from the Anthropic Console.

(If you want to use OpenAI's GPT or Google's Gemini instead, see step 4 below for configuration instructions.)

  1. (Optional) Publish the configuration file:

    This step is optional but recommended if you want to customize the package's behavior. It will create a config/ai-translator.php file where you can modify various settings.

  2. (Optional) The package is configured to use Claude by default. If you want to use OpenAI's GPT or Google's Gemini instead, update the config/ai-translator.php file:

    For OpenAI GPT:

    Or for Gemini:

    Then, add the OpenAI or Gemini API key to your .env file:

    You can obtain API keys from:

    We strongly recommend using Claude for the best translation quality and accuracy.

  3. You're now ready to use the Laravel AI Translator!

Usage

To translate your language files, run the following command:

To speed up translating multiple locales, you can run them in parallel:

Specify target locales separated by commas using the --locale option. For example:

If you omit the --locale option, the command automatically translates all available locales.

This command will:

  1. Recognize all language folders in your lang directory
  2. Use AI to translate the contents of the string files in the source language, English. (You can change the source language in the config file)

Finding and Removing Unused Translations

To find translation keys that are no longer used in your codebase:

This command scans your source code to identify unused translation keys and optionally removes them.

Features

Options

Examples

The command automatically:

Cleaning Translations

To remove translated strings and prepare for re-translation, use the clean command:

This command removes translations from locale files while preserving your source language, allowing you to regenerate translations with updated AI models or rules.

Arguments

Options

Examples

The command automatically:

Example

Given an English language file:

The package will generate translations like these:

Configuration

If you want to customize the settings, you can publish the configuration file:

This will create a config/ai-translator.php file where you can modify the following settings:

Example configuration:

Make sure to set your chosen AI provider's API key in your .env file.

Supported File Types

This package supports both PHP and JSON language files used by Laravel:

PHP Language Files

These commands translate PHP language files located in subdirectories like lang/en/, lang/ko/, etc.

JSON Language Files

This command translates root-level JSON language files like lang/en.json, lang/ko.json, etc.

All translation commands support the same powerful features:

Command Options

All translation commands support these options:

File Structure Examples

PHP Files:

JSON Files:

Why Support Both Formats?

PHP Files Benefits:

JSON Files Benefits:

Choose the format that best fits your project's needs - this package handles both seamlessly!

TODO List

We're constantly working to improve Laravel AI Translator. Here are some features and improvements we're planning:

If you'd like to contribute to any of these tasks, please feel free to submit a pull request!

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Credits

Read my articles about language


All versions of laravel-ai-translator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
crowdin/crowdin-api-client Version ^1.14
google-gemini-php/client Version ^1.0|^2.0
guzzlehttp/guzzle Version ^6.0|^7.0
guzzlehttp/promises Version ^1.0|^2.0
illuminate/support Version >=8.0
openai-php/client Version >=0.2 <1.0
symfony/process Version ^5.0|^6.0|^7.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 kargnas/laravel-ai-translator contains the following files

Loading the files please wait ....