Users can set their preferred language in their profile:
- English (British) -
en_GB(date format DD/MM/YYYY) - English (American) -
en_US(date format MM/DD/YYYY) - Français -
fr - Deutsch -
de
When new translations are available after a phpIP update, run:
# Normal update - preserves your customizations
php artisan translations:refresh
# Complete reset to "official" translations
php artisan translations:refresh --force-
UI Elements: Add translations to language files in
/lang/:en.jsonfor Englishfr.jsonfor Frenchde.jsonfor German
-
Database Content: Use the admin interface to add/modify translations for:
- Matter categories
- Event names
- Actor roles
- Task rules
- etc.
The admin interface displays and allows editing of database content (like Matter Categories, Event Names, etc.) based on your currently selected user language.
- Viewing: Content is shown in your profile's language. If a translation doesn't exist for your language, it may fall back to a default language (e.g., English).
- Editing/Adding: When you modify or add content through the admin interface, the changes are saved only for the language currently set in your user profile.
To add or edit translations for a different language:
- Go to your user profile settings.
- Change your language to the desired target language (e.g., change from English to French).
- Navigate back to the relevant admin section (e.g., Matter Categories).
- You will now see the content in the newly selected language.
- Make the necessary additions or modifications. These changes will be saved for that specific language.
- Repeat the process for any other languages you need to manage.
The application uses two translation systems:
-
UI Translations
- Menu items, buttons, messages
- Stored in JSON files
- Easy to customize
-
Core Data Translations
- Business data (categories, types, events, etc.)
- Stored in database
- Preserved during updates
| Content Type | Examples |
|---|---|
| Matter Categories | Patent, Trademark, Design |
| Event Names | Filed, Published, Granted |
| Actor Roles | Owner, Agent, Inventor |
| Task Rules | Reminders, Actions |
Technical implementation details (click to expand)
Uses Laravel's built-in localization:
// In PHP files
echo __('Welcome to phpIP');
// In Blade templates
{{ __('Search Results') }}File structure:
/lang/
├── en.json
├── fr.json
└── de.json
Uses JSON columns with spatie/laravel-translatable:
{
"en": "English text",
"fr": "French text",
"de": "German text"
}| Table | Column | Usage |
|---|---|---|
| actor_role | name | Role names |
| classifier_type | type | Classifier types |
| event_name | name | Event names |
| matter_category | category | Matter categories |
| matter_type | type | Matter types |
| task_rules | detail | Task rule details |
- Querying Translated Content:
// Get translation in current locale
$category->category
// Get specific translation
$category->getTranslation('category', 'fr')
// Check if translation exists
$category->hasTranslation('category', 'de')
// Filtering by translation (case sensitive)
$patents = MatterCategory::where('category->en', 'Patent')->get();
$brevets = MatterCategory::where('category->fr', 'Brevet')->get();
// Using raw SQL operator (case sensitive)
$patents = MatterCategory::whereRaw("category->>'$.en' = ?", ['Patent'])->get();
// Case-insensitive matching
$matters = MatterCategory::whereRaw(
"category->>'$.en' COLLATE utf8mb4_0900_ai_ci LIKE ?",
['patent%']
)->get();
// This can be simplified using the whereJsonLike() macro defined in AppServiceProvider (starts with 'patent'):
$matters = MatterCategory::whereJsonLike('category', 'patent')->get();- Adding New Translations:
$category->setTranslation('category', 'en', 'Patent')
->setTranslation('category', 'fr', 'Brevet')
->save();- Direct SQL Updates:
UPDATE table_name
SET column_name = JSON_SET(
COALESCE(column_name, '{}'),
'$.en', 'English text',
'$.fr', 'French text',
'$.de', 'German text'
)
WHERE id = X;- Indexing:
- Functional indexes for each locale
- Collation: utf8mb4_0900_ai_ci
- Format:
idx_table_column_locale
- Fallback Behavior:
- Missing translation → English
- Missing English → null
- Configure in
config/app.php
- Indexes:
- Use functional indexes on specific locales for faster lookups.
- Example query using functional index:
// Using JSON functions (requires specific index) ->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(category, '$.en')) = ?", ['Patent']) // Using Laravel's shorthand (may leverage index depending on DB/version) ->where('category->en', 'Patent')
- Caching:
- Cache frequently accessed translations
- Use Laravel's cache system
- Bulk Operations:
- Use
translations:refreshfor updates - Batch process manual updates