Skip to content

Commit

Permalink
feat: Pass locale as template variable (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabschurt committed Apr 26, 2024
1 parent cdf2ac8 commit 79da07a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ export default async function main(
lang
? (
parseProjectTranslations(_parseJSONFile, withSrcDir, dotFlattenObject)(lang)
.then((dictionary) => ({ _: { t: translateString(IntlMessageFormat, dictionary, lang) } }))
.then((dictionary) => ({
_: {
locale: lang,
t: translateString(IntlMessageFormat, dictionary, lang),
},
}))
)
: {}
,
Expand Down
4 changes: 2 additions & 2 deletions tests/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('#src/main', () => {
`)
await fs.writeFile(indexTemplatePath, `
doctype html
html
html(lang=_.locale)
head
title Some meaningless title
body
Expand All @@ -77,7 +77,7 @@ html
assert.strictEqual(
await fs.readFile(indexOutputPath, { encoding: 'utf8' }),
'<!DOCTYPE html>' +
'<html>' +
'<html lang="en">' +
'<head>' +
'<title>Some meaningless title</title>' +
'</head>' +
Expand Down

0 comments on commit 79da07a

Please sign in to comment.