MCPcopy Create free account
hub / github.com/ampproject/amphtml / findLocalizedString

Function findLocalizedString

src/service/localization/index.js:34–48  ·  view source on GitHub ↗

* Gets the string matching the specified localized string ID in the language * specified. * @param {!{[key: string]: !LocalizedStringBundleDef}} localizedStringBundles * @param {!Array } languageCodes * @param {!LocalizedStringId_Enum} localizedStringId * @return {?string}

(
  localizedStringBundles,
  languageCodes,
  localizedStringId
)

Source from the content-addressed store, hash-verified

32 * @return {?string}
33 */
34function findLocalizedString(
35 localizedStringBundles,
36 languageCodes,
37 localizedStringId
38) {
39 for (const code of languageCodes) {
40 const entry = localizedStringBundles[code]?.[localizedStringId];
41 if (entry != null) {
42 // In unminified builds, this is an object {"string": "foo", ...}.
43 // In minified builds, this is the actual string "foo".
44 return entry['string'] || entry;
45 }
46 }
47 return null;
48}
49
50/**
51 * @param {string} languageCode

Callers 2

getLocalizedStringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected