### GET /languages Source: https://developers.dcsplus.net/trip/doc/translation Retrieves a list of available languages that can be added and managed within the TRIP system. This endpoint is crucial for understanding the language support of the CMS. ```APIDOC ## GET /languages ### Description Retrieves a list of all languages supported and configurable within the TRIP CMS. This allows for managing multi-language content effectively. ### Method GET ### Endpoint /languages ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **languages** (array) - A list of language objects, each containing details like language code, name, and RTL support. #### Response Example ```json { "languages": [ { "code": "en-US", "name": "English (US)", "rtl": false }, { "code": "ar-SA", "name": "Arabic (Saudi Arabia)", "rtl": true } ] } ``` ``` -------------------------------- ### Configure Multiple Currencies and Exchange Rates Source: https://developers.dcsplus.net/trip/doc/cms-config This section details how to set up and manage multiple currencies within the project. It explains how to define active currencies, set a default currency, and access currency data through global variables. It also covers the process of fetching live exchange rates using a dedicated helper function. ```javascript ____globals.project.currency.list__ ____globals.project.currency.display__ ____app.exchange.getExchangeRate(from, to) ____globals.project.currency.provider__ __globals.project.currency.list __app.exchange.getExchangeRate __app.exchange.rate __globals __globals.activeCurrency ``` -------------------------------- ### Manage Pre-rendering Data with Custom Init Event Source: https://developers.dcsplus.net/trip/doc/cms-config This snippet explains how to ensure necessary data is available before rendering page content. It describes the use of the 'Custom init event' property (`__globals.project.customInitProp`) to block automatic rendering and manually control the rendering process after data is fetched. It also highlights the importance of writing pre-rendering JavaScript in static postScripts. ```javascript __globals.project.customInitProp doEvent(‘myCustomInitPropName’) __hooks[__globals.project.customInitProp]() ``` -------------------------------- ### Initialize Language with Callback - JavaScript Source: https://developers.dcsplus.net/trip/doc/tips-and-tricks Initializes the use of a specific language at page load. It takes a language code, a success callback, and an error callback. If no language code is provided, it falls back to the default language. This ensures the app is ready for language and translation usage. ```javascript __app.language.init(langcode, callback, errorCallback) ``` -------------------------------- ### Define Named Module for PostScript (RequireJS) Source: https://developers.dcsplus.net/trip/doc/cms-config This code snippet shows how to define a named module for a PostScript file when using a minified single file approach with RequireJS. By providing a unique ID like 'homepageHero', it ensures the module can be correctly referenced and loaded. ```javascript define('homepageHero', ['jquery'], function ($) { // ... your script logic here ... }); ``` -------------------------------- ### Bind Event Listener for Snippet Render (JavaScript) Source: https://developers.dcsplus.net/trip/doc/cms-config This JavaScript code demonstrates how to bind an event listener to a specific snippet's '-rendered' event. This allows for precise control over page reveal, ensuring content is shown only after a particular snippet, like 'homepage-hero', has finished rendering. ```javascript $(document).on('homepage-hero-rendered', function () { // Logic to reveal page content after the hero snippet is rendered }); ``` -------------------------------- ### HTML Text Translation Management Source: https://developers.dcsplus.net/trip/doc/translation Explains how HTML text translations are managed and persisted using browser localStorage within the TRIP CMS. It details the localStorage keys used and global variables available for language management. ```APIDOC ## HTML Text Translation Management ### Description This section describes the client-side mechanism for managing and persisting active language settings for HTML text translations using browser `localStorage`. It outlines the keys used for storing language data and related flags, as well as global JavaScript variables that provide access to default and active language configurations. ### Method Client-side JavaScript ### Endpoint N/A (Client-side implementation) ### Parameters #### Local Storage Keys 1. **`location.hostname + '.lang'`** (string) - **Value**: JSON object representing the language. Example: `{ Code: 'en', Rtl: false }` or `{ Code: 'en', Name: 'English', Rtl: false, ISO: 'en_GB', ... }`. - **Description**: Stores the current language code and its properties (like RTL support). 2. **`location.hostname + '.langUrlRequired'`** (boolean) - **Value**: `true` or `false`. - **Description**: Indicates whether a specific language URL parameter is required for accessing pages. If `true`, accessing a page without a language parameter might revert to the default language. #### Global Variables - **`__globals.client.defaultLanguage`** (string) - **Description**: The default language configured for the website (e.g., 'en'). This is set during the server installation. - **`__globals.activeLanguage`** (variable) - **Description**: Holds the currently active language settings if any translations are available. ### Request Example N/A (Client-side implementation) ### Response N/A (Client-side implementation) ### Notes - The persistence of language settings relies on `localStorage`. Developers are responsible for implementing logic to clear storage at desired intervals or on specific user actions. - The `__globals.client.defaultLanguage` variable is essential for server configuration related to translations. ``` -------------------------------- ### Initialize jQuery Slider in PostScript (RequireJS) Source: https://developers.dcsplus.net/trip/doc/cms-config This snippet demonstrates how to initialize a jQuery slider plugin within a PostScript using RequireJS. It ensures jQuery is loaded as a dependency before executing the initialization code. This is a standard pattern for managing dynamic script initializations. ```javascript define(['jquery'], function ($) { $('#HeroSlider').initSlider(); }); ``` -------------------------------- ### Manually Trigger Decloaking (JavaScript) Source: https://developers.dcsplus.net/trip/doc/cms-config This JavaScript snippet illustrates how to manually trigger the decloaking process using the `__app.utils.decloak()` method. This is typically used when custom decloaking is enabled, allowing developers to control the page reveal from within a PostScript. ```javascript __app.utils.decloak(); ``` -------------------------------- ### Manage 'requiredUrlParam' localStorage Key Source: https://developers.dcsplus.net/trip/doc/translation This JavaScript code illustrates how to manage the `requiredUrlParam` localStorage key to control whether translations are applied only when the `lang` URL parameter is present. It shows how to enable and disable this feature by setting or removing the key in localStorage. ```javascript // To enable: localStorage.setItem(location.hostname + '.requiredUrlParam', true); // To disable: localStorage.removeItem(location.hostname + '.requiredUrlParam'); ``` -------------------------------- ### Hotel Content Translation API Source: https://developers.dcsplus.net/trip/doc/translation Details on how to request hotel data in specific languages using the TRIP API. This includes parameters for dynamic package searches and hotel detail requests. ```APIDOC ## Hotel Content Translation API ### Description This section details how to retrieve hotel content in various languages. It covers modifications needed for both initial search requests and specific hotel detail lookups to ensure translated content is returned. ### Method GET /dynamic-package, GET /v3/hotels/{hotelID} ### Endpoint - `/dynamic-package` - `/v3/hotels/{hotelID}` ### Parameters #### Query Parameters for `/dynamic-package` - **_s[CID][h][0][hotel][lang]** (string) - Required - The language ISO code (e.g., 'en_EN') in which hotel results should be returned. This code must be configured in TRIP's admin area and available in IRIX. #### Query Parameters for `/v3/hotels/{hotelID}` - **lang** (string) - Required - The language ISO code (e.g., 'en') for the specific hotel details requested. ### Request Example #### Dynamic Package Search ``` GET /dynamic-package?_s[CID][h][0][hotel][lang]=en_EN ``` #### Hotel Details ``` GET /v3/hotels/12345?lang=en ``` ### Response #### Success Response (200) - Hotel data will be returned in the language specified by the `lang` parameter. #### Response Example (Response will vary based on the requested hotel and language) ```json { "hotelName": "Sample Hotel", "description": "A beautiful hotel with...", "address": "123 Main St..." } ``` ``` -------------------------------- ### Translate String in JavaScript Source: https://developers.dcsplus.net/trip/doc/translation This JavaScript function is used to output translated texts. It requires a single mandatory parameter: the static plain text string to be translated. This string can include punctuation marks. ```javascript function translate(textToTranslate) { // Implementation to translate text return translatedText; } ``` -------------------------------- ### Set Language via JavaScript Event Listener Source: https://developers.dcsplus.net/trip/doc/translation This JavaScript code snippet demonstrates how to change the active language based on user interaction. It listens for a 'change' event on an element with the class 'lang-selector' and calls the `setLanguage` function with the selected value. ```javascript $('.lang-selector').on('change', function(e) { setLanguage(e.target.value); }); ``` -------------------------------- ### Twig Translation Syntax Source: https://developers.dcsplus.net/trip/doc/translation This is the format used in Twig templates for translations. The text within the filter will be translated. It must be plain text and can contain punctuation. This format is crucial for the translation interface to scan and display keys correctly. ```twig {% filter translate %} This text will be translated {% endfilter %} ``` -------------------------------- ### Set Language via JavaScript Source: https://developers.dcsplus.net/trip/doc/translation The `setLanguage` JavaScript function is used to change the active language on the website. It can be triggered by user interaction (e.g., selecting from a dropdown) or by the presence of a `lang` query parameter in the URL. The function accepts the language code or object, and optional parameters to control page reloading and URL parameter enforcement. ```javascript function setLanguage(value, doNotReload, callbackFn, requiredUrlParam) { // Implementation details for changing the active language } ``` ```javascript // Example usage in an onchange attribute: ``` -------------------------------- ### Render Active Language in TWIG Source: https://developers.dcsplus.net/trip/doc/translation This TWIG code snippet demonstrates how to display the currently active language in a language selector dropdown. It iterates through available languages and marks the current one as selected, utilizing the `__globals.activeLanguage` variable. ```twig ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.