Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP feat: Implement slug solution #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Jno21
Copy link

@Jno21 Jno21 commented May 22, 2020

feat: Implement slug solution to rename your URLs depending of the language

This feature will allow users to be able to change the url name depending of the language use.

Example:

  • /en/about
  • /fr/a-propos

How to use it ?

Imagine some pages:

pages/
  - index.js
  - features.js
  - about.js

Create or modify your language ressource file example: src/int/fr.json

{
  "features": {
    "slug": "fonctionnalites" 
  },
  "about": {
    "slug": "a-propos"
  }
}

And use your link like usual:

import { Link } from "gatsby-plugin-intl"

const MyLinks = () => (
          <Link to="/features">
          <Link to="/about">
);

export default MyLinks

What's missing

The Object slugs containing all the differents slug by language on the current page is not accesible via useIntl().

It should be accesible via context tho.

TODO

In another PR I will try to see if I can modify the wrapper to inject directly in the the good alternate link for SEO purpose.

So this is a WIP, it needs to be tested correctly.

So test it, and come back to me if there is a bug / problem related to this implementation, when everything is validated that would be a great feature to this product !

@Jno21
Copy link
Author

Jno21 commented May 22, 2020

#33

@rekuenkdr
Copy link

Hi, I've tested and so far it works great, something I've noticed is that on the translated url the last trailing slash is missing while in the original remains.
Thanks!

@adiusz
Copy link

adiusz commented Aug 24, 2020

hey @Jno21, good job! Since the creator of the plugins seems to be permanent offline, have you considered creating your own version of this plugin with this slug functionality? It would be really awesome to easily implement this feature!

@Jno21
Copy link
Author

Jno21 commented Aug 24, 2020

Hi,

Well you can technically use my branch as plugin. I am going to do a README.md when I have a little time to explain how to do everything :)

@adiusz
Copy link

adiusz commented Aug 25, 2020

I could, but I'm little confused how to implement it, so it would be awesome if you put some informations in README.md :) Please let us know when you do it :D

@gregoryforel
Copy link

Hi, I've tested and so far it works great, something I've noticed is that on the translated url the last trailing slash is missing while in the original remains.
Thanks!

Would you mind sharing how you implemented it? I'm struggling so far. Thank you!

@Jno21
Copy link
Author

Jno21 commented Sep 9, 2020

Hey, sorry didn't have much time so far. I will try to update my branch as soon as I can with everything.

Here a fast explanation on how to install it:
https://gist.github.com/Jno21/0c641cd2e009b2f994823598b77e0366

Keep me update if it is good for you.

@gregoryforel
Copy link

gregoryforel commented Sep 9, 2020

Thanks @Jno21

It works perfectly. I had not realized that I also had to create a "pricing": { "slug": "precios" } in my es.json file.

Thanks again!

@KajBialas
Copy link

@Jno21 - your solution isn't working for nested routes, eg: /about/teams :)

@Jno21
Copy link
Author

Jno21 commented Jun 15, 2022

Hi !
It has been a while and I am currently not working anymore on this project.
For those who still want to use this feature I published it to make things easier:
https://www.gatsbyjs.com/plugins/@jno21/gatsby-plugin-intl/?=@jno21/gatsby-plugin-intl

For the nested routes, I have no clue since it has been 2 years. Unfortunately I don't think I will have time to patch this and it seems that this project has not been active since a while.

Is there other alternative nowadays ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants