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

1.0.0 beta 14 breaks loadPath #79

Closed
fmilioni opened this issue Nov 30, 2022 · 6 comments
Closed

1.0.0 beta 14 breaks loadPath #79

fmilioni opened this issue Nov 30, 2022 · 6 comments
Labels
bug Something isn't working released on @beta

Comments

@fmilioni
Copy link

fmilioni commented Nov 30, 2022

After this commit all my keys returns default untranslated string.

The temporary workaround that works for me is this snippet bellow:

/** @type {import('astro-i18next').AstroI18nextConfig} */
export default {
  ...
  i18nextServer: {
    backend: {
      loadPath: "./public/locales/{{lng}}/{{ns}}.json",
    },
  },
};

My config file (works fine in beta 13, but not in 14)

/** @type {import('astro-i18next').AstroI18nextConfig} */
export default {
  namespaces: ["common", "footer", "nav"],
  defaultNamespace: "common",
  defaultLocale: "en",
  locales: ["en", "pt", "vi"],
  showDefaultLocale: true
};

My page

Path: src/pages/[lang]/index.astro

💡 The reason I made a path that way is precisely because it is not possible to use the generate command with showDefaultLocale set to true. It just doesn't extract anything, so the alternative was to create a folder with lang as param and manually set it inside the page (since this is a small project with only one page anyway)

---
import i18n from "i18next";

import MainLayout from "@layouts/MainLayout.astro";

// ....

export function getStaticPaths() {
  return [{ params: { lang: "en" } }, { params: { lang: "pt" } }, { params: { lang: "vi" } }];
}

const { lang } = Astro.params;
i18n.changeLanguage(lang as string);
---

<MainLayout>
  <p>{i18n.t('example')}</p>
  <!-- all contents -->
</MainLayout>
@yassinedoghri
Copy link
Owner

Hey @fmilioni, I guess you are on Windows, right?

@florian-lefebvre
Copy link
Contributor

Hey @yassinedoghri I can confirm this issue on Windows. The path generated is /D:/somepath instead of D:/somepath. https://github.com/unjs/pathe works well for path normalization across OSs (used in nuxt3)

@yassinedoghri yassinedoghri added the bug Something isn't working label Dec 4, 2022
@zogar1993
Copy link

+1 to having this issue on Windows. The proposed workaround works fine tho.

@fmilioni
Copy link
Author

Hey @fmilioni, I guess you are on Windows, right?

Sorry for late response, and yes, Windows 11. My project is located in D: partition.

yassinedoghri pushed a commit that referenced this issue Jan 8, 2023
# [1.0.0-beta.15](v1.0.0-beta.14...v1.0.0-beta.15) (2023-01-08)

### Bug Fixes

* add levels to Astro.global pattern and scripts' import statements ([9d88d79](9d88d79))
* remove trailing slash from localized path ([1998309](1998309)), closes [#77](#77)
* use fileURLToPath to normalize publicDir pathname accross operating systems ([3c07d6a](3c07d6a)), closes [#79](#79)
@github-actions
Copy link

github-actions bot commented Jan 8, 2023

🎉 This issue has been resolved in version 1.0.0-beta.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Silbad
Copy link

Silbad commented Jan 8, 2023

Hello,
Should the configuration be changed accordingly? I still have the bug on the beta 15 version...

/** @type {import('astro-i18next').AstroI18nextConfig} */
export default {
    defaultLocale: "fr",
    locales: ["fr", "en"],
    showDefaultLocale: true,
};

No issue on beta 13

AliLee0923 pushed a commit to AliLee0923/astro-i18N that referenced this issue Dec 2, 2023
# [1.0.0-beta.15](yassinedoghri/astro-i18next@v1.0.0-beta.14...v1.0.0-beta.15) (2023-01-08)

### Bug Fixes

* add levels to Astro.global pattern and scripts' import statements ([9d88d79](yassinedoghri/astro-i18next@9d88d79))
* remove trailing slash from localized path ([1998309](yassinedoghri/astro-i18next@1998309)), closes [#77](yassinedoghri/astro-i18next#77)
* use fileURLToPath to normalize publicDir pathname accross operating systems ([3c07d6a](yassinedoghri/astro-i18next@3c07d6a)), closes [#79](yassinedoghri/astro-i18next#79)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released on @beta
Projects
None yet
Development

No branches or pull requests

5 participants