Skip to content

Commit

Permalink
Release 1.1.1 (#705)
Browse files Browse the repository at this point in the history
* feat(697): allow to disable colors (#698)

* docs: add rubenmoya as a contributor for code (#699)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* Update package VERSION

* Add pagesInDir config property + improve default (#701)

* Add app and integrations folders for Blitz

* Add pagesInPath configuration property

* Fix (#704)

* Update .npmrc

Co-authored-by: Rubén Moya <[email protected]>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 8, 2021
1 parent b1f0f40 commit 881ffe3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@
"contributions": [
"doc"
]
},
{
"login": "rubenmoya",
"name": "Rubén Moya",
"avatar_url": "https://avatars.githubusercontent.com/u/905225?v=4",
"profile": "https://rubenmoya.dev",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
registry=http://registry.npmjs.org/
registry=https://registry.npmjs.org/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ In the configuration file you can use both the configuration that we specified h
| `interpolation` | Change the delimeter that is used for interpolation. | `{prefix: string; suffix: string}` | `{prefix: '{{', suffix: '}}'}`
| `staticsHoc` | The HOCs we have in our API ([appWithI18n](#appwithi18n)), do not use [hoist-non-react-statics](https://github.com/mridgway/hoist-non-react-statics) in order not to include more kb than necessary _(static values different than getInitialProps in the pages are rarely used)_. If you have any conflict with statics, you can add hoist-non-react-statics (or any other alternative) here. [See an example](docs/hoist-non-react-statics.md). | `Function` | `null`
| `extensionsRgx` | Change the regex used by the webpack loader to find Next.js pages. | `Regex` | `/\.(tsx\|ts\|js\|mjs\|jsx)$/`
| `pagesInDir` | If you run `next ./my-app` to change where your pages are, you can here define `my-app/pages` so that next-translate can guess where they are. | `String` | If you don't define it, by default the pages will be searched for in the classic places like `pages` and `src/pages`.


## 4. API
Expand Down Expand Up @@ -873,6 +874,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
</tr>
<tr>
<td align="center"><a href="https://its-just-nans.github.io"><img src="https://avatars.githubusercontent.com/u/56606507?v=4?s=100" width="100px;" alt=""/><br /><sub><b>n4n5</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=Its-Just-Nans" title="Documentation">📖</a></td>
<td align="center"><a href="https://rubenmoya.dev"><img src="https://avatars.githubusercontent.com/u/905225?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rubén Moya</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=rubenmoya" title="Code">💻</a></td>
</tr>
</table>

Expand Down
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": "1.1.0",
"version": "1.1.1-canary.3",
"description": "Tiny and powerful i18n tools (Next plugin + API) to translate your Next.js pages.",
"license": "MIT",
"keywords": [
Expand Down
8 changes: 7 additions & 1 deletion src/loadNamespaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { LoaderConfig, LocaleLoader } from '.'
import getConfig from './getConfig'
import getPageNamespaces from './getPageNamespaces'

const colorEnabled =
process.env.NODE_DISABLE_COLORS == null &&
process.env.NO_COLOR == null &&
process.env.TERM !== 'dumb' &&
process.env.FORCE_COLOR !== '0'

export default async function loadNamespaces(
config: LoaderConfig = {}
): Promise<{
Expand Down Expand Up @@ -42,7 +48,7 @@ export default async function loadNamespaces(
).catch(() => {})) || []

if (conf.logBuild !== false && typeof window === 'undefined') {
const color = (c: string) => `\x1b[36m${c}\x1b[0m`
const color = (c: string) => (colorEnabled ? `\x1b[36m${c}\x1b[0m` : c)
console.log(
color('next-translate'),
`- compiled page:`,
Expand Down
21 changes: 16 additions & 5 deletions src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,32 @@ export default function nextTranslate(nextConfig: any = {}) {
path.relative(pkgDir(), process.env.NEXT_TRANSLATE_PATH || '.')
)

const arePagesInsideSrc = fs.existsSync(path.join(dir, 'src/pages'))

const i18n = nextConfig.i18n || {}
const {
let {
locales,
defaultLocale,
loader = true,
pagesInDir,
pages,
logger,
...restI18n
} = require(path.join(dir, 'i18n'))

// Check if exist a getInitialProps on _app.js
let hasGetInitialPropsOnAppJs = false
const pagesPath = path.join(dir, arePagesInsideSrc ? '/src/pages' : '/pages')

// https://github.com/blitz-js/blitz/blob/canary/nextjs/packages/next/build/utils.ts#L54-L59
if (!pagesInDir) {
pagesInDir = 'pages'
if (fs.existsSync(path.join(dir, 'src/pages'))) {
pagesInDir = 'src/pages'
} else if (fs.existsSync(path.join(dir, 'app/pages'))) {
pagesInDir = 'app/pages'
} else if (fs.existsSync(path.join(dir, 'integrations/pages'))) {
pagesInDir = 'integrations/pages'
}
}

const pagesPath = path.join(dir, pagesInDir)
const app = fs
.readdirSync(pagesPath)
.find((page: string) => page.startsWith('_app.'))
Expand Down

0 comments on commit 881ffe3

Please sign in to comment.