Skip to content

Commit

Permalink
Fix document lang typescript (#188)
Browse files Browse the repository at this point in the history
* Update package version

* Fix documentLang in TypeScript
  • Loading branch information
aralroca authored May 30, 2020
1 parent f711246 commit 597ca43
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/examples/*/node_modules

out
/.pnp
.pnp.js

Expand Down Expand Up @@ -37,4 +38,6 @@ yarn-error.log*
*.js
!src/**/*.js
!__tests__/*.js
!examples/**/*.js
!examples/**/*.js

.vscode
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-translate",
"version": "0.17.0-canary.2",
"version": "0.17.1-canary.1",
"description": "Next.js utility to translate pages without the need of a server (static i18n pages generator).",
"license": "MIT",
"keywords": [
Expand Down
7 changes: 5 additions & 2 deletions src/documentLang.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const path = require('path')
const fs = require('fs')

export default function documentLang({ __NEXT_DATA__ }) {
const { resolve } = require('path')
const i = require(resolve(process.cwd() + '/i18n.json'))
const configDir = path.join(process.cwd(), 'i18n.json')
const i = JSON.parse(fs.readFileSync(configDir))
const { page } = __NEXT_DATA__
const [, langQuery] = page.split('/')
const lang = i.allLanguages.find((l) => l === langQuery)
Expand Down

0 comments on commit 597ca43

Please sign in to comment.