Options
All
  • Public
  • Public/Protected
  • All
Menu

TranslationService is the Service responsible for translation. Current implmenetation supports SalesForce Custom Labels and Dictionaries. TranslationProxy SDK is to interact with Vlocity Translation SDK functionality hosted in node server.

Hierarchy

Index

Constructors

constructor

Properties

Private config

The config used to initialize this SDK.

Private translatedLabels

translatedLabels: object

Static Private instance

Accessors

namespace

  • get namespace(): string
  • set namespace(customNamespace: string): void
  • getter method for namespace. Provides the salesforce org namespace

    Returns string

  • setter method for namespace. Set custom namespace

    Parameters

    • customNamespace: string

    Returns void

Methods

createFetchTranslationsInput

  • Create an input object of the FetchTranslationInput.

    Returns FetchTranslationsInput

    • input object that contains the labels needs to be fetched.

fetchTranslations

  • This function fetch the translations for a given set of label(s) with the language provided.

    Parameters

    Returns Promise<any>

    • promise that will get all the translated labels and keep them in labelStorage.

Private invokeAPI

  • Parameters

    Returns Promise<any>

translate

  • translate(label: string): string
  • Get the corresponding translated string for a given label. fetch() must be called first before calling this function. This function translates only strings exist in translatedLabels. Otherwise, it will return the provided label.

    Parameters

    • label: string

    Returns string

    • translatedLabel that is translated if exists. Otherwise, return the provided label.

version

  • version(): string
  • Returns the version number of SDK.

    Returns string

    Returns SDK version number as string

Static extend

  • extend(extendObj: object): void
  • Adds all the enumerable string keyed function properties of a source object to the sdk prototype. .extend should only be used to add new methods and it won't override the existing methods.

    Note: If the property already exists, it will be not be added.

    Custom functions which are being extended should have proper namespaces to avoid issues during upgrades. When Vlocity releases new changes it won't impact if unique namespaces are used.

    Example: myCompanyOrFeatureMethodName

    example

    How to extend an sdk?

    VlocitySDK.datasource.extend({ myCompanySayHello(){
         console.log("Hello World");
      }, sayTime() {
         console.log(new Date().myCompanyGetTime());
      }});
    
    const dataSource = VlocitySDK.datasource.getInstance({'create':true});
    console.log(daSource.myCompanySayHello())

    Parameters

    • extendObj: object

      The object of functions

    Returns void

Static getInstance

Static override

  • override(overrideObj: object): void
  • Adds all the enumerable string keyed function properties of a source object to the sdk prototype.

    .override method should only be used to override the existing methods and should only be used in rare cases. Overriding the existing or default methods may cause unintended consequences and may also impact during upgrades.

    Please be cautious while using this

    example

    How to override methods in an sdk?

    VlocitySDK.datasource.override({ soql(){
         console.log("This code overrides the default soql function");
         // code goes here...
      }, sosl() {
         console.log("This code overrides the default soql function");
         // code goes here...
      }});
    
    const dataSource = VlocitySDK.datasource.getInstance({'create':true});
    console.log(dataSource.soql()); // prints "This code overrides the default soql function"

    Parameters

    • overrideObj: object

      The object of functions

    Returns void

Generated using TypeDoc