Skip to content

Commit

Permalink
LibWeb: Use "en" as a fallback when setting preferred languages
Browse files Browse the repository at this point in the history
This will set the preferred languages to [ "en" ] if an empty list is
provided.

(cherry picked from commit b7f0241ab5c06c945553acdefbd7daf7569d2b8b)
  • Loading branch information
jamierocks authored and nico committed Nov 5, 2024
1 parent 58f9631 commit c7e4d1b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Userland/Libraries/LibWeb/Loader/ResourceLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,15 @@ class ResourceLoader : public Core::EventReceiver {
void set_platform(String platform) { m_platform = move(platform); }

Vector<String> preferred_languages() const { return m_preferred_languages; }
void set_preferred_languages(Vector<String> preferred_languages) { m_preferred_languages = move(preferred_languages); }
void set_preferred_languages(Vector<String> preferred_languages)
{
// Default to "en" if no preferred languages are specified.
if (preferred_languages.is_empty() || (preferred_languages.size() == 1 && preferred_languages[0].is_empty())) {
m_preferred_languages = { "en"_string };
} else {
m_preferred_languages = move(preferred_languages);
}
}

NavigatorCompatibilityMode navigator_compatibility_mode() { return m_navigator_compatibility_mode; }
void set_navigator_compatibility_mode(NavigatorCompatibilityMode mode) { m_navigator_compatibility_mode = mode; }
Expand Down

0 comments on commit c7e4d1b

Please sign in to comment.