Back to overview

Adding a New Language

Developer Tutorials Published on 01.11.2025

Tutorial: Adding a New Language

This guide explains how to add a new language (localization) to the application. The system is designed to be easily extensible. By following these steps, you can add any language and make it available to your users.

Step 1: Add the Flag Icon

Flag icons are used for visual representation in the language switcher. The application looks for them in a specific folder.

Flag Icon Details
  • Directory: Place the new flag icon in the media/flags/ directory.
  • File Name: The file must be named after the two-letter language code (ISO 639-1). For Spanish, the file name should be es.svg.
  • Format: SVG is the recommended format for flags as it scales perfectly without losing quality.

Example: To add a flag for Spain, you would add the file media/flags/es.svg.

Step 2: Create the Language File

The language file contains all the translated strings (UI text) for the application. The easiest way to create a new one is to copy an existing file.

Creating the PHP Language File
  1. Navigate to the languages/ directory.
  2. Copy the existing en.php file.
  3. Rename the copied file to match the new language code. For Spanish, this would be es.php.
  4. Open the new es.php file and start translating the values.

Example: languages/es.php

<?php
// Spanish language file

return [
    // General
    'my_website' => 'INtex Proyecto X',
    'learn_more' => 'Aprende más',
    'copyright' => '© %s INtex Publishing. Todos los derechos reservados.',
    
    // This key is very important! It's the name shown in the dropdown.
    'language_native_name' => 'Español',

    // Sidebar Menu (menu.php)
    'menu_home' => 'Inicio',
    'menu_contact' => 'Contacto',

    // ... translate all other keys ...
];
Crucial Key: The key 'language_native_name' is mandatory. Its value is the name of the language as it will appear in the selection dropdown (e.g., "Español", "Français", "Deutsch").

Step 3: Add the Language to the User Profile Dropdown

Finally, you need to tell the application that the new language is available. This is done by adding it to the language array in the user profile page.

Editing userprofile.php

Open the file userprofile.php and find the section where the languages are defined. Add your new language code to the $available_languages array.

<?php
// ... other code in userprofile.php ...

// Define available languages
$available_languages = ['de', 'en']; // Original

// --- Add your new language code here ---
$available_languages = ['de', 'en', 'es']; // Modified

// ... rest of the code ...
?>

Once you save this change, "Español" (or whatever you defined in language_native_name) will automatically appear as an option in the "Preferred Language" dropdown in every user's profile.