ChemPal Documentation - v1.17.0
    Preparing search index...

    Variable getLocalizedNamesConst

    getLocalizedNames: (term: string, lang: string) => Promise<string[] | undefined> = ...

    Resolves a CAS number or English chemical name to its Wikidata label and aliases in another language. Cached for wikidata.ttlDays (config.json); a definitive "no match" is cached as an empty array, a failed request (undefined) is not.

    Type declaration

      • (term: string, lang: string): Promise<string[] | undefined>
      • Parameters

        • term: string

          A CAS number (7647-01-0) or an English chemical name (hydrochloric acid)

        • lang: string

          Target language code, e.g. nl

        Returns Promise<string[] | undefined>

        The label first, then up to wikidata.maxAliases aliases; an empty array when Wikidata has no confident match; undefined if the lookup failed

    await getLocalizedNames("7647-01-0", "nl");
    // Returns: ["zoutzuur"]
    await getLocalizedNames("sodium chloride", "nl");
    // Returns: ["natriumchloride"]
    await getLocalizedNames("not a chemical", "nl");
    // Returns: []
    export const getLocalizedNames: (term: string, lang: string) => Promise<string[] | undefined> =
    withTtlCache(getLocalizedNamesUncached, { namespace: 'wikidataNames', ttlMs: TTL_MS });