MCPcopy Create free account
hub / github.com/FSGModding/FSG_Mod_Assistant / syncStringLookup

Method syncStringLookup

lib/modUtilLib.js:482–499  ·  view source on GitHub ↗

* Synchronous lookup * @param {string} stringID * @returns {string} Translated text

(stringID)

Source from the content-addressed store, hash-verified

480 * @returns {string} Translated text
481 */
482 syncStringLookup(stringID) {
483 // Note: this could fail depending on when it's used.
484 if ( stringID === null ) { return null }
485
486 let possibleValue = null
487 const lcStringID = stringID.toLowerCase()
488
489 possibleValue ??= this.#iconOverride(lcStringID)
490 possibleValue ??= this.#translatorStrings.get(this.#currentLocale)?.get(lcStringID)
491 possibleValue ??= this.#translatorStrings.get('en')?.get(lcStringID)
492 possibleValue ??= `__${lcStringID}__`
493
494 if ( this.#debug ) {
495 if ( possibleValue === '' ) { this.#log.info(`Empty translation string : ${this.#currentLocale} :: ${lcStringID}`) }
496 if ( possibleValue === `__${lcStringID}__` ) { this.#log.info(`Unknown translation string : ${this.#currentLocale} :: ${lcStringID}`) }
497 }
498 return possibleValue
499 }
500
501 /**
502 * Retrieve MA string

Callers 10

currentUnitsMethod · 0.95
stringLookupMethod · 0.95
stringGroupMethod · 0.95
__Function · 0.80
trayContextMenuMethod · 0.80
createSubWindowMethod · 0.80
sendToTrayMethod · 0.80
doDialogBoxMethod · 0.80
openMethod · 0.80
modUtilLib.jsFile · 0.80

Calls 3

#iconOverrideMethod · 0.95
infoMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected