TranslationService
- 26 Nov 2024
- 1 Minute to read
- Print
- DarkLight
TranslationService
- Updated on 26 Nov 2024
- 1 Minute to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
To be able to retrieve record text field translations registered by OrderCentral you can use the welisacommerce.TranslationService
class. It holds a method getLocalizedRecords()
. It accepts an instance of the welisacommerce.TranslationService GetLocalizedRecordsRequest
. It returns an instance of welisacommerce.TranslationService .GetLocalizedRecordsResult
.
Class definitions
All classes that are used as input and output are listed below
welisacommerce.TranslationService.GetLocalizedRecordsRequest
Property Name | Property Type | Description |
---|---|---|
recordIds | List<Id> | Ids of the records to retrieve. All need to be of the same type |
fields | List<Schema.SObjectField> | The field tokens which needs to be translated |
languages | List<String> | The language iso codes which translate the values to (examples: nl_NL, en_US) |
onlyIncludeTranslatedRecords | Boolean | If true only records will be returned that are translated, defaults to false |
welisacommerce.TranslationService .GetLocalizedRecordsResult
Property Name | Property Type | Description |
---|---|---|
results | List<welisacommerce.TranslationService .LocalizedRecords> | A list of localized records grouped by language iso code |
welisacommerce.TranslationService.LocalizedRecords
Property Name | Property Type | Description |
---|---|---|
language | String | The language iso code to which the records are translated |
records | List<welisacommerce.LocalizedSObjectDto> | A list of translated records |
welisacommerce.LocalizedSObjectDto
Property Name | Property Type | Description |
---|---|---|
recordId | Id | The language iso code to which the records are translated |
fields | Map<String, welisacommerce.LocalizedFieldValueDto> | Hold the translated field value by the field api name |
welisacommerce.LocalizedFieldValueDto
Property Name | Property Type | Description |
---|---|---|
value | Object | The actual field value |
displayValue | String | The localized (translated) field value |
Example class
public class ExampleClass {
public List<welisacommerce.LocalizedSObjectDto> getTranslatedRecords(List<Id> webProductIds) {
welisacommerce.TranslationService.GetLocalizedRecordsRequest request =
new welisacommerce.TranslationService.GetLocalizedRecordsRequest();
request.recordIds = webProductIds;
request.fields = new List<Schema.SObjectField> {
welisacommerce__Web_Product__c.welisacommerce__Title__c
};
request.languages = new List<String>{ 'nl_NL' };
request.onlyIncludeTranslatedRecords = true;
return welisacommerce.TranslationService.getLocalizedRecords(request).results);
}
}