PHP 8.2.30
Preview: TranslateController.php Size: 1.77 KB
/home/byroehnu/cnggold.com.ng/app/Http/Controllers/Admin/TranslateController.php

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Setting;
use App\Repositories\Admin\TranslateRepository;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;

class TranslateController extends Controller
{

    public function __construct()
    {
        // for demo mood
        $this->middleware('demo', ['only' => ['update', 'auto']]);
    }

    /**
     * Display a listing of the languages.
     */
    public function index(): Response
    {
        $data['languages'] = json_decode(Setting::pull('languages'), true);
        $data['default_lang'] = Setting::pull('default_lang');

        return Inertia::render('Settings/Translate/Index', $data);
    }

    /**
     * Show the form for edit a new resource.
     */
    public function show($language): Response
    {
        $file = base_path('lang/' . $language . '.json');
        $post = file_get_contents($file);
        $data['posts'] = json_decode($post);
        $data['language'] = $language;

        return Inertia::render('Settings/Translate/Show', $data);
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, $language, TranslateRepository $repository): RedirectResponse
    {
        $repository->updateLangData($request, $language);

        return redirect()->route('admin.translations.index')->with('success', 'Language file successfully translated!');
    }

    public function auto(Request $request, $language, TranslateRepository $repository)
    {
        try {
            $data = $repository->autoTranslateFromFile('en', $language, $request->key);

            return response()->json(['translated' => $data]);
        } catch (\Exception) {
        }
    }
}

Directory Contents

Dirs: 0 × Files: 41

Name Size Perms Modified Actions
1.15 KB lrw-r--r-- 2025-05-04 10:56:26
Edit Download
3.29 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
3.88 KB lrw-r--r-- 2025-05-22 03:36:31
Edit Download
5.76 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
3.97 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.95 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.91 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
3.00 KB lrw-r--r-- 2025-05-08 11:48:26
Edit Download
2.07 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.09 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
411 B lrw-r--r-- 2025-04-08 04:12:56
Edit Download
1.66 KB lrw-r--r-- 2025-05-05 10:37:43
Edit Download
2.75 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
3.26 KB lrw-r--r-- 2025-05-15 12:02:59
Edit Download
4.47 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.89 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
4.12 KB lrw-r--r-- 2025-05-08 11:48:26
Edit Download
5.74 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
169 B lrw-r--r-- 2025-04-19 04:22:19
Edit Download
1.01 KB lrw-r--r-- 2025-04-19 04:22:19
Edit Download
3.83 KB lrw-r--r-- 2025-05-22 03:36:31
Edit Download
5.83 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
5.19 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
3.20 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
3.59 KB lrw-r--r-- 2025-05-22 13:45:40
Edit Download
3.65 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
2.54 KB lrw-r--r-- 2025-05-08 11:48:26
Edit Download
1.18 KB lrw-r--r-- 2025-05-08 11:48:26
Edit Download
2.79 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
459 B lrw-r--r-- 2025-04-19 04:22:18
Edit Download
3.74 KB lrw-r--r-- 2025-05-22 03:36:31
Edit Download
5.86 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
5.50 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.78 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.77 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
5.11 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
2.98 KB lrw-r--r-- 2025-04-19 04:22:19
Edit Download
847 B lrw-r--r-- 2025-04-08 04:12:56
Edit Download
2.32 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.77 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
2.63 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).