cds-snc / node-starter-app

Quick start application setup.... because you have to start somewhere.
MIT License
5 stars 3 forks source link

Better bilingual routes #58

Closed dsamojlenko closed 4 years ago

dsamojlenko commented 5 years ago

Would like to see if we can improve on the bilingual routing.

Currently, we have a single route with a lang param to switch languages, so a french url would look like:

/personal?lang=fr

An obvious issue is the unilingual url segment personal. Also, query params are kinda ugly.

Would be better: /en/personal /fr/personnel

(we'd need the language prefix since some words are same english/french, ie confirmation)

So, not sure exactly how to pull this off, but to start we'd need to revisit the config/routes file. Maybe something like this:

const routes = [
  { name: 'start', lang: 'en', path: '/start' },
  { name: 'start', lang: 'fr', path: '/debut' },
  { name: 'personal', lang: 'en', path: '/personal' },
  { name: 'personal', lang: 'fr', path: '/personnel' },
  { name: 'confirmation', lang: 'en', path: '/confirmation' },
  { name: 'confirmation', lang: 'fr', path: '/confirmation' }
];
timarney commented 4 years ago

Thinking it would be better do route setup more grouped like this:

const routes = [
  { name: 'start', path : {"en", "/start" , "fr", "/debut"}},
];

The helper functions can still do the lookup based on "start" and path would get returned via the helpers using the local.

jneen commented 4 years ago

In case it's a string, we can treat it as if both are the same.

jneen commented 4 years ago

I have a preliminary version of this based on #82.