Skip to content

Commit

Permalink
Add __basename__ to file
Browse files Browse the repository at this point in the history
  • Loading branch information
danhper committed Nov 25, 2020
1 parent 5b7a68c commit 534c527
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 8 additions & 6 deletions bin/static-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const minimistOptions = {
'allowHtml',
'version',
'help',
'localeRootKey'
'localeRootKey',
],
string: [
'locale',
Expand All @@ -36,25 +36,27 @@ const minimistOptions = {
h: 'help',
r: 'localeRootKey',
'root-key': 'rootKey',
'output-dir': 'outputDir',
'base-dir': 'baseDir',
'output-dir': 'outputDir',
'output-default': 'outputDefault',
'output-other': 'outputOther',
'output-override': 'outputOverride',
'translate-conditional-comments': 'translateConditionalComments',
f: 'fixPaths',
t: 'fileFormat',
'file-format': 'fileFormat',
'fix-paths': 'fixPaths',
'locales-path': 'localesPath',
'output-override': 'outputOverride',
'allow-html': 'allowHtml'
'allow-html': 'allowHtml',
},
default: {
localeRootKey: false,
useAttr: true,
fixPaths: true,
replace: false,
removeAttr: true,
xml: false
}
xml: false,
},
};

const usageText = [
Expand Down
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ function getRawOutputFile(file, locale, options) {

function getOutput(file, locale, options, absolute) {
const output = getRawOutputFile(file, locale, options);
const outputFile = output.replace('__lng__', locale).replace('__file__', file);
const outputFile = output
.replace('__lng__', locale)
.replace('__file__', file)
.replace('__basename__', path.basename(file, path.extname(file)));
if (absolute !== false) {
const outdir = _.isString(options.outputDir) ? options.outputDir : options.baseDir;
return path.join(outdir, outputFile);
Expand Down

0 comments on commit 534c527

Please sign in to comment.