Code Integration

This section will guide you through the steps required to integrate the addon into your Pterodactyl panel by editing specific files.

Each step includes:

  • The file you need to open

  • The exact line or code block to search for.

  • The code you need to add or replace.

First, navigate to the directory where your Pterodactyl panel is installed.

By default, this is usually located at:

/var/www/pterodactyl

1. Open the file: resources/scripts/components/App.tsx

Locate this line:

import Spinner from '@/components/elements/Spinner';

And add this directly below:

import i18n from '@/i18n';

Search for:

        store.getActions().user.setUserData({
            uuid: PterodactylUser.uuid,
            username: PterodactylUser.username,
            email: PterodactylUser.email,
            language: PterodactylUser.language,
            rootAdmin: PterodactylUser.root_admin,
            useTotp: PterodactylUser.use_totp,
            createdAt: new Date(PterodactylUser.created_at),
            updatedAt: new Date(PterodactylUser.updated_at),
        });

Bellow of this block of code add:

        if (PterodactylUser.language) {
            i18n.changeLanguage(PterodactylUser.language);
        }

Example:

2. Open the file: resources/scripts/components/NavigationBar.tsx

Locate this line:

import Avatar from '@/components/Avatar';

And add this directly below:

import LanguageSelector from '@/components/dashboard/LanguageSelector';

Search for this block of code:

                    <Tooltip placement={'bottom'} content={'Account Settings'}>
                        <NavLink to={'/account'}>
                            <span className={'flex items-center w-5 h-5'}>
                                <Avatar.User />
                            </span>
                        </NavLink>
                    </Tooltip>

Right below it, add:

                    <div className='px-4'>
                        <LanguageSelector />
                    </div>

3. Open the file: /var/www/pterodactyl/routes/api-client.php

Search for this block of code:

    Route::prefix('/ssh-keys')->group(function () {
        Route::get('/', [Client\SSHKeyController::class, 'index']);
        Route::post('/', [Client\SSHKeyController::class, 'store']);
        Route::post('/remove', [Client\SSHKeyController::class, 'delete']);
    });

Right below it, add:

    Route::post('/language/save', [LanguageController::class, 'update']);

4. Open the file: /var/www/pterodactyl/app/Providers/RouteServiceProvider.php

Search for this block of code:

            Route::middleware(['api', RequireTwoFactorAuthentication::class])->group(function () {
                Route::middleware(['application-api', 'throttle:api.application'])
                    ->prefix('/api/application')
                    ->scopeBindings()
                    ->group(base_path('routes/api-application.php'));

                Route::middleware(['client-api', 'throttle:api.client'])
                    ->prefix('/api/client')
                    ->scopeBindings()
                    ->group(base_path('routes/api-client.php'));
            });

Right below it, add:

            Route::middleware('guest')->prefix('/api/public')->group(base_path('routes/api-public.php'));

5. Go to: /var/www/pterodactyl/routes and create the file api-public.php

Inside this fill add this code:

<?php

use Illuminate\Support\Facades\Route;
use Pterodactyl\Http\Controllers\User\LanguageController;

Route::get('/locales/list', [LanguageController::class, 'index']);

And that's it for the integration!

You've now integrated the addon into your Pterodactyl panel by editing the required files.

Last updated