RedM documentation
Murphy's Craft
Advanced Usage
Translation System
Overview
Murphy Craft now includes a complete translation system for the user interface, supporting both French and English languages with easy extension for additional languages.
Features
- Automatic Language Detection: The UI automatically receives the language setting from the server configuration
- Fallback System: If translations are missing, the system falls back to English or the original text
- Dynamic Updates: Language can be changed without restarting the interface
- Extensible: Easy to add new languages and translation keys
Configuration
Server-Side Configuration
The language is set in shared/config.lua:
This setting is automatically sent to the UI when players open the crafting interface.
Client-Side Translation Files
The translations are stored in ui/translations.js:
Usage
Automatic Translation
Elements with the data-translate attribute are automatically translated:
JavaScript Translation
Use the global T object to get translations in JavaScript:
Available Functions
T.setLanguage(language)
Change the current language:
T.t(key, params)
Get translated text:
T.getCurrentLanguage()
Get current language code:
T.updateUI()
Manually update all translated elements:
T.formatTime(seconds)
Format time duration:
Available Translation Keys
Main Navigation
craft- Craft buttonspecialisation- Specialisation buttonrecipes- Recipes titlecategories- Categories title
Buttons & Actions
close- Close buttoncraft_item- Craft buttonunlock- Unlock buttonunlock_recipe- Unlock recipe buttonreset- Reset buttonconfirm- Confirm buttoncancel- Cancel buttonretrieve- Retrieve button
Crafting Interface
available_items- Available itemsrequired_resources- Required resourcescrafting_time- Crafting timequantity- Quantityduration- Durationamount- Amountitem_description- Item descriptioninsufficient_resources- Insufficient resources messagecrafting_in_progress- Crafting in progress messagecraft_completed- Craft completed message
Specialisation Interface
specialisation_points- Specialisation pointsavailable_points- Available pointsspecialisation_tree- Specialisation treelevel- Levelexperience- Experienceprogress- Progress
Time Units
second/seconds- Time unitsminute/minutes- Time unitshour/hours- Time units
Status Messages
loading- Loading messageerror- Error messagesuccess- Success messagewarning- Warning message
Adding New Languages
- Add translations to
ui/translations.js:
- Update the language detection:
- Update server configuration:
Technical Implementation
File Structure
Integration Points
- HTML Elements: Use
data-translateattributes - JavaScript Functions: Use
T.t()for dynamic content - Server Communication: Language sent via NUI messages
- Automatic Updates: DOM is updated when language changes
Performance Notes
- Translations are cached in memory
- DOM updates are batched for efficiency
- Fallback system prevents missing text errors
- Lightweight implementation with minimal overhead
Best Practices
- Always use translation keys instead of hardcoded text
- Keep keys descriptive and organized by feature
- Test both languages to ensure proper functionality
- Use fallbacks for missing translations
- Update both language files when adding new features
Migration Guide
For Existing HTML
Replace hardcoded text with data-translate attributes:
Before:
After:
For Existing JavaScript
Replace hardcoded strings with translation calls:
Before:
After:
Last updated: September 9, 2026