Giter Site home page Giter Site logo

Comments (8)

daaru00 avatar daaru00 commented on July 17, 2024

Hi @tandeman77,

did you still replicate it with the latest version? it seems like some problem with context variables, by chance if you check in the $context or in the route's meta do you see the locale property disappear?

from gridsome-plugin-i18n.

helloiamlukas avatar helloiamlukas commented on July 17, 2024

Please have a look at #32

I just opened a pull request to solve this issue.

from gridsome-plugin-i18n.

ericwaetke avatar ericwaetke commented on July 17, 2024

Temporary Workaround until this gets fixed:
cou can manually inject the language code you use in the url to your g-links.

In my case it looks like this:
<g-link class="nav__link" :to="'/'+$context.locale+'/about/'">{{$t("menu.about")}}</g-link>

Not the fanciest solution, but it works.

from gridsome-plugin-i18n.

helloiamlukas avatar helloiamlukas commented on July 17, 2024

Temporary Workaround until this gets fixed:
cou can manually inject the language code you use in the url to your g-links.

In my case it looks like this:
<g-link class="nav__link" :to="'/'+$context.locale+'/about/'">{{$t("menu.about")}}</g-link>

Not the fanciest solution, but it works.

Unfortunately this still doesn't solve the issue, as the $context doesn't include the actual locale – the locale falls back to the default locale. As already mentioned, I resolved this here: #32

from gridsome-plugin-i18n.

ericwaetke avatar ericwaetke commented on July 17, 2024

The locale still falls back to the default with your code, however. When taking out the $contect.locale the $context changes on page-switch. On links with the added $contect.locale the $context does not change

Edit: I didn't deep-dive in this top, so I don't know why this happens, just that it does :D

from gridsome-plugin-i18n.

helloiamlukas avatar helloiamlukas commented on July 17, 2024

Can you provide an example repo? In all my tests the locale didn't fall back to the default with the fix of this pull request.

from gridsome-plugin-i18n.

ericwaetke avatar ericwaetke commented on July 17, 2024

Sure!
https://github.com/Thaiten/localization-bug

I've included the my "temporary workaround" from earlier commented out so you can test the difference!

Edit: I seem to have overlooked the $tp() style of using g-links. I haven't had time to update the repo above, but I am aware of it!

from gridsome-plugin-i18n.

helloiamlukas avatar helloiamlukas commented on July 17, 2024

@ericwaetke I looked up your code now.

The problem with the $context.locale falling back to the default only applies to Templates. In your example however, you are exclusively using Pages.

Your problem is not related to this issue at all. As you already mentioned in your edit, you forgot to use the $tp helper function – by using this, everything will work as expected ☺️

from gridsome-plugin-i18n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.