Internal Server Error when translating into a candidate language



Mozilla Developer Network
9 months ago
8 months ago


(Reporter: jwhitlock, Assigned: safwan)




(Whiteboard: [specification][type:bug])



9 months ago
What did you do?
Bulgarian (bg) was added to CANDIDATE_LANGUAGES, and is enabled on MDN's staging server (last entry):

It appears in the list of possible languages for translation:$locales

What happened?
When Bulgarian is selected, an Internal Server Error occurs

What should have happened?
The translation interface should appear

Is there anything else we should know?
Tracked in Sentry:

Error is "KeyError: u'bg'"

Last part of traceback:

  File "kuma/wiki/views/", line 261, in translate
    language = language_mapping[document_locale.lower()]

The language_mapping does not include the candidate languages:


9 months ago
See Also: → bug 1339948, bug 1265891
Severity: normal → enhancement
Keywords: in-triage

Comment 1

9 months ago
@jwhitlock How do you have enabled "bg" in staging server?
Have you Added it to MDN_LANGUAGES setting file?
Flags: needinfo?(jwhitlock)

Comment 2

9 months ago
No, this is enabled by recent code from this year, adding a CANDIDATE_LANGUAGES item to settings:

There's a function enable_candidate_languages() that updates settings to enable the candidate languages:

This is done on the staging server when kuma/settings/ is loaded:

The language_mapping has not been updated to be aware of CANDIDATE_LANGUAGES:
Flags: needinfo?(jwhitlock)

Comment 3

8 months ago
Proposed PR:
Assignee: nobody → safwan.rahman15

Comment 4

8 months ago
Commits pushed to master at
[Bug 1340003] Internal Server Error when translating into a candidate language
Merge pull request #4155 from safwanrahman/fix-candidate-language

[Bug 1340003] Internal Server Error when translating into a candidate language

Comment 5

8 months ago
Commits pushed to master at
bug 1340003: Use settings.LANGUAGES, path parsing

In locale_and_slug_from_path, use settings.LANGUAGES, which includes any
enabled candidate languages. This is used by KumaScript, like:
bug 1340003: Use settings.LANGUAGES in sitemaps

In build_sitemaps(), create the locale list from settings.LANGUAGES,
which includes enabled candidate languages.
Merge pull request #4156 from jwhitlock/more_candidate_lang_1340003

bug 1340003: More changes for candidate languages

Comment 6

8 months ago
Fixes pushed to stage and production. Thanks safwan!
Last Resolved: 8 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.