question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

suggestion: router/next middleware to autolink by lang variable

See original GitHub issue

Hello, I use localeSubpaths with import { Link } from '../config/i18n' and it works really well.

When I need to use push('/url') from react/router , I need to set subpath every time according to locale variable, I would prefer approach of importing {Router} from '../config/i18n' which would be middleware for standard next router that would be prefixing urls automatically with locale as

I18nRouter.push('/media')
// to 
I18nRouter.push('/en/media')
// or
I18nRouter.push('/media') // if default locale

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
capellinicommented, Jan 29, 2019

I like this suggestion. Though I could conceptually think about how this would work, I want to make sure that I fully understand the “ins and outs” of Next.Router before doing so. We would also probably need to provide a wrapper for the withRouter HoC.

1reaction
isaachinmancommented, Jan 30, 2019

Probably all that will happen prior to a 1.0 release is that we expose lang path utils so that “advanced” users can import them and use them for their own imperative routing.

There’s a lot going on in this package at the moment and I don’t want to commit to any new features/API changes prior to 1.0.

@capellini Do you agree?

Read more comments on GitHub >

github_iconTop Results From Across the Web

withI18nRouter HOC for locale subpath routing #4 - GitHub
withI18nRouter HOC for locale subpath routing #4 ... suggestion: router/next middleware to autolink by lang variable #143.
Read more >
Advanced Features: Internationalized Routing - Next.js
Next.js has built-in support for internationalized (i18n) routing since v10.0.0 . You can provide a list of locales, the default locale, and domain-specific ......
Read more >
Advanced internationalization with Next.js and middleware
Next.js 12 introduced middleware for handling logic at the CDN level ... Update the router and locale if the selected language is changed....
Read more >
The MERN stack tutorial - LogRocket Blog
Learn all about the MERN stack in this step-by-step guide on how to use it by developing a simple CRUD application from scratch....
Read more >
Altered map routes based on user profile information
Methods and systems for an improved navigation environment are provided. The navigation system can route users to preferred locations based on user profile ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found