@welldot/core

resolveLanguageText

Resolves text to a single string for locale: exact tag, then its base language (pt-BR → pt), then fallback, then the first available value. Empty labels count as missing.

resolveLanguageText(text, locale, fallback?): string

Resolves text to a single string for locale: exact tag, then its base language (pt-BR → pt), then fallback, then the first available value. Empty labels count as missing.

  • A plain string is locale-invariant and returned as-is.
  • A JSON object string ('{"en":"Pump","pt":"Bomba"}') is parsed and resolved like the object; malformed JSON is treated as a plain string.
  • null / undefined, and objects (or JSON objects) with no usable label, resolve to ''.

Parameters

text

LanguageTextInput

locale

string

fallback?

string = 'en'

Returns

string