Documentation
Market translations introduction¶
- Domain Model documentation
- Translation schema documents (condition format and translation format)
- Response with translations schema contains four entities that are used in localization of markets:
- markets
- outcomes
- periods
- trading types
- Each entity is a map of entity id to an array of entity translations. All entities (except trading types) have complex rules for translation. These rules are compactly encoded in condition property. Client code should check every condition in array and first matching should be used for translation.
- Response with translations schema contains four entities that are used in localization of markets:
Translation Schema Structure¶
The translation functions expect translation schema from API endpoint /v0/sport/feed/localization/markets. Key structure includes:
| Field | Type | Description |
|---|---|---|
markets | Object | Market type translations indexed by market type ID |
periods | Object | Period translations indexed by sport |
tradingTypes | Object | Trading type translations |
outcomes | Object | Outcome translations indexed by outcome type |
marketItems | Object | Market item translations (optional) |
Structure and content are described in condition format and translation format docs.
JS snippets for Frontend implementation¶
This section targets clients who will use JavaScript snippets from the examples folder. Note: these snippets are frontend implementation details built based on:
Download examples.zip: - Archive with all js snippets and usage demo.
Market Object Schema¶
The market translation functions work with market objects that follow the MarketDto API schema (Similar for LineApi and DFAPI):
{
"key": {
"period": 0, // Period of market (integer)
"subPeriod": null, // Sub-period of market (integer, nullable)
"marketType": 1, // Type of market (integer)
"resultKind": 1, // Kind of market (integer)
"layout": null // Layout string (nullable, deprecated)
},
"items": [
{
"values": [], // Market specific array of values (e.g. ["3", "1"])
"isOpen": true, // Shows that market is open for trading
"outcomes": [
{
"key": {
"type": 0, // Outcome type (integer)
"values": [] // Outcome values array
},
"odd": 230, // Odd multiplied by 100 (e.g. 1.35 = 135)
"status": "Opened" // Status: "Opened", "Suspended", "Removed"
}
]
}
],
"tabs": [0] // Array of tab integers
}
Related Schema Objects¶
| Object | Field | Type | Description |
|---|---|---|---|
| MarketKey | period | integer | Period of market |
subPeriod | integer, nullable | Sub-period of market | |
marketType | integer | Type of market | |
resultKind | integer | Kind of market | |
layout | string, nullable | Layout string (deprecated) | |
| MarketItemDto | values | array | Market specific array of values |
isOpen | boolean | Boolean indicating if market is open for trading | |
outcomes | array | Array of OutcomeDto objects | |
| OutcomeDto | key | object | OutcomeKey object with type and values |
odd | integer | Odd value multiplied by 100 | |
status | string | Status string ("Opened", "Suspended", "Removed") |
Exported Functions Documentation¶
getMarketName()¶
Location: marketName.js
Purpose: Generates translated market names based on market data and translation rules.
Parameter Specifications:
| Parameter | Type | Market Object Field | Description |
|---|---|---|---|
translations | Object | API Response | Translation schema from /v0/sport/feed/localization/markets |
translations.markets | Object | API Response | Market type translations indexed by market type |
translations.periods | Object | API Response | Period translations indexed by sport |
translations.tradingTypes | Object | API Response | Trading type translations |
marketId | Object | market.key | Market key object from MarketDto |
marketId.marketType | Integer | market.key.marketType | Market type identifier |
marketId.resultKind | Integer | market.key.resultKind | Result kind identifier |
marketId.period | Integer | market.key.period | Period identifier |
marketId.subPeriod | Integer | market.key.subPeriod | Sub-period identifier |
sportFeedId | String | Event Data | Sport identifier |
competitors | Array | Event Data | Array of competitor objects |
marketParameters | Array | market.items[0].values | Market parameters array from first item (works with markets with single market item) |
marketParametersWithCompetitors | Array | Event Competitors | Array of objects with team names for TeamN token replacement |
marketParametersWithPlayers | Array | Player Data | Array of players for markets with players |
useShortName | Boolean | Optional | Flag for using short competitor names |
useAsiaName | Boolean | Optional | Flag for using Asian market name format |
Returns: String - Translated market name
getMarketItemName()¶
Location: marketName.js
Purpose: Generates translated market item names for specific market items.
Parameter Specifications:
| Parameter | Type | Market Object Field | Description |
|---|---|---|---|
marketItemsTranslations | Object | Translation Data | Market items translation data |
marketId | Object | market.key | Market key object from MarketDto |
marketId.marketType | Integer | market.key.marketType | Market type identifier |
marketId.resultKind | Integer | market.key.resultKind | Result kind identifier |
marketId.period | Integer | market.key.period | Period identifier |
sportFeedId | String | Event Data | Sport identifier |
competitors | Array | Event Data | Array of competitor objects |
marketItemParameters | Array | market.items[].values | Market item parameters |
marketParametersWithCompetitors | Array | Event Competitors | Array of objects with team names for TeamN token replacement |
marketParametersWithPlayers | Array | Player Data | Array of players for markets with players |
Returns: String - Translated market item name
getOutcomeName()¶
Location: OutcomeName.utils.js
Purpose: Generates translated outcome names for individual outcomes within market items.
Parameter Specifications:
| Parameter | Type | Market Object Field | Description |
|---|---|---|---|
marketId | Object | market.key | Market key object from MarketDto |
marketId.marketType | Integer | market.key.marketType | Market type identifier |
marketId.period | Integer | market.key.period | Period identifier |
marketId.subPeriod | Integer | market.key.subPeriod | Sub-period identifier |
marketItemKey | Object | Market Item Data | Market item key object |
marketItemKey.marketParameters | Array | market.items[].values | Market item parameters |
outcomeKey | Object | outcome.key | Outcome key object from OutcomeDto |
outcomeKey.type | Integer | outcome.key.type | Outcome type identifier |
outcomeKey.values | Array | outcome.key.values | Outcome values array |
sport | String | Event Data | Sport identifier |
competitors | Array | Event Data | Array of competitor objects for {Team1}, {Team2} replacement |
translations | Object | API Response | Translation schema object |
templateType | String | Optional | Template type (default: SHORT) |
skipMarketParameters | Boolean | Optional | Flag to skip market parameters - if true then removes tokens from translation related to market values |
outcomeValuesWithPlayers | Array | Player Data | Array mapping outcome values to player objects by position. Used for #player{s1} replacement where s1 refers to first outcome value |
markedParametersWithCompetitors | Object | Event Competitors | Object mapping market parameter IDs to competitor objects. Used for #competitor{p1} replacement |
Returns: String - Translated outcome name
Function Parameters Details¶
Common Parameters¶
| Parameter | Type | Source | Description |
|---|---|---|---|
translations | Object | API endpoint /v0/sport/feed/localization/markets | Translation schema containing translation rules. Can be full JSON or top-level fields from translations-example.json. Structure described in condition-format.md and translation-format.md |
competitors | Array | Event's competitors field | Array of objects with team names to replace "{TeamN}" tokens in translations |
marketParametersWithPlayers | Array | Player Data | Array of player objects mapped by position for market parameters. Used for #player{p1} replacement in market-level translations |
marketParametersWithCompetitors | Array | Event Competitors | Array of competitor objects mapped by position for market parameters. Used for #competitor{p1} replacement in market-level translations |
outcomeValuesWithPlayers | Array | Player Data | Array of player objects mapped by position for outcome values. Used for #player{s1} replacement in outcome-level translations |
Market Object Field Mappings:
marketIdmaps directly tomarket.keyfrom MarketDtomarketParametersmaps tomarket.items[0].valuesfrom first MarketItemDto (works with markets with single market item)outcomeKeymaps directly tooutcome.keyfrom OutcomeDto