MCPcopy
hub / github.com/mashpie/i18n-node / getStorageFilePath

Function getStorageFilePath

i18n.js:1334–1352  ·  view source on GitHub ↗
(locale)

Source from the content-addressed store, hash-verified

1332 * basic normalization of filepath
1333 */
1334 const getStorageFilePath = (locale) => {
1335 // changed API to use .json as default, #16
1336 const ext = extension || '.json'
1337 const filepath = path.normalize(directory + pathsep + prefix + locale + ext)
1338 const filepathJS = path.normalize(
1339 directory + pathsep + prefix + locale + '.js'
1340 )
1341 // use .js as fallback if already existing
1342 try {
1343 if (fs.statSync(filepathJS)) {
1344 logDebug('using existing file ' + filepathJS)
1345 extension = '.js'
1346 return filepathJS
1347 }
1348 } catch (e) {
1349 logDebug('will use ' + filepath)
1350 }
1351 return filepath
1352 }
1353
1354 /**
1355 * Get locales with wildcard support

Callers 2

readFunction · 0.85
writeFunction · 0.85

Calls 1

logDebugFunction · 0.85

Tested by

no test coverage detected