![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/private_html/ |
# Translation System Documentation
## Overview
The SoundStudioPro website now supports bilingual content in **English** and **French**. The translation system is fully functional and ready to use.
## How It Works
### 1. Translation Files
- **English**: `/lang/en.php` - Base language file
- **French**: `/lang/fr.php` - French translations
- Both files use the same key structure for consistency
### 2. Translation Function
The main function to use is `t('key')` which returns the translated string based on the current language.
**Usage:**
```php
<?= t('nav.home') ?> // Returns "Home" or "Accueil"
<?= t('user.login') ?> // Returns "Login" or "Connexion"
<?= t('btn.save') ?> // Returns "Save" or "Enregistrer"
```
**With Parameters:**
```php
<?= t('time.minutes_ago', ['count' => 5]) ?> // Returns "5 minutes ago" or "Il y a 5 minutes"
```
### 3. Language Detection
The system automatically detects the user's language preference in this order:
1. Session preference (if user switched language)
2. URL parameter (`?lang=en` or `?lang=fr`)
3. Browser's Accept-Language header
4. Defaults to English
### 4. Language Switcher
A language switcher has been added to the header (both logged-in and logged-out views). Users can click the globe icon to switch between English and French.
## What's Already Translated
### Navigation & Menus
- Home, Dashboard, Create, Library, Artists, Community
- User menu items (Profile, Settings, Logout, etc.)
- Dropdown menus (Creator Hub, Social & Discovery, My Collection)
- Mobile menu items
### Homepage
- Hero section (title, subtitle, badges)
- Call-to-action buttons
- Login required messages
### Common Elements
- Buttons (Save, Cancel, Submit, Delete, etc.)
- Messages (Success, Error, Loading)
- Form labels
- Time/date formats
- Ratings
## How to Add More Translations
### Step 1: Add Translation Keys
Add new keys to both `/lang/en.php` and `/lang/fr.php`:
**English (`/lang/en.php`):**
```php
'new.key' => 'English Text',
```
**French (`/lang/fr.php`):**
```php
'new.key' => 'Texte français',
```
### Step 2: Use in Code
Replace hardcoded strings with translation calls:
**Before:**
```php
<h1>Welcome to SoundStudioPro</h1>
```
**After:**
```php
<h1><?= t('welcome.title') ?></h1>
```
### Step 3: Organize Keys
Use dot notation to organize keys:
- `nav.*` - Navigation items
- `user.*` - User-related text
- `btn.*` - Buttons
- `msg.*` - Messages
- `form.*` - Form labels
- `home.*` - Homepage content
- `create.*` - Music creation
- `common.*` - Common elements
## Files Modified
1. **`/includes/translations.php`** - Core translation system
2. **`/lang/en.php`** - English translations
3. **`/lang/fr.php`** - French translations
4. **`/lang_switch.php`** - Language switcher handler
5. **`/includes/header.php`** - Updated with translations and language switcher
6. **`/index.php`** - Updated homepage with translations
## Language Switcher UI
The language switcher appears in the header as a globe icon with the current language code (EN/FR). On hover, it shows a dropdown with available languages.
**Mobile:** The language code text is hidden on small screens, showing only the globe icon.
## Session Management
Language preference is stored in the session (`$_SESSION['language']`), so it persists across page loads until the user switches again or the session expires.
## SEO Considerations
The `<html lang="">` attribute is automatically set based on the current language, which helps search engines understand the page language.
## Future Enhancements
Potential improvements:
- Add more languages (Spanish, German, etc.)
- Database-driven translations for dynamic content
- URL-based language routing (`/en/` and `/fr/` paths)
- Admin panel for managing translations
- Translation memory for consistency
## Testing
To test the translation system:
1. Visit any page on the site
2. Click the language switcher (globe icon) in the header
3. Select a language
4. Verify that text changes throughout the page
5. Navigate to other pages to confirm language persists
## Notes
- User-generated content (track titles, comments, etc.) is not automatically translated
- Some dynamic content may need special handling
- Meta tags and SEO descriptions can be translated by using the translation function in page-specific variables