[Feature Request] Make "Property" terminology dynamic using sprintf placeholders for multi-accommodation flexibility (Hotels, Villas, Gites, Apartments)
Recently, the core translation strings were updated from 'Hotel Name' to 'Property Name'. While this is a great step forward to make QloApps more generic and inclusive for non-hotel accommodations, it remains rigid for end-users. Currently, a user running a pure Hotel website is forced to see "Property" everywhere, while a user running a Gite or a Villa website is also stuck with "Property". Hardcoding 'Property' inside $this->l() translation strings restricts the user experience.
We should introduce a global configuration setting in the back office (e.g., QLO_PROPERTY_TYPE) allowing the administrator to choose their accommodation type from a dropdown:
- Hotel
- Apartment
- Gite
- Villa
- Property (Default)
To avoid breaking the PrestaShop/QloApps translation scanner, we should not inject variables directly inside $this->l(). Instead, we can refactor the hardcoded "Property" strings by replacing them with a %s placeholder combined with sprintf.
Example
Instead of hardcoding strings like this:
$this->l('Property Amenity Image Required.'); $this->l('Please enter a valid Property Name.');
We can fetch the dynamically translated accommodation type and inject it cleanly:
// 1. Fetch the user-defined configuration type (e.g., 'hotel', 'villa', 'gite')
$propertyConfiguration = Configuration::get('QLO_PROPERTY_TYPE');
// 2. Get the translated singular noun
$propertyType = $this->l(ucfirst($propertyConfiguration));
// 3. Output the dynamic strings using sprintf placeholders
$msg1 = sprintf($this->l('%s Amenity Image Required.'), $propertyType);
$msg2 = sprintf($this->l('Please enter a valid %s Name.'), $propertyType);Short versions and other approaches
$msg1 = sprintf($this->l('%s Amenity Image Required.'), $this->l(ucfirst(Configuration::get('QLO_PROPERTY_TYPE')))); or
define('_QLO_PROPERTY_TYPE_', Configuration::get('QLO_PROPERTY_TYPE'));
$msg1 = sprintf($this->l('%s Amenity Image Required.'), $this->l(ucfirst(_QLO_PROPERTY_TYPE_)));or
public static function getPropType() {
return $this->l(ucfirst(Configuration::get('QLO_PROPERTY_TYPE')));
}
$msg1 = sprintf($this->l('%s Amenity Image Required.'), Translation::getPropType());
// in tpl
{l s='%s Amenity Image Required.' sprintf=[$property_type] }Why this is the best approach:
- Translation Scanner Friendly: The literal string '%s Amenity Image Required.' remains static. The QloApps/PrestaShop translation tool will parse it perfectly, allowing translators to place the %s wherever it makes grammatical sense in their target language.
- True White-Label Flexibility: It allows QloApps to instantly transform its entire UI vocabulary to match exactly what the administrator is renting out (a hotel network, a collection of villas, or local gites).
Thank you for considering this enhancement to make QloApps even more adaptable for the hospitality industry!
Source: Qloapps/QloApps