Skip to content

Commit

Permalink
Fixup language edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicletz committed Feb 11, 2025
1 parent df1ab85 commit 056a026
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/desktop.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ defmodule Desktop do
find_default_locale(locales, known_locales)
end

defp find_default_locale([], _known_locales), do: nil

defp find_full_match(locale, known_locales) do
# locale and known_locales should be lowercase already
with <<locale::binary-size(5), _rest::binary>> <- locale do
Expand All @@ -81,6 +83,7 @@ defmodule Desktop do
String.split(language_code(), "|")
|> Enum.map(&String.trim/1)
|> Enum.map(&String.downcase/1)
|> Enum.map(&String.replace(&1, "-", "_"))
end

def language_code() do
Expand Down

0 comments on commit 056a026

Please sign in to comment.