How to change the default language ? #43
-
Hi, I'm trying to build a blog based on ScrewFast template, a blog that is meant to be only in French, so I'd like to make the French language by default AND to have URLs without /fr in the path. I searched everywhere in the files, modified a number of parameters, but I can't get rid of those /fr and make the website work. PS: BTW, there is a small glitch with the dropdown menu, the language box appears on the far-right instead of under the button. But that's secondary, as I will probably remove that button to only have a single language. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Hi, @GoustiFruit ! You need to modify the i18n: {
defaultLocale: "en",
locales: ["en", "fr"],
fallback: {
fr: "en",
},
routing: {
prefixDefaultLocale: false,
},
}, As for the dropdown menu, I didn't notice anything strange. Indeed, they are a bit to the right, aligned with the chevron icon. Here are the screenshots for reference. |
Beta Was this translation helpful? Give feedback.
-
@GoustiFruit If I understand correctly, you want to have the whole site in French, without any other locales. So we need to swap the French and English locales, and remove the latter. In i18n: {
defaultLocale: "en",
locales: ["en", "fr"],
fallback: {
fr: "en",
},
routing: {
prefixDefaultLocale: false,
},
},
...
// And from sitemap
i18n: {
defaultLocale: "en",
locales: {
en: "en",
fr: "fr",
},
},
} In ---
//Import relevant dependencies
import ThemeIcon from "../ThemeIcon.astro";
import NavLink from "../ui/links/NavLink.astro";
import Authentication from "./Authentication.astro";
import frStrings from "@/utils/fr/navigation.ts";
import BrandLogo from "../BrandLogo.astro";
// Select the correct translation based on the page's lang prop:
const strings = frStrings;
const homeUrl = "/";
---
<!-- We removed LanguagePicker, enStrings and adjusted the check of lang prop --> Same with ---
// Import the necessary dependencies
import FooterSocialLink from "../ui/links/FooterSocialLink.astro";
import EmailFooterInput from "../ui/forms/input/EmailFooterInput.astro";
import frStrings from "@/utils/fr/navigation.ts";
import Icon from "../ui/icons/Icon.astro";
import BrandLogo from "@/components/BrandLogo.astro";
import { SITE } from "@/data_files/constants";
// Select the correct translation based on the page's lang prop:
const strings = frStrings;
// Define the variables that will be used in this component
const sectionThreeTitle: string = "Rester à jour";
const sectionThreeContent: string = "Restez informé des derniers outils et des offres exclusives.";
const crafted: string = "Fabriqué par";
--- In const navBarLinks = [
{ name: "Accueil", url: "/" },
{ name: "Produits", url: "/products" },
... That should be it. There are probably more components where we check for locale, eg. And either move all French directories up, and remove English ones, or remove French and edit English. I will think how we can make it easier to maintain, if developers need only one default language. Please come back to confirm if it worked for you or not. |
Beta Was this translation helpful? Give feedback.
I've created a separate branch with a monolingual language setup. You can use this branch instead of the main one:
https://github.com/mearashadowfax/ScrewFast/tree/monolingual-site