TMS Selector API Documentations
Accessing the API
After initialization, the API is available globally at:
window.tms.selectorApi
API Properties
Property |
Type |
Description |
Example Output |
language | { code: string } | The current language code | { code: "en" } |
region | { code: string } | The current region code | { code: "CA" } |
currency | { code: string } | The current currency code | { code: "CAD" } |
type | string | The selector type (see possible values below) | "region-language-selector" |
visitorGeo | { code: string } | The visitor’s geo region code (IP-based) | { code: "US" } |
Selector Type Values
The
type
property can return one of the following strings:
"language-selector"
"region-selector"
"region-language-selector"
"currency-selector"
"currency-language-selector"
Example Usage
// Get the current language const language = window.tms.selectorApi.language; // Get the current region const region = window.tms.selectorApi.region; // Get the current currency const currency = window.tms.selectorApi.currency; // Get the selector type const selectorType = window.tms.selectorApi.type; // Get the visitor's geo region const visitorGeo = window.tms.selectorApi.visitorGeo;
Notes:
- All properties are read-only.
- The API is automatically available on the page once initialized.
- If a value is not recognized or available, a default such as
""
is returned.