Namespace not being loaded for error page with default-prefix middleware
See original GitHub issueWhat version of Next.js are you using?
12.0.4-canary.5
What version of Node.js are you using?
v16.13.0
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
next start
Describe the Bug
I see not translated strings at error page using middleware to prefix default locale
Expected Behavior
I expected to see translated strings with loaded namespace
To Reproduce
- Use middleware to prefix the default locale
- Try to open any not-existing file from
publicfolder (without locale prefix): http://localhost:3031/common/this_file_not_exists.png - There will be no redirect to locale-prefixed path because of the check for a file at middleware config
- You will see the output from the
_error.tsxpage. - Try to output some translatable strings on this error page
- You’ll see “common:error.title” instead of the translated strings
- All strings are translated OK with locale-prefixed path like: http://localhost:3031/ru/common/test.png
My i18n.json:
{
"locales": ["default", "ru", "en"],
"defaultLocale": "default",
"pages": {
"*": ["common", "main"],
"/_error": ["common", "main"]
}
}
And /pages/_middleware.ts:
import { NextRequest, NextResponse } from 'next/server'
const PUBLIC_FILE = /\.(.*)$/
const DEFAULT_LOCALE = 'en'
export function middleware(request: NextRequest) {
const pathName = request.nextUrl.pathname
const shouldHandleLocale =
!PUBLIC_FILE.test(pathName) && request.nextUrl.locale === 'default'
return shouldHandleLocale
? NextResponse.redirect(`/${DEFAULT_LOCALE}${pathName}`)
: undefined
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Namespace not being loaded for error page with default-prefix ...
To Reproduce. Use middleware to prefix the default locale; Try to open any not-existing file from public folder (without locale prefix): http ...
Read more >load(): Namespace default prefix was not found in Entity ...
A workaround (and possible permanent solution) is that of adding the namespace to each of the <!ENTITY> s, like so:
Read more >11 Oracle WebLogic Server
Oracle Fusion Middleware 11g contains Oracle WebLogic Server 11g. The version number of ... Section 11.2.1, "Cached JDBC Information is not Displayed".
Read more >CICS TS for z/OS: Using Web Services with CICS - IBM
Not every request is succeeded by a response; some applications use a ... immediate transition can also occur if CICS detects an error....
Read more >2007-July.txt - Python mailing list
The default prefix is "app:"; you can also give "middleware:". Prefixes not recognized will be ignored. A possible prefix might be "logging:" for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Just for context, this is the error
It would be nice if there was a property like
ignoreDefault: boolean, that would just ignore thedefaultlocale.hi guys, using 1.4.0 of next-translate now.
After setup with localesToIgnore, But I still got the default locale with a 404 page complied at the very first time it running
npm run dev(should be the compliation triggered bygetStaticProps)Here is the sinppet:
May I know what is wrong in my config? Or there’s other issues we didn’t spot it in this thread?