- Added standard Laravel directory structure and configuration. - Included Svelte and Tailwind configuration for the admin interface. - Added core PHPUnit and testing scripts.
61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Translations;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Translation;
|
|
use App\Services\TranslationManager;
|
|
use App\Services\SettingService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class TranslationController extends Controller
|
|
{
|
|
/**
|
|
* Display the translations management UI.
|
|
*/
|
|
public function index(Request $request, SettingService $settingService)
|
|
{
|
|
$locale = $request->query('locale', $settingService->get('default_locale', config('app.locale')));
|
|
|
|
// Fetch all translations for the given locale
|
|
$overrides = Translation::where('locale', $locale)->get();
|
|
|
|
return view('admin.translations.index', [
|
|
'locale' => $locale,
|
|
'overrides' => $overrides,
|
|
'availableLocales' => $settingService->getSupportedLocales(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Update or create a translation override.
|
|
*/
|
|
public function update(Request $request, TranslationManager $manager)
|
|
{
|
|
$validated = $request->validate([
|
|
'locale' => 'required|string',
|
|
'group' => 'required|string',
|
|
'key' => 'required|string',
|
|
'value' => 'required|string',
|
|
]);
|
|
|
|
$manager->updateOverride(
|
|
$validated['locale'],
|
|
$validated['group'],
|
|
$validated['key'],
|
|
$validated['value']
|
|
);
|
|
|
|
return response()->json(['success' => true]);
|
|
}
|
|
|
|
/**
|
|
* Sync translations from files (placeholder for future implementation).
|
|
*/
|
|
public function sync()
|
|
{
|
|
// This would scan lang files and ensure keys are available for override
|
|
return response()->json(['message' => 'Sync not yet implemented. Use manual entry for now.']);
|
|
}
|
|
}
|