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

how to add the lang folder to the baseLanguage. #13

Closed
preetamslot opened this issue Aug 2, 2022 · 6 comments · Fixed by #15
Closed

how to add the lang folder to the baseLanguage. #13

preetamslot opened this issue Aug 2, 2022 · 6 comments · Fixed by #15

Comments

@preetamslot
Copy link

Hi,
my current page structure is like this:

[lang]
 - about.astro
 - news.astro
 - contact.astro
 - index.astro
index.astro (homepage default lang or redirect to user locale)

So except for the homepage in baseLanguage I always add the [lang] to every URL.
How can I do this?

(in my setup the HeadHrefLangs & LanguageSelector won't work.)

I would like not to have a structure like this:

[lang]
 - about.astro
 - news.astro
 - contact.astro
 - index.astro
about.astro
news.astro
contact.astro
index.astro

Thanks!

@yassinedoghri
Copy link
Owner

Hey, thanks for reporting the issue!

This is a concern I've had since the beginning and haven't figured out a way to automate it yet!

I've thought about generating the language files during build time but there are some limitations with Astro's integration API. I'll have to take some time in finding my way around them.

I'll try working on it this weekend and post my progress here 🙂

@yassinedoghri
Copy link
Owner

Alright, I've thought about this and I think I have a solution I can work with.

IMO, the best Developer Experience is not to have to think about this at all by having a folder structure as you would in any non localized Astro project like so:

pages
|-- about.astro
|-- news.astro
|-- contact.astro
└-- index.astro

Also, you shouldn't think about switching the language with i18next.changeLanguage(i18next.options.supportedLngs[0]);.

👉 astro-i18next would do the heavy lifting on both language files and language switching logic.

This would be possible using a CLI command that generates the code for you:

astro-i18next generate

☝️ This command, would produce:

pages
├-- [lang]
|    |-- about.astro
|    |-- news.astro
|    |-- contact.astro
|    └-- index.astro
|-- about.astro
|-- news.astro
|-- contact.astro
└-- index.astro

This would be possible in 2 steps:

  1. Create the astro-i18next generate command, responsible of going through the pages folder and generating the [lang] folder with the language switch logic. Now that I think of it, it may be easier (best?) to generate each supported locale in a different folder instead of the dynamic routes for starters.
    --> code injection and astro files creation is easily done using the @astrojs/compiler

  2. Call the astro-i18next generate command during build time to have localized pages and all language switching logic included with the build.

👉 I've started implementing this, and will work on it further next weekend.

@preetamslot
Copy link
Author

preetamslot commented Aug 10, 2022

Sounds good!
But what if the structure is deeper like with a blog collection?

pages
├-- news
|    |-- [...slug].astro
|    |-- [page].astro
|-- about.astro
|-- [...page].astro
|-- contact.astro
└-- index.astro

Then the getStaticPaths for a news item or a dynamic page can get more complicated.
I use NetlifyCms where all translations are stored in a single mdx file but not all fields are translated.
So on every [lang] route, I merge the language to access all the fields.

How would the astro-i18next generate know what to do?

[lang] route

export async function getStaticPaths () {
const allNews= await Astro.glob("../../../../data/news/*.mdx");
 
  let params = [];

  return await Promise.all(
    locales
      .filter((locale) => locale !== i18next.options.supportedLngs[0])
      .map(async (lang) => {
        const news = getTranslation(allNews, lang) 
        news.map((newsItem, index) => {
          params.push({
            params: { lang: lang, slug: newsItem.slug },
            props: { content: newsItem},
          });
        });
        return params;
      })
  );
}

original route

export async function getStaticPaths () {
const allNews= await Astro.glob("../../../data/news/*.mdx");
 
  let params = [];

  return await Promise.all(
    locales
      .filter((locale) => locale == i18next.options.supportedLngs[0])
      .map(async (lang) => {
        const news = getTranslation(allNews, lang) 
        news.map((newsItem, index) => {
          params.push({
            params: {slug: newsItem.slug },
            props: { content: newsItem},
          });
        });
        return params;
      })
  );
}

Thanks!

@yassinedoghri
Copy link
Owner

Sounds good! But what if the structure is deeper like with a blog collection?
[...]
How would the astro-i18next generate know what to do?

That's the catch when trying to have a dynamic route for languages! So, first, the easiest thing to do is to discard using getStaticPaths to declare localized routes.

Instead, astro-i18next generate would generate each declared locale in its own folder. For example, let's say we have 3 languages (fr, es, en), english being the default language:

# base pages translated using the `t()` function / `<Trans />` component
pages
├-- news
|    |-- [...slug].astro
|    |-- [page].astro
|-- about.astro
|-- [...page].astro
|-- contact.astro
└-- index.astro

astro-i18next generate would generate the following at build time:

pages
├-- fr
|    ├-- news
|    |    |-- [...slug].astro
|    |    └-- [page].astro
|    |-- about.astro
|    |-- [...page].astro
|    |-- contact.astro
|    └-- index.astro
├-- es
|    ├-- news
|    |    |-- [...slug].astro
|    |    └-- [page].astro
|    |-- about.astro
|    |-- [...page].astro
|    |-- contact.astro
|    └-- index.astro
├-- news
|    |-- [...slug].astro
|    └-- [page].astro
|-- about.astro
|-- [...page].astro
|-- contact.astro
└-- index.astro

And would add the following lines to the pages' frontmatter so as not to touch to the getStaticPaths logic:

---
import i18next from "i18next";
 
i18next.changeLanguage(<language code goes here>);

[...]
--- 

I think that in terms of DX, this is the best. Apart from having to replace the text with translation keys, you wouldn't have to do anything else.

And eventually, this also unlocks some other cool features, like what if we'd like to translate the routes? astro-i18next generate could also replace the file names for each language.

Anyways, haven't worked out the details yet, hopefully I can get something working this weekend 🤞

yassinedoghri added a commit that referenced this issue Aug 15, 2022
- use yargs to build documented command
- use typescript compiler API to parse frontmatter & inject
locale change
- update dependencies to latest

closes #13
yassinedoghri added a commit that referenced this issue Aug 15, 2022
- use yargs to build documented command
- use typescript compiler API to parse frontmatter & inject
locale change
- update dependencies to latest

closes #13
yassinedoghri added a commit that referenced this issue Aug 15, 2022
- use yargs to build documented command
- use typescript compiler API to parse frontmatter & inject
locale change
- update dependencies to latest

closes #13
yassinedoghri added a commit that referenced this issue Aug 21, 2022
- use yargs to build documented command
- use typescript compiler API to parse frontmatter & inject
locale change
- update dependencies to latest

closes #13
yassinedoghri added a commit that referenced this issue Aug 21, 2022
- use yargs to build documented command
- use typescript compiler API to parse frontmatter & inject
locale change
- update dependencies to latest

closes #13
yassinedoghri added a commit that referenced this issue Aug 21, 2022
- use yargs to build documented command
- use typescript compiler API to parse frontmatter & inject
locale change
- update dependencies to latest

closes #13
yassinedoghri pushed a commit that referenced this issue Aug 21, 2022
# [1.0.0-beta.4](v1.0.0-beta.3...v1.0.0-beta.4) (2022-08-21)

### Bug Fixes

* add depth level to relative import declarations ([02ddb76](02ddb76))
* **example:** add isCurrentPath function comparing current url to localized path ([ee90afb](ee90afb))
* **language-selector:** replace country-code-to-flag-emoji dependency with locale-emoji ([6aee21d](6aee21d)), closes [#14](#14)

### Features

* allow using i18next plugins directly in the config ([114ccd7](114ccd7))
* **cli:** add generate command to create localized astro pages ([17982cf](17982cf)), closes [#13](#13)
* **cli:** add success feedback to generate command + add generated filepaths with verbose ([9e3d4f5](9e3d4f5))
* move astro-i18next config in a standalone file to load it for CLI commands ([bdf2408](bdf2408))

### BREAKING CHANGES

* config is now a standalone file + some property names
have changed for better clarity and consistency

- `baseLocale` is now `defaultLanguage`
- `supportedLocales` is now `supportedLanguages``
* `baseLanguage` is now `baseLocale` in config options
@github-actions
Copy link

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

The release is available on:

Your semantic-release bot 📦🚀

@yassinedoghri
Copy link
Owner

As the github-actions bot said, 1.0.0-beta.4 was just released with the first version of the npx astro-i18next generate command.

I had a blast working on this, learned a lot! Thanks for your feedback @preetamslot, I've added you as a contributor in the README.md. Hope you don't mind 🙂

@yassinedoghri yassinedoghri added this to the v1.0.0 milestone Jan 19, 2023
AliLee0923 pushed a commit to AliLee0923/astro-i18N that referenced this issue Dec 2, 2023
# [1.0.0-beta.4](yassinedoghri/astro-i18next@v1.0.0-beta.3...v1.0.0-beta.4) (2022-08-21)

### Bug Fixes

* add depth level to relative import declarations ([02ddb76](yassinedoghri/astro-i18next@02ddb76))
* **example:** add isCurrentPath function comparing current url to localized path ([ee90afb](yassinedoghri/astro-i18next@ee90afb))
* **language-selector:** replace country-code-to-flag-emoji dependency with locale-emoji ([6aee21d](yassinedoghri/astro-i18next@6aee21d)), closes [#14](yassinedoghri/astro-i18next#14)

### Features

* allow using i18next plugins directly in the config ([114ccd7](yassinedoghri/astro-i18next@114ccd7))
* **cli:** add generate command to create localized astro pages ([17982cf](yassinedoghri/astro-i18next@17982cf)), closes [#13](yassinedoghri/astro-i18next#13)
* **cli:** add success feedback to generate command + add generated filepaths with verbose ([9e3d4f5](yassinedoghri/astro-i18next@9e3d4f5))
* move astro-i18next config in a standalone file to load it for CLI commands ([bdf2408](yassinedoghri/astro-i18next@bdf2408))

### BREAKING CHANGES

* config is now a standalone file + some property names
have changed for better clarity and consistency

- `baseLocale` is now `defaultLanguage`
- `supportedLocales` is now `supportedLanguages``
* `baseLanguage` is now `baseLocale` in config options
github-actions bot pushed a commit to jeffwcx/astro-i18next that referenced this issue Dec 4, 2024
# 1.0.0 (2024-12-04)

### Bug Fixes

* add depth level to relative import declarations ([02ddb76](02ddb76))
* add isFileHidden function + tests to prevent missing hidden files ([7dcd0aa](7dcd0aa))
* add levels to Astro.global pattern and scripts' import statements ([9d88d79](9d88d79))
* add levels to relative path in script tag ([1203d42](1203d42)), closes [yassinedoghri#129](https://github.com/jeffwcx/astro-i18next/issues/129)
* add missing `script` to regex in resolveRelativePathsLevel ([9288efe](9288efe)), closes [yassinedoghri#129](https://github.com/jeffwcx/astro-i18next/issues/129)
* **build:** remove components and utils from build + set components export to src ([bb7ab0f](bb7ab0f)), closes [yassinedoghri#18](https://github.com/jeffwcx/astro-i18next/issues/18)
* **cli:** filter out any file other than .astro files for generate ([c34fa07](c34fa07))
* **example:** add isCurrentPath function comparing current url to localized path ([ee90afb](ee90afb))
* expect locales folder to be in astro's publicDir config by default ([ec72ff3](ec72ff3)), closes [yassinedoghri#64](https://github.com/jeffwcx/astro-i18next/issues/64)
* **generate:** ignore any directories/files that begin with an underscore ([a7e6f08](a7e6f08)), closes [yassinedoghri#43](https://github.com/jeffwcx/astro-i18next/issues/43)
* **generate:** inject changeLanguage statement after imports and before frontmatter logic ([4d74e0b](4d74e0b)), closes [yassinedoghri#23](https://github.com/jeffwcx/astro-i18next/issues/23)
* **generate:** replace isLocale check with user defined locales to prevent nested folders generation ([a598e2e](a598e2e)), closes [yassinedoghri#56](https://github.com/jeffwcx/astro-i18next/issues/56)
* get astro pages' full paths using fdir's withFullPaths instead of withRelativePaths ([92a5178](92a5178)), closes [yassinedoghri#135](https://github.com/jeffwcx/astro-i18next/issues/135)
* handle localizePath trailing slash depending on astro's trailingSlash config ([880666c](880666c)), closes [yassinedoghri#119](https://github.com/jeffwcx/astro-i18next/issues/119)
* **i18next-server:** load locale files synchronously ([e7892e2](e7892e2))
* import localizeUrl in HeadHrefLangs from index for access to astro-i18next runtime config ([5e3b96c](5e3b96c)), closes [yassinedoghri#65](https://github.com/jeffwcx/astro-i18next/issues/65)
* include LanguageSelector component to release files ([efa1961](efa1961))
* **language-selector:** replace country-code-to-flag-emoji dependency with locale-emoji ([6aee21d](6aee21d)), closes [yassinedoghri#14](https://github.com/jeffwcx/astro-i18next/issues/14)
* **plugins:** normalize named imports to call in i18next's use function ([6928ddc](6928ddc)), closes [yassinedoghri#38](https://github.com/jeffwcx/astro-i18next/issues/38)
* remove trailing slash from localized path ([1998309](1998309)), closes [yassinedoghri#77](https://github.com/jeffwcx/astro-i18next/issues/77)
* replace @proload/plugin-typescript with @proload/plugin-tsm ([6f639ee](6f639ee))
* replace language-flag-colors with country-code-to-flag-emoji dependency ([7d4d408](7d4d408))
* reset iso-639-1 and locale-emoji as dependencies ([b2863d7](b2863d7)), closes [yassinedoghri#32](https://github.com/jeffwcx/astro-i18next/issues/32)
* resolve astroFileFullPath to extract relative astroFilePath on Windows ([c23cd27](c23cd27)), closes [yassinedoghri#135](https://github.com/jeffwcx/astro-i18next/issues/135)
* Rollup failed to resolve import 'types' ([yassinedoghri#33](https://github.com/jeffwcx/astro-i18next/issues/33)) ([2807989](2807989))
* take astro base path into account when using localizePath or localizeUrl functions ([5c35eaf](5c35eaf)), closes [yassinedoghri#27](https://github.com/jeffwcx/astro-i18next/issues/27)
* **trans component:** import utility functions from index ([eea0d5d](eea0d5d))
* type definitions for exported astro components ([bb60949](bb60949)), closes [yassinedoghri#18](https://github.com/jeffwcx/astro-i18next/issues/18)
* update package.json's exports value ([86d7cf9](86d7cf9))
* update publish workflow to include bundled package in dist ([5428dc3](5428dc3))
* update types import to relative ([yassinedoghri#58](https://github.com/jeffwcx/astro-i18next/issues/58)) ([44a5422](44a5422))
* update utils path to relative in Trans component ([c767fe3](c767fe3))
* use fileURLToPath to normalize publicDir pathname accross operating systems ([3c07d6a](3c07d6a)), closes [yassinedoghri#79](https://github.com/jeffwcx/astro-i18next/issues/79)
* use unjs/pathe to resolve cross OS public path ([ad1d24f](ad1d24f)), closes [yassinedoghri#105](https://github.com/jeffwcx/astro-i18next/issues/105)
* use unjs/pathe to resolve generated localized files paths across OS ([da80a8d](da80a8d)), closes [yassinedoghri#135](https://github.com/jeffwcx/astro-i18next/issues/135)
* **workflow:** download bundle artifact into dist path to include it into package ([3fb5a78](3fb5a78))

### Features

* add astro integration --> initialize i18next upon astro:config:setup ([78ec744](78ec744))
* add HeadHrefLangs component + localizeUrl util function ([cd4095e](cd4095e))
* add i18next namespaces + validate config before processing it ([10b40cc](10b40cc))
* add LanguageSelector component to select language from supported locales ([ad3fe2a](ad3fe2a))
* add option to show the default locale in the url ([yassinedoghri#51](https://github.com/jeffwcx/astro-i18next/issues/51)) ([ea939db](ea939db)), closes [yassinedoghri#54](https://github.com/jeffwcx/astro-i18next/issues/54)
* add showFlag attribute to LanguageSelector to display the flag emoji or not ([a4b2f98](a4b2f98))
* add support for route translations ([db5200b](db5200b)), closes [yassinedoghri#50](https://github.com/jeffwcx/astro-i18next/issues/50) [yassinedoghri#29](https://github.com/jeffwcx/astro-i18next/issues/29)
* add Trans component to interpolate translation strings with its contents ([14ff1bd](14ff1bd))
* add utility function to localize path + improve components and overall DX ([d230f00](d230f00))
* Allow astro versions greater than 1.0.0 as peer dependency. ([0205d41](0205d41))
* allow implicit key for <Trans> when omitting i18nKey prop ([ff14354](ff14354)), closes [yassinedoghri#53](https://github.com/jeffwcx/astro-i18next/issues/53)
* allow passing functions to i18next init ([ed7c721](ed7c721))
* allow using i18next plugins directly in the config ([114ccd7](114ccd7))
* **cli:** add generate command to create localized astro pages ([17982cf](17982cf)), closes [yassinedoghri#13](https://github.com/jeffwcx/astro-i18next/issues/13)
* **cli:** add success feedback to generate command + add generated filepaths with verbose ([9e3d4f5](9e3d4f5))
* **language-selector:** add languageMapping prop to rename languages of choice ([20d94e4](20d94e4)), closes [yassinedoghri#116](https://github.com/jeffwcx/astro-i18next/issues/116)
* load translation resources automatically + add example website ([48dd98e](48dd98e))
* make base path for i18next resources configurable ([4e4b057](4e4b057))
* move astro-i18next config in a standalone file to load it for CLI commands ([bdf2408](bdf2408))
* **plugins:** set i18next plugins config for both server and client side setups ([5ddb1c7](5ddb1c7)), closes [yassinedoghri#68](https://github.com/jeffwcx/astro-i18next/issues/68)
* prefix language name with language flag emoji using language-flag-colors ([7e09d93](7e09d93))
* simplified API + instanciate i18next both in server and client side ([ed44510](ed44510)), closes [yassinedoghri#57](https://github.com/jeffwcx/astro-i18next/issues/57) [yassinedoghri#46](https://github.com/jeffwcx/astro-i18next/issues/46) [yassinedoghri#37](https://github.com/jeffwcx/astro-i18next/issues/37)

### Reverts

* **i18next-peer:** reset i18next as package dependency ([7906e19](7906e19)), closes [yassinedoghri#131](https://github.com/jeffwcx/astro-i18next/issues/131)

### BREAKING CHANGES

* - defaultLanguage is now defaultLocale
- supportedLanguages is now locales
- i18next config is now split into two configs: `i18nextServer`
and `i18nextClient`
* config is now a standalone file + some property names
have changed for better clarity and consistency

- `baseLocale` is now `defaultLanguage`
- `supportedLocales` is now `supportedLanguages``
* `baseLanguage` is now `baseLocale` in config options
* rename i18nextConfig to i18next in config + remove className and baseLanguage props
for LanguageSelector
github-actions bot pushed a commit to jeffwcx/astro-i18next that referenced this issue Dec 4, 2024
# 1.0.0-beta.1 (2024-12-04)

### Bug Fixes

* add depth level to relative import declarations ([02ddb76](02ddb76))
* add isFileHidden function + tests to prevent missing hidden files ([7dcd0aa](7dcd0aa))
* add levels to Astro.global pattern and scripts' import statements ([9d88d79](9d88d79))
* add levels to relative path in script tag ([1203d42](1203d42)), closes [yassinedoghri#129](https://github.com/jeffwcx/astro-i18next/issues/129)
* add missing `script` to regex in resolveRelativePathsLevel ([9288efe](9288efe)), closes [yassinedoghri#129](https://github.com/jeffwcx/astro-i18next/issues/129)
* **build:** remove components and utils from build + set components export to src ([bb7ab0f](bb7ab0f)), closes [yassinedoghri#18](https://github.com/jeffwcx/astro-i18next/issues/18)
* **cli:** filter out any file other than .astro files for generate ([c34fa07](c34fa07))
* **example:** add isCurrentPath function comparing current url to localized path ([ee90afb](ee90afb))
* expect locales folder to be in astro's publicDir config by default ([ec72ff3](ec72ff3)), closes [yassinedoghri#64](https://github.com/jeffwcx/astro-i18next/issues/64)
* **generate:** ignore any directories/files that begin with an underscore ([a7e6f08](a7e6f08)), closes [yassinedoghri#43](https://github.com/jeffwcx/astro-i18next/issues/43)
* **generate:** inject changeLanguage statement after imports and before frontmatter logic ([4d74e0b](4d74e0b)), closes [yassinedoghri#23](https://github.com/jeffwcx/astro-i18next/issues/23)
* **generate:** replace isLocale check with user defined locales to prevent nested folders generation ([a598e2e](a598e2e)), closes [yassinedoghri#56](https://github.com/jeffwcx/astro-i18next/issues/56)
* get astro pages' full paths using fdir's withFullPaths instead of withRelativePaths ([92a5178](92a5178)), closes [yassinedoghri#135](https://github.com/jeffwcx/astro-i18next/issues/135)
* handle localizePath trailing slash depending on astro's trailingSlash config ([880666c](880666c)), closes [yassinedoghri#119](https://github.com/jeffwcx/astro-i18next/issues/119)
* **i18next-server:** load locale files synchronously ([e7892e2](e7892e2))
* import localizeUrl in HeadHrefLangs from index for access to astro-i18next runtime config ([5e3b96c](5e3b96c)), closes [yassinedoghri#65](https://github.com/jeffwcx/astro-i18next/issues/65)
* include LanguageSelector component to release files ([efa1961](efa1961))
* **language-selector:** replace country-code-to-flag-emoji dependency with locale-emoji ([6aee21d](6aee21d)), closes [yassinedoghri#14](https://github.com/jeffwcx/astro-i18next/issues/14)
* **plugins:** normalize named imports to call in i18next's use function ([6928ddc](6928ddc)), closes [yassinedoghri#38](https://github.com/jeffwcx/astro-i18next/issues/38)
* remove trailing slash from localized path ([1998309](1998309)), closes [yassinedoghri#77](https://github.com/jeffwcx/astro-i18next/issues/77)
* replace @proload/plugin-typescript with @proload/plugin-tsm ([6f639ee](6f639ee))
* replace language-flag-colors with country-code-to-flag-emoji dependency ([7d4d408](7d4d408))
* reset iso-639-1 and locale-emoji as dependencies ([b2863d7](b2863d7)), closes [yassinedoghri#32](https://github.com/jeffwcx/astro-i18next/issues/32)
* resolve astroFileFullPath to extract relative astroFilePath on Windows ([c23cd27](c23cd27)), closes [yassinedoghri#135](https://github.com/jeffwcx/astro-i18next/issues/135)
* Rollup failed to resolve import 'types' ([yassinedoghri#33](https://github.com/jeffwcx/astro-i18next/issues/33)) ([2807989](2807989))
* take astro base path into account when using localizePath or localizeUrl functions ([5c35eaf](5c35eaf)), closes [yassinedoghri#27](https://github.com/jeffwcx/astro-i18next/issues/27)
* **trans component:** import utility functions from index ([eea0d5d](eea0d5d))
* type definitions for exported astro components ([bb60949](bb60949)), closes [yassinedoghri#18](https://github.com/jeffwcx/astro-i18next/issues/18)
* update package.json's exports value ([86d7cf9](86d7cf9))
* update publish workflow to include bundled package in dist ([5428dc3](5428dc3))
* update types import to relative ([yassinedoghri#58](https://github.com/jeffwcx/astro-i18next/issues/58)) ([44a5422](44a5422))
* update utils path to relative in Trans component ([c767fe3](c767fe3))
* use fileURLToPath to normalize publicDir pathname accross operating systems ([3c07d6a](3c07d6a)), closes [yassinedoghri#79](https://github.com/jeffwcx/astro-i18next/issues/79)
* use unjs/pathe to resolve cross OS public path ([ad1d24f](ad1d24f)), closes [yassinedoghri#105](https://github.com/jeffwcx/astro-i18next/issues/105)
* use unjs/pathe to resolve generated localized files paths across OS ([da80a8d](da80a8d)), closes [yassinedoghri#135](https://github.com/jeffwcx/astro-i18next/issues/135)
* **workflow:** download bundle artifact into dist path to include it into package ([3fb5a78](3fb5a78))

### Features

* add astro integration --> initialize i18next upon astro:config:setup ([78ec744](78ec744))
* add HeadHrefLangs component + localizeUrl util function ([cd4095e](cd4095e))
* add i18next namespaces + validate config before processing it ([10b40cc](10b40cc))
* add LanguageSelector component to select language from supported locales ([ad3fe2a](ad3fe2a))
* add option to show the default locale in the url ([yassinedoghri#51](https://github.com/jeffwcx/astro-i18next/issues/51)) ([ea939db](ea939db)), closes [yassinedoghri#54](https://github.com/jeffwcx/astro-i18next/issues/54)
* add showFlag attribute to LanguageSelector to display the flag emoji or not ([a4b2f98](a4b2f98))
* add support for route translations ([db5200b](db5200b)), closes [yassinedoghri#50](https://github.com/jeffwcx/astro-i18next/issues/50) [yassinedoghri#29](https://github.com/jeffwcx/astro-i18next/issues/29)
* add Trans component to interpolate translation strings with its contents ([14ff1bd](14ff1bd))
* add utility function to localize path + improve components and overall DX ([d230f00](d230f00))
* Allow astro versions greater than 1.0.0 as peer dependency. ([0205d41](0205d41))
* allow implicit key for <Trans> when omitting i18nKey prop ([ff14354](ff14354)), closes [yassinedoghri#53](https://github.com/jeffwcx/astro-i18next/issues/53)
* allow passing functions to i18next init ([ed7c721](ed7c721))
* allow using i18next plugins directly in the config ([114ccd7](114ccd7))
* **cli:** add generate command to create localized astro pages ([17982cf](17982cf)), closes [yassinedoghri#13](https://github.com/jeffwcx/astro-i18next/issues/13)
* **cli:** add success feedback to generate command + add generated filepaths with verbose ([9e3d4f5](9e3d4f5))
* **language-selector:** add languageMapping prop to rename languages of choice ([20d94e4](20d94e4)), closes [yassinedoghri#116](https://github.com/jeffwcx/astro-i18next/issues/116)
* load translation resources automatically + add example website ([48dd98e](48dd98e))
* make base path for i18next resources configurable ([4e4b057](4e4b057))
* move astro-i18next config in a standalone file to load it for CLI commands ([bdf2408](bdf2408))
* **plugins:** set i18next plugins config for both server and client side setups ([5ddb1c7](5ddb1c7)), closes [yassinedoghri#68](https://github.com/jeffwcx/astro-i18next/issues/68)
* prefix language name with language flag emoji using language-flag-colors ([7e09d93](7e09d93))
* simplified API + instanciate i18next both in server and client side ([ed44510](ed44510)), closes [yassinedoghri#57](https://github.com/jeffwcx/astro-i18next/issues/57) [yassinedoghri#46](https://github.com/jeffwcx/astro-i18next/issues/46) [yassinedoghri#37](https://github.com/jeffwcx/astro-i18next/issues/37)

### Reverts

* **i18next-peer:** reset i18next as package dependency ([7906e19](7906e19)), closes [yassinedoghri#131](https://github.com/jeffwcx/astro-i18next/issues/131)

### BREAKING CHANGES

* - defaultLanguage is now defaultLocale
- supportedLanguages is now locales
- i18next config is now split into two configs: `i18nextServer`
and `i18nextClient`
* config is now a standalone file + some property names
have changed for better clarity and consistency

- `baseLocale` is now `defaultLanguage`
- `supportedLocales` is now `supportedLanguages``
* `baseLanguage` is now `baseLocale` in config options
* rename i18nextConfig to i18next in config + remove className and baseLanguage props
for LanguageSelector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants