Max
Max

Reputation: 788

Firebase Hosting i18n rewrites not working

Firebase has recently(Aug 20, 2020) announced support for i18n rewrites.

My web app has two locales: English and French, so I've put the French content under public/localized/fr/ and the English content under public. Then, I added the following to firebase.json:

{
  "hosting": {
    ...
  },
  "i18n": {
    "root": "/localized"
  }
}

However, if I set French as my primary language in the browser settings(and the value of the Accept-Language header is fr), the website still serves the English content.

I have created an MCVE: https://github.com/Jaimies/firebase-hosting-i18n-rewrites-demo.


I'm using Firebase CLI version 8.9.0.

Update: I filed a bug report to Firebase support.
Update 2: I got a response from Firebase support, see this answer.

Upvotes: 2

Views: 1210

Answers (1)

Max
Max

Reputation: 788

The i18n attribute in your firebase.json is placed at the root, while it should be inside the hosting attribute. So you have to change firebase.json to the following:

{
 "hosting": {
    ...
    "i18n": {
     "root": "/localized"
   }
 }
}

Thanks to Eder from Firebase support for pointing this issue out.

Upvotes: 2

Related Questions