Skip to content

Localization does not work for sv (Swedish) in Edge (but does in Chrome that reports sv-SE). #13689

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

Closed
sictransit opened this issue Jul 7, 2021 · 7 comments · Fixed by #13696
Labels

Comments

@sictransit
Copy link

Configuration:

Steps to reproduce the problem:

  1. Open the demo viewer in Chrome
  2. Open the demo viewer in Edge

What is the expected behavior?

The viewer should be localized, i.e. translated to Swedish.

What went wrong? (add screenshot)

The viewer is translated to Swedish in Chrome, but not in Edge.

Request headers:

  • Chrome: Accept-Language: sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7
  • Edge: Accept-Language: sv,en;q=0.9,en-GB;q=0.8,en-US;q=0.7

The problem seems to be that the l10n folder does not contain an sv folder, but only an sv-SE.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Jul 7, 2021

This does seem like more a Microsoft Edge issue, rather than a PDF.js one.
(In my testing, both Firefox Nightly 91.0a1 and Chrome Beta 92.0.4515.81 work just fine as-is.)

The problem seems to be that the l10n folder does not contain an sv folder, but only an sv-SE.

That's how things have been since the very beginning of this project, hence I'm not sure that we necessarily want to make any changes here (since that may cause regressions elsewhere). There's basically three possible ways to address this:

  • Copying the sv-SE folder to a sv folder. This is undesirable for two reasons, first of all it'd unnecessarily increase the size of the viewer and secondly it'd add unwanted maintenance overhead w.r.t. the l10n-folder.
  • Renaming the sv-SE folder to sv instead. This has, as already mentioned, the potential to basically fix things for one set of users while breaking things for another set of users; hence this feels problematic as well. Edit: This could even end up breaking localization in Firefox, so it definitely doesn't seem acceptable.
  • Configuring your browser to also accept an "sv-SE" locale (which at least in e.g. Firefox can be very easily done). This would definitely seem like the preferred solution to the issue.

@sictransit
Copy link
Author

I agree that this is primarliy an Edge issue. However, on a few random machines with different Edge versions I've tried, Accept-Language is only sv (and does not include sv-SE).

The main question might be whether to support the default Edge behaviour in pdf.js or not, as average users will not configure their browser to emit another language/region. Those who are able to, probably prefer English to Swedish anyway.

For me, this is not an issue at all. I just wanted to let you know. If I bother fixing it, I'll probably just copy the folder to solve the minor problem.

@Snuffleupagus
Copy link
Collaborator

I suppose that another possible option could be to try and fixup these "incomplete" language codes, however I don't know if this is a desirable change (for the PDF.js project) and more importantly if this is actually a specification compliant way of handling language codes; e.g. something like master...Snuffleupagus:issue-13689

@sictransit
Copy link
Author

That would of course solve the problem, but as you say, is it the proper way of handling the issue and is it is a desirable change in PDF.js? I can't really tell.

It is weird that Edge behaves differently than other browsers. There is also very little information/discussion on this topic. I spent an hour on google-fu and didn't find anything useful.

@nachoalcazar
Copy link

Same problem with Spanish:

this works OK

image

(this NO WORKS)

image

Wouldn't it be a good solution to include a generic folder 'es', 'sv' ... with the generality of the language and thus avoid these problems?

image

@timvandermeij
Copy link
Contributor

The PR above should have fixed this if I look at https://github.com/mozilla/pdf.js/pull/13696/files#diff-51a0dde82a8d1b56568a0375e28fccde02bc154a89b3cb92f34f090b5219b62aR100. Are you sure you're using the latest PDF.js version?

@nachoalcazar
Copy link

The PR above should have fixed this if I look at https://github.com/mozilla/pdf.js/pull/13696/files#diff-51a0dde82a8d1b56568a0375e28fccde02bc154a89b3cb92f34f090b5219b62aR100. Are you sure you're using the latest PDF.js version?

Yes, was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants