Comments (8)
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.
Please have a look at #32
I just opened a pull request to solve this issue.
from gridsome-plugin-i18n.
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.
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.
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.
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.
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.
@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)
- Duplicate key for property path HOT 13
- Provide better example using page queries HOT 11
- Localized routes HOT 15
- Translation issues on 404 (not found) route HOT 7
- Make the plugin public for other people HOT 2
- Language prefix in path breaks active class on g-link HOT 2
- with "rewriteDefaultLanguage" the gridsome pages not have locale for page-query HOT 3
- G-links & Locale Switcher fail when you first reach the URL. Reload & all works OK (Netlify Host)
- How do you navigate to the user's browser language? HOT 1
- Package Size HOT 1
- How sort languages? HOT 1
- Npm & gridsome readme is outdated
- $i18n.locale behaving differently in templates vs pages HOT 1
- pathAliases retrieval
- Cannot read property '$i18n' of undefined HOT 5
- Localised routes HOT 9
- Disable/exclude redirect(Rewrite) for assets (Get 404 not found)
- How to use i18n only at build time, without adding to client JS bundle?
- How to properly query data with graphql
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gridsome-plugin-i18n.