~alcinnz/hurl

0c50ae13e1f74f4e16b2ce5084ed353da664f827 — Adrian Cochrane 4 years ago 1fec182
Reverse locale reformatting for XDG config localized lookup.
1 files changed, 5 insertions(+), 1 deletions(-)

M src/Network/URI/XDG/Ini.hs
M src/Network/URI/XDG/Ini.hs => src/Network/URI/XDG/Ini.hs +5 -1
@@ 36,6 36,10 @@ iniLookup group key ini = lookup group ini >>= lookup key

iniLookupLocalized :: [String] -> String -> String -> INI -> Maybe String
iniLookupLocalized (locale:locales) group key ini
    | Just ret <- iniLookup group (key ++ "[" ++ locale ++ "]") ini = Just ret
    | Just ret <- iniLookup group (key ++ "[" ++ locale' ++ "]") ini = Just ret
    | otherwise = iniLookupLocalized locales group key ini
    where locale' = map dash2under locale
iniLookupLocalized [] group key ini = iniLookup group key ini

dash2under '-' = '_'
dash2under c = c