Popularity
1.1
Stable
Activity
0.0
Stable
1
2
0
Monthly Downloads: 6
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Latest version: v0.1.0.5
snap-language alternatives and similar packages
Based on the "snap" category.
Alternatively, view snap-language alternatives based on common mentions on social networks and blogs.
-
snap-configuration-utilities
Utility functions for manipulating Snap-compatible Configurator objects
Do you think we are missing an alternative of snap-language or a related project?
README
snap-language
Language handling for Snap.
Support for determining the client's prefered language using the Accept-Language header or using suffixes to the requested URI.
Try this example:
{-# LANGUAGE OverloadedStrings #-}
module Simple where
import Snap.Http.Server
import Snap.Core
import Data.Map
import Control.Applicative
import Snap.Language
data Lang = SV | EN deriving Eq
table :: RangeMapping Lang
table = fromList [("sv-SE",SV),("en-GB",EN)]
getLanguage :: Snap Lang
getLanguage =
getSuffixLanguage table <|>
getAcceptLanguage table <|>
return EN
test :: IO ()
test = quickHttpServe $ do
lang <- getLanguage
dir "hello" $ handler lang
handler :: Lang -> Snap ()
handler EN = writeBS "hello"
handler SV = writeBS "hej"
You can now access /hello
and you will get an answer depending on your Accept-Language header.
Or you can access /hello.en-GB
or /hello.sv-SE
directly.