-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Language handling for Snap -- -- Language handling for Snap. -- -- Support for determining the client's prefered language using the -- Accept-Language header or using suffixes to the requested URI. @package snap-language @version 0.1.0.2 -- | Language handling for Snap. -- -- Support for determining the client's prefered language using the -- Accept-Language header or using suffixes to the requested URI. module Snap.Language -- | A mapping from language ranges as defined in rfc2616 to languages in -- your own representation. -- -- For example: -- --
-- data Language = EN | SV deriving Eq
--
-- mapping :: RangeMapping Language
-- mapping = Map.fromList [("en-gb",EN),("sv-se",SV)]
--
type RangeMapping a = Map String a
-- | Attempt to find a suitable language according to the Accept-Language
-- header of the request.
--
-- This handler will call pass if it cannot find a suitable language.
getAcceptLanguage :: MonadSnap m => RangeMapping a -> m a
-- | Attempt to find a suitable language according to a suffix in the
-- request URI corresponding to a language range.
--
-- Will call pass if it cannot find a suitable language.
--
-- If a match is found, the suffix will be removed from the URI in the
-- request, so that you can later match on your resource as usual and not
-- worry about suffixes.
--
-- For example, with the following requested URI:
--
-- -- /resource.en-gb?param=value ---- -- getSuffixLanguage with our previously defined mapping will -- return EN and rqPathInfo will be changed to: -- --
-- /resource?param=value --getSuffixLanguage :: MonadSnap m => RangeMapping a -> m a -- | Change, or remove, the language suffix of an URI. switchSuffixLanguage :: Eq a => RangeMapping a -> ByteString -> Maybe a -> ByteString -- | Set the Content-Language header in the response. setContentLanguage :: (Eq a, MonadSnap m) => RangeMapping a -> a -> m ()