2

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.

2
  • 1
    Since this appears to be a Firebase Hosting bug, I'd recommend reaching out to support. Can you also include your Firebase CLI version and the exact Accept-Language header being sent in the request when it's not working? Commented Aug 25, 2020 at 20:12
  • @MichaelBleigh The CLI version is 8.9.0, and the Accept-Language value is fr. I've also edited the question to include that information. I'll create a bug report in the near-time. Commented Aug 26, 2020 at 5:34

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi - I'm an engineer on Firebase Hosting - this is correct. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.