-
Notifications
You must be signed in to change notification settings - Fork 37
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
The plugin thinks the locale is set to undefined
for localizePath()
#131
Comments
Same behaviour on my project, same context as mentioned above. |
Same in my project. I fixed it by using
|
Same behavior on my project, same context as mentioned above. |
I knew it was possible to fix this @Akasiek, but I have tens and tens of instances scattered across tens of files. |
I'm guessing it's because I've set i18next as a peer dependency in beta.18. I'll look into it. |
@yassinedoghri I had to manually install it, after the update. It is installed, though. |
Having i18next set as peer dependency prevents astro-i18next from accessing the same i18next context. Keeping it as a direct dependency for now. fixes #131
Having i18next set as peer dependency prevents astro-i18next from accessing the same i18next context. Keeping it as a direct dependency for now. fixes #131
Having i18next set as peer dependency prevents astro-i18next from accessing the same i18next context. Keeping it as a direct dependency for now. fixes #131
# [1.0.0-beta.19](v1.0.0-beta.18...v1.0.0-beta.19) (2023-03-05) ### Bug Fixes * add levels to relative path in script tag ([1203d42](1203d42)), closes [#129](#129) * use unjs/pathe to resolve generated localized files paths across OS ([da80a8d](da80a8d)), closes [#135](#135) ### Reverts * **i18next-peer:** reset i18next as package dependency ([7906e19](7906e19)), closes [#131](#131)
🎉 This issue has been resolved in version 1.0.0-beta.19 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Reverted to having |
@yassinedoghri For some reason I'm still getting this problem:
---
import i18next, { changeLanguage } from "i18next";
import { localizePath } from "astro-i18next";
import { getCollection } from "astro:content";
import Layout from "../../layouts/Layout.astro";
export async function getStaticPaths({ paginate }) {
changeLanguage("en");
const posts = await getCollection("blog", ({ id }) =>
id.startsWith(i18next.language)
);
return paginate(posts, {
pageSize: 1,
});
}
const { page } = Astro.props;
const example = localizePath(`blog/${page.data[0].slug.split("/").slice(1).join("/")}`)
console.log(example);
---
"dependencies": {
"@astrojs/mdx": "^1.0.0",
"astro": "^3.0.7",
"astro-i18next": "1.0.0-beta.21",
"i18next": "^23.4.6",
"i18next-fs-backend": "^2.1.5"
} |
I just noticed that it happens because of the |
# [1.0.0-beta.19](yassinedoghri/astro-i18next@v1.0.0-beta.18...v1.0.0-beta.19) (2023-03-05) ### Bug Fixes * add levels to relative path in script tag ([1203d42](yassinedoghri/astro-i18next@1203d42)), closes [#129](yassinedoghri/astro-i18next#129) * use unjs/pathe to resolve generated localized files paths across OS ([da80a8d](yassinedoghri/astro-i18next@da80a8d)), closes [#135](yassinedoghri/astro-i18next#135) ### Reverts * **i18next-peer:** reset i18next as package dependency ([7906e19](yassinedoghri/astro-i18next@7906e19)), closes [#131](yassinedoghri/astro-i18next#131)
I am getting this issue too
|
Describe the bug
Starting from the latest, v1.0.0-beta.18 release, all instances of
localizePath()
(at least, do not use other variations, but most depend on this) assume that the currentlocale
isundefined
, unless I manually add it in the function call, after the URL.localizePath("/search")
fails,localizePath("/search", "es")
works.To Reproduce
localizePath()
with a locale in thelocales
key in the plugin's config file (in my case this is the default locale, too), as it should be configured per the instructions (including thei18next.changeLanguage()
at the top of the Astro file).localizePath()
will return wrongly formatted URLs, missing the language part completely).Expected behavior
It should get the current locale, which is correctly set (I checked,
i18next.language
returns the correct one) and use it if not set manually as it did previously.Context (please complete the following information):
astro-i18next
version: v1.0.0-beta.18astro
version: 2.0.16Possible fixes
The issue seems to be related to the check here, which fails, haven't yet figured out where it went wrong, but it's definitely in the commits between v1.0.0-beta.17 and v1.0.0-beta.18.
astro-i18next/src/utils.ts
Line 238 in aa5f1c9
The text was updated successfully, but these errors were encountered: