Language order not respected when using JS SDK

I’m using the JavaScript SDK to embed forms on a webapp.
All the forms have English texts by default and French-Canadian text as translations.

In the init function, I specify the language I want the form to show, either en-US or fr-CA.

I observed that when Feathery’s SDK makes the HTTP request to load the form, that request has a header Accept-Language with the language I specified,
but it also includes a list of languages that my device support.
The issue I observed is that when the list languages include a language that has a translation, it will use that language, even though it’s not the first on the list.

I tried the following options, en-US, en, en-CA and default, to have the SDK to load the default (english) language, but it does work.

For example, my phone is in English, but has French-Canadian as a second language. In the init function, when I specify en-US,
I can see that the SDK is using en-US,fr-CA in the Accept-Language header.
The HTTP request that loads the form is ignoring en-US and loads the French translations.

Hey there, taking a look into this! Would you mind sharing a link of your webapp where one is embedded?

That won’t be possible. It’s embedded in an Ionic/CapacitorJS app.

Here how we set the language:

 Feathery.init(environement.featherySDKKey, {
        userId: 'xxxx',
        language: 'en-US'
    });

When running that code on my phone I can see that the Accept-Language header contains en-US,en,fr,en-CA,fr-CA.

The correct way here to set the language in the JS embed would be just the 2 letter code ‘en’.
The 2 letter codes here would be the form languages while the rest are from your device languages.

Is the issue only isolated on your Ionic/CapacitorJS app, or does it also load the language wrongly for a regular webpage embed (desktop and mobile) ?

I tried with only en, but the SDK always add the additional languages before sending the HTTP request that loads the form.

It looks like the SDK is taking the language parameter from the init function and add the values from global variable: navigator.languages.

The issue is also present when running the Ionic/CapacitorJS app locally (it runs like a webapp).

Is it tested on a regular webpage embed? Can you share a test link?

Yes, when it’s running locally, it’s like any webapp.

The forms are not accessible directly, you need an account and go through a complex process.
I could create a special version and host it somewhere. But I can’t share the link publicly. I will email it to you once it’s ready.

That’ll be a big help in checking. Let’s follow this over email once its replicated.