Everything you need to integrate, configure, and master LocalizerX in your Laravel applications. From quick setup to advanced customization.
Navigate through our comprehensive guides and references
Get started quickly with our step-by-step installation guide
Setup and customize LocalizerX for your needs
Complete API endpoint documentation
Code samples and practical implementations
Deep customization and advanced features
Common issues and their solutions
Get LocalizerX up and running in your Laravel application
Latest Laravel framework
Modern PHP version
Database support
For caching performance
Download LocalizerX from CodeCanyon and extract to your Laravel project directory.
# Extract to your Laravel project
unzip localizerx-package.zip
cp -r localizerx/* /path/to/your/laravel-project/
Install required Composer packages.
# Install Composer dependencies
composer install
# Install NPM dependencies for frontend assets
npm install && npm run build
Add LocalizerX configuration to your .env file.
# LocalizerX Configuration
LOCALIZERX_ENABLED=true
LOCALIZERX_DEFAULT_LOCALE=en
LOCALIZERX_FALLBACK_LOCALE=en
# AI Translation Services (Optional)
GOOGLE_TRANSLATE_API_KEY=your_google_api_key
OPENAI_API_KEY=your_openai_api_key
CLAUDE_API_KEY=your_claude_api_key
# Redis Configuration (Optional)
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
Create database tables for LocalizerX.
# Run database migrations
php artisan migrate
# Seed default languages and translations
php artisan localizerx:seed
Publish configuration files and assets.
# Publish configuration
php artisan vendor:publish --tag=localizerx-config
# Publish Filament admin panel resources
php artisan vendor:publish --tag=localizerx-filament
The main configuration file is located at config/localizerx.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Locale
|--------------------------------------------------------------------------
*/
'default_locale' => env('LOCALIZERX_DEFAULT_LOCALE', 'en'),
/*
|--------------------------------------------------------------------------
| Fallback Locale
|--------------------------------------------------------------------------
*/
'fallback_locale' => env('LOCALIZERX_FALLBACK_LOCALE', 'en'),
/*
|--------------------------------------------------------------------------
| Supported Locales
|--------------------------------------------------------------------------
*/
'supported_locales' => [
'en' => 'English',
'es' => 'Spanish',
'fr' => 'French',
'de' => 'German',
'it' => 'Italian',
'pt' => 'Portuguese',
'ru' => 'Russian',
'ja' => 'Japanese',
'ko' => 'Korean',
'zh' => 'Chinese',
'ar' => 'Arabic',
],
/*
|--------------------------------------------------------------------------
| AI Translation Services
|--------------------------------------------------------------------------
*/
'ai_translation' => [
'enabled' => env('LOCALIZERX_AI_ENABLED', true),
'default_provider' => env('LOCALIZERX_AI_PROVIDER', 'google'),
'providers' => [
'google' => [
'api_key' => env('GOOGLE_TRANSLATE_API_KEY'),
'endpoint' => 'https://translation.googleapis.com/language/translate/v2',
],
'openai' => [
'api_key' => env('OPENAI_API_KEY'),
'model' => 'gpt-3.5-turbo',
],
'claude' => [
'api_key' => env('CLAUDE_API_KEY'),
'model' => 'claude-3-sonnet',
],
],
],
/*
|--------------------------------------------------------------------------
| Caching Configuration
|--------------------------------------------------------------------------
*/
'cache' => [
'enabled' => env('LOCALIZERX_CACHE_ENABLED', true),
'ttl' => env('LOCALIZERX_CACHE_TTL', 3600), // 1 hour
'prefix' => 'localizerx',
],
/*
|--------------------------------------------------------------------------
| API Configuration
|--------------------------------------------------------------------------
*/
'api' => [
'enabled' => env('LOCALIZERX_API_ENABLED', true),
'rate_limit' => env('LOCALIZERX_API_RATE_LIMIT', 1000), // requests per hour
'authentication' => env('LOCALIZERX_API_AUTH', 'jwt'),
],
];
Register LocalizerX middleware in your app/Http/Kernel.php
protected $middleware = [
// Other middleware...
\LocalizerX\Middleware\SetLocale::class,
];
protected $routeMiddleware = [
// Other middleware...
'localized' => \LocalizerX\Middleware\LocalizedRoutes::class,
'translate' => \LocalizerX\Middleware\AutoTranslate::class,
];
The service provider is auto-registered via package discovery, but you can manually add it:
// config/app.php
'providers' => [
// Other providers...
LocalizerX\LocalizerXServiceProvider::class,
],
All API requests require authentication via JWT token or API key.
/api/auth/login
Authenticate and receive JWT token
{
"email": "admin@example.com",
"password": "password"
}
Response:
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"token_type": "bearer",
"expires_in": 3600
}
/api/languages
Get all supported languages
{
"data": [
{
"id": 1,
"code": "en",
"name": "English",
"native_name": "English",
"is_default": true,
"is_active": true,
"created_at": "2024-01-01T00:00:00.000000Z"
}
],
"meta": {
"total": 11,
"per_page": 15,
"current_page": 1
}
}
/api/languages
Create new language
{
"code": "pt",
"name": "Portuguese",
"native_name": "Português",
"is_active": true
}
/api/translations
Get translations with filtering options
Query Parameters:
locale - Filter by language codenamespace - Filter by namespacesearch - Search in keys and valuespage - Pagination pageper_page - Items per page (max 100)/api/translations
Create or update translation
{
"key": "welcome.title",
"namespace": "frontend",
"translations": {
"en": "Welcome to our platform",
"es": "Bienvenido a nuestra plataforma",
"fr": "Bienvenue sur notre plateforme"
}
}
/api/translations/auto-translate
Auto-translate text using AI services
{
"text": "Hello, welcome to our platform",
"source_locale": "en",
"target_locales": ["es", "fr", "de"],
"provider": "google"
}
Response:
{
"translations": {
"es": "Hola, bienvenido a nuestra plataforma",
"fr": "Bonjour, bienvenue sur notre plateforme",
"de": "Hallo, willkommen auf unserer Plattform"
},
"provider": "google",
"confidence": 0.95
}
/api/translations/import
Import translations from JSON or CSV file
curl -X POST \
'https://yourapp.com/api/translations/import' \
-H 'Authorization: Bearer {token}' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@translations.json' \
-F 'format=json' \
-F 'namespace=frontend'
/api/translations/export
Export translations to JSON or CSV format
Query Parameters:
format - json|csv (required)locales - Comma-separated language codesnamespace - Filter by namespace
welcome.title
welcome.greeting
{{ localize('navigation.home') }}
{{ localize('admin.dashboard.title', [], 'admin') }}
<?php
namespace App\Http\Controllers;
use LocalizerX\Facades\LocalizerX;
class HomeController extends Controller
{
public function index()
{
// Get translation for current locale
$title = LocalizerX::get('welcome.title');
// Get translation for specific locale
$titleEs = LocalizerX::get('welcome.title', [], 'es');
// Get all translations for a key
$allTranslations = LocalizerX::getAll('welcome.title');
// Set translation programmatically
LocalizerX::set('dynamic.message', 'This is dynamic content');
return view('home', compact('title', 'titleEs', 'allTranslations'));
}
public function switchLanguage($locale)
{
LocalizerX::setLocale($locale);
session(['locale' => $locale]);
return redirect()->back();
}
}
// Install the LocalizerX Vue plugin
import { createApp } from 'vue'
import LocalizerX from '@/plugins/localizerx'
const app = createApp({})
app.use(LocalizerX)
// Usage in Vue components
export default {
mounted() {
// Get current locale
console.log(this.$locale.current)
// Get available locales
console.log(this.$locale.available)
// Switch locale
this.$locale.switch('es')
},
template: `
{{ $t('welcome.description') }}
@{ $t('user.greeting', { name: user.name }) }}
`
}
import React, { useContext } from 'react'
import { LocalizerXProvider, useLocalizerX } from '@/context/LocalizerXContext'
// Provider setup
function App() {
return (
)
}
// Component usage
function HomePage() {
const { t, locale, setLocale, availableLocales } = useLocalizerX()
return (
{t('welcome.title')}
{t('welcome.description')}
{/* With parameters */}
{t('user.greeting', { name: 'John' })}
{/* Language switcher */}
)
}
// Custom hook
export function useLocalizerX() {
const context = useContext(LocalizerXContext)
if (!context) {
throw new Error('useLocalizerX must be used within LocalizerXProvider')
}
return context
}
# Scan and extract translatable strings from your codebase
php artisan localizerx:scan
# Auto-translate missing translations using AI
php artisan localizerx:translate --locale=es --provider=google
# Import translations from file
php artisan localizerx:import translations.json --namespace=frontend
# Export translations to file
php artisan localizerx:export --format=json --locale=en,es
# Clear translation cache
php artisan localizerx:cache:clear
# Generate translation keys for specific namespace
php artisan localizerx:generate-keys --namespace=admin
# Validate translation files for missing keys
php artisan localizerx:validate
Create custom AI translation providers for specific needs.
<?php
namespace App\Providers;
use LocalizerX\Contracts\TranslationProvider;
use LocalizerX\Exceptions\TranslationException;
class CustomTranslationProvider implements TranslationProvider
{
public function translate(string $text, string $fromLocale, string $toLocale): string
{
// Your custom translation logic
$result = $this->callCustomAPI($text, $fromLocale, $toLocale);
if (!$result) {
throw new TranslationException("Translation failed for: {$text}");
}
return $result;
}
public function translateBatch(array $texts, string $fromLocale, string $toLocale): array
{
// Batch translation implementation
return array_map(function($text) use ($fromLocale, $toLocale) {
return $this->translate($text, $fromLocale, $toLocale);
}, $texts);
}
private function callCustomAPI(string $text, string $from, string $to): ?string
{
// Implementation specific to your translation service
}
}
// Register in service provider
LocalizerX::addProvider('custom', new CustomTranslationProvider());
Implement custom storage for translations (e.g., MongoDB, Elasticsearch).
<?php
namespace App\Storage;
use LocalizerX\Contracts\TranslationStorage;
class MongoTranslationStorage implements TranslationStorage
{
public function get(string $key, string $locale, string $namespace = 'default'): ?string
{
return $this->collection()
->where('key', $key)
->where('locale', $locale)
->where('namespace', $namespace)
->value('value');
}
public function set(string $key, string $value, string $locale, string $namespace = 'default'): bool
{
return $this->collection()->updateOrInsert([
'key' => $key,
'locale' => $locale,
'namespace' => $namespace,
], [
'value' => $value,
'updated_at' => now(),
]);
}
public function getAll(string $locale, string $namespace = 'default'): array
{
return $this->collection()
->where('locale', $locale)
->where('namespace', $namespace)
->pluck('value', 'key')
->toArray();
}
private function collection()
{
return app('mongodb')->collection('translations');
}
}
Listen to LocalizerX events for custom functionality.
<?php
namespace App\Listeners;
use LocalizerX\Events\TranslationCreated;
use LocalizerX\Events\TranslationUpdated;
use LocalizerX\Events\LocaleChanged;
class TranslationEventListener
{
public function handleTranslationCreated(TranslationCreated $event)
{
// Log new translation
logger()->info('New translation created', [
'key' => $event->key,
'locale' => $event->locale,
'namespace' => $event->namespace,
]);
// Clear related caches
$this->clearCache($event->namespace);
// Send notification to translators
$this->notifyTranslators($event);
}
public function handleTranslationUpdated(TranslationUpdated $event)
{
// Track changes for audit
$this->auditChange($event);
// Invalidate frontend cache
$this->invalidateFrontendCache($event->key);
}
public function handleLocaleChanged(LocaleChanged $event)
{
// Track user locale preferences
if ($event->user) {
$event->user->update(['preferred_locale' => $event->newLocale]);
}
// Load locale-specific resources
$this->loadLocaleResources($event->newLocale);
}
}
Advanced caching and performance strategies.
<?php
// Pre-warm cache for critical translations
Artisan::command('localizerx:warm-cache', function () {
$criticalKeys = [
'navigation.*',
'auth.*',
'errors.*',
'common.*',
];
$locales = config('localizerx.supported_locales');
foreach ($locales as $locale => $name) {
foreach ($criticalKeys as $pattern) {
LocalizerX::warmCache($pattern, $locale);
}
}
$this->info('Translation cache warmed successfully');
});
// Custom cache tags for granular invalidation
LocalizerX::cacheUsing(function($key, $locale, $namespace) {
return cache()->tags([
"translations:{$namespace}",
"translations:{$locale}",
"translations:{$namespace}:{$locale}"
])->remember("translation:{$key}:{$locale}:{$namespace}", 3600, function() use ($key, $locale, $namespace) {
return LocalizerX::getFromStorage($key, $locale, $namespace);
});
});
// Lazy loading for frontend
LocalizerX::lazyLoad([
'common.*',
'navigation.*'
], function($translations) {
return response()->json($translations);
});
Possible causes:
Solutions:
# Clear all caches
php artisan cache:clear
php artisan config:clear
php artisan localizerx:cache:clear
# Check current locale
php artisan tinker
>>> app()->getLocale()
>>> LocalizerX::getCurrentLocale()
# Verify translation exists
>>> LocalizerX::get('your.translation.key')
Check API credentials:
# Verify environment variables
php artisan tinker
>>> config('localizerx.ai_translation.providers.google.api_key')
>>> config('localizerx.ai_translation.providers.openai.api_key')
# Test API connection
php artisan localizerx:test-translation --provider=google
Enable caching and optimize:
# Enable Redis caching
LOCALIZERX_CACHE_ENABLED=true
CACHE_DRIVER=redis
# Pre-warm cache for critical translations
php artisan localizerx:warm-cache
# Monitor cache hit ratio
php artisan localizerx:cache:stats
File format validation:
# Validate file before import
php artisan localizerx:validate-file translations.json
# Check file permissions
ls -la storage/app/translations/
# Use verbose mode for detailed error messages
php artisan localizerx:import translations.json --verbose
Enable debug mode for detailed logging and error reporting.
# Enable debug mode
LOCALIZERX_DEBUG=true
LOG_LEVEL=debug
# View logs
tail -f storage/logs/laravel.log | grep localizerx
# Debug specific translation key
php artisan localizerx:debug welcome.title --locale=es
Run comprehensive health check to identify issues.
# Run full health check
php artisan localizerx:health-check
# Check specific components
php artisan localizerx:health-check --component=database
php artisan localizerx:health-check --component=cache
php artisan localizerx:health-check --component=ai-providers