MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / loadTranslation

Function loadTranslation

lib/container.js:974–996  ·  view source on GitHub ↗

* Method collect own property and prototype

(locale, vocabularies)

Source from the content-addressed store, hash-verified

972 */
973
974async function loadTranslation(locale, vocabularies) {
975 if (!locale) {
976 return Translation.createEmpty()
977 }
978
979 let translation
980
981 // check if it is a known translation
982 const langs = await Translation.getLangs()
983 if (langs[locale]) {
984 translation = new Translation(langs[locale])
985 } else if (fileExists(path.join(store.codeceptDir, locale))) {
986 // get from a provided file instead
987 translation = Translation.createDefault()
988 translation.loadVocabulary(locale)
989 } else {
990 translation = Translation.createDefault()
991 }
992
993 vocabularies.forEach(v => translation.loadVocabulary(v))
994
995 return translation
996}
997
998function getHelperModuleName(helperName, config) {
999 // classical require

Callers 2

createMethod · 0.85
clearMethod · 0.85

Calls 5

fileExistsFunction · 0.90
createEmptyMethod · 0.80
getLangsMethod · 0.80
createDefaultMethod · 0.80
loadVocabularyMethod · 0.80

Tested by

no test coverage detected