| 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 |