SAS logoSAS® Mobile Investigator API
    Preparing search index...

    Interface SolutionLocalizationApi

    interface SolutionLocalizationApi {
        getLocalizationBundle(): SolutionLocalizationBundle | undefined;
        getLocalizedResource(resourceKey: string): string | undefined;
        isEnabled(): boolean;
        localize(str: string, resourceKey?: string): string;
        localizeList<T extends object>(
            list: T[],
            getProps: (obj: T) => Record<string, string | undefined>,
        ): T[];
        localizeObject<T extends object>(
            obj: T,
            props: Record<string, string | undefined>,
        ): T;
    }
    Index

    Methods

    • returns the localized value for the given resource key, else, undefined.

      Parameters

      • resourceKey: string

      Returns string | undefined

    • returns true if solution localization is enabled. methods will return unmodified inputs if not enabled. note that solution localization is disabled in the administration application.

      Returns boolean

    • localize a string using a resourceKey. fallback to lookup by value if the resourceKey is not supplied/found. mappings are defined by the contents of getLocalizationBundle

      Parameters

      • str: string

        string to localize

      • OptionalresourceKey: string

        a resource key used to lookup the localized value

      Returns string

      the localized string

      localize("red", "colours.red.txt") === "rouge"
      
    • localize a list of objects. localizeObject is applied to each element in the list.

      Type Parameters

      • T extends object

      Parameters

      • list: T[]

        objects to translate

      • getProps: (obj: T) => Record<string, string | undefined>

        callback to return a map of properties and resource keys for the given list element

      Returns T[]

      the localized list

      localizeList(
      [{ id: "red", label: "Red" }, { id: "blue", label: "Blue"} ],
      (item) => ({ "label": `colours.${item.id}.title` })
      ) === [{ id: "red", label: "Rouge" }, { id: "blue", label: "Bleu"} ]
    • localize string properties of an object, properties are provided as a map of <propertyKey, resourceKey>, deep property keys are accepted. localize is applied to each property with its given resourceKey.

      Type Parameters

      • T extends object

      Parameters

      • obj: T

        source object to localize

      • props: Record<string, string | undefined>

        properties to localize and their resource keys

      Returns T

      the localized object

      localizeObject({ label: "red" }, { "label": "colours.red.txt" }) === { label: "rouge" }