packages feed

snaplet-i18n 0.0.5 → 0.1.0

raw patch · 3 files changed

+60/−58 lines, 3 filesdep +mtldep +transformersdep ~bytestringdep ~configuratordep ~filepath

Dependencies added: mtl, transformers

Dependency ranges changed: bytestring, configurator, filepath, heist, lens, snap, snap-loader-static, text, xmlhtml

Files

example/snap.hs view
@@ -1,26 +1,27 @@-{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP               #-}-{-# LANGUAGE TemplateHaskell   #-}+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes        #-}+{-# LANGUAGE TemplateHaskell   #-}   module Main where  ------------------------------------------------------------------------------+import           Control.Exception      (SomeException, try)+import           Control.Lens           hiding (index) import           Control.Monad-import           Control.Exception (SomeException, try)-import           Data.ByteString (ByteString)+import           Control.Monad.IO.Class+import           Data.ByteString        (ByteString) import           Data.Maybe-import           Prelude hiding ((.))+import qualified Data.Text              as T+import qualified Heist.Interpreted      as I+import           Prelude                hiding ((.)) import           Snap-import           Snap.Snaplet.Heist import           Snap.Snaplet.Config+import           Snap.Snaplet.Heist import           System.IO-import qualified Data.Text as T-import qualified Heist.Interpreted as I-import Control.Lens hiding (value) -import Snap.Snaplet.I18N+import           Snap.Snaplet.I18N  import           Snap.Loader.Static @@ -28,8 +29,8 @@ ------------------------------------------------------------------------------  data App = App-    { _heist   :: Snaplet (Heist App)-    , _i18n   :: Snaplet I18N+    { _heist :: Snaplet (Heist App)+    , _i18n  :: Snaplet I18N     }  makeLenses ''App@@ -52,13 +53,12 @@  testSplice :: I.Splice AppHandler testSplice = do-    locale <- liftIO $ getDefaultLocale+    locale <- liftIO getDefaultLocale     liftIO $ print locale     I.textSplice $ T.pack "test"  index :: AppHandler ()-index = do-     heistLocal (I.bindSplice "testSplice" testSplice) $ render "index"+index = heistLocal (I.bindSplice "testSplice" testSplice) $ render "index"  -- | wrap to element span --@@ -75,14 +75,14 @@ app :: SnapletInit App App app = makeSnaplet "app" "An snaplet example application." Nothing $ do     h <- nestSnaplet "heist" heist $ heistInit "templates"-    --locale <- liftIO $ getDefaultLocale-    i <- nestSnaplet "i18n" i18n $ initI18N (Just "zh_CN")+    locale <- liftIO getDefaultLocale+    i <- nestSnaplet "i18n" i18n $ initI18N locale     addRoutes routes     return $ App h i -getDefaultLocale :: IO (Maybe String)+getDefaultLocale :: IO (Maybe Locale) --getDefaultLocale = return $ Just "zh_CN"-getDefaultLocale = liftM getLocale getConf+getDefaultLocale = fmap getLocale getConf  ------------------------------------------------------------------------------ @@ -92,7 +92,7 @@                                           'getActions                                           ["heist/templates"]) -    _ <- try $ httpServe conf $ site :: IO (Either SomeException ())+    _ <- try $ httpServe conf site :: IO (Either SomeException ())     cleanup  getConf :: IO (Config Snap AppConfig)
snaplet-i18n.cabal view
@@ -1,9 +1,5 @@--- snaplet-i10n.cabal auto-generated by cabal init. For additional--- options, see--- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.--- The name of the package. Name:                snaplet-i18n-Version:             0.0.5+Version:             0.1.0 Description:         A light weight i18n snaplet. Synopsis:            snaplet-i18n Homepage:            https://github.com/HaskellCNOrg/snaplet-i18n@@ -17,7 +13,7 @@ Stability:           Experience Cabal-version:       >=1.10 -Extra-source-files:  +Extra-source-files:   README.md   example/snap.hs   snaplets/heist/templates/*.tpl@@ -31,47 +27,49 @@ Library   Hs-Source-Dirs:   src   default-language:    Haskell2010-  Exposed-modules:     +  Exposed-modules:       Snap.Snaplet.I18N    Other-modules: Paths_snaplet_i18n -  Build-Depends:    -      base         >= 4       && < 5,-      configurator >= 0.2     && < 0.3,-      filepath     >= 1.2     && < 1.4,-      heist        >= 0.10    && < 0.14,-      lens         >= 3.7.0.1 && < 3.8,-      snap         >= 0.10    && < 0.14,-      snap-loader-static >= 0.9 && < 0.11,-      text         >= 0.11    && < 1.2,-      xmlhtml      >= 0.2+  Build-Depends:+                base         >= 4       && < 5+              , mtl+              , transformers+              , configurator+              , filepath+              , heist+              , lens+              , snap+              , snap-loader-static+              , text+              , xmlhtml    if impl(ghc >= 6.12.0)       ghc-options: -Wall -fwarn-tabs -funbox-strict-fields                    -fno-warn-orphans -fno-warn-unused-do-bind   else       ghc-options: -Wall -fwarn-tabs -funbox-strict-fields-                   -fno-warn-orphans     +                   -fno-warn-orphans  Executable demo-  Hs-Source-Dirs:   example-  default-language:    Haskell2010-  main-is: snap.hs--  Build-Depends:    -      base         >= 4       && < 5,-      configurator >= 0.2     && < 0.3,-      filepath     >= 1.2     && < 1.4,-      heist        >= 0.10    && < 0.14,-      lens         >= 3.7.0.1 && < 3.8,-      snap         >= 0.10    && < 0.14,-      snap-loader-static >= 0.9 && < 0.11,-      text         >= 0.11    && < 1.2,-      xmlhtml      >= 0.2,+  --Hs-Source-Dirs:   example+  default-language: Haskell2010+  main-is: example/snap.hs -      bytestring   >= 0.9 && < 1.0,-      snaplet-i18n+  Build-Depends:+                base         >= 4       && < 5+              , configurator+              , transformers+              , filepath+              , heist+              , lens+              , snap+              , snap-loader-static+              , text+              , xmlhtml+              , bytestring+              , snaplet-i18n    if impl(ghc >= 6.12.0)       ghc-options: -Wall -fwarn-tabs -funbox-strict-fields
src/Snap/Snaplet/I18N.hs view
@@ -5,12 +5,16 @@   ( I18N   , HasI18N (..)   , I18NMessage (..)+  , Locale+  , MessageFile+   , initI18N   , getI18NMessages   , lookupI18NValue   ) where -import           Control.Monad+import           Control.Monad.IO.Class+import           Control.Monad.State import qualified Data.Configurator       as Config import qualified Data.Configurator.Types as Config import           Data.Maybe@@ -66,12 +70,12 @@ -- | Util functions -- getI18N :: HasI18N b => Handler b b I18N-getI18N = with i18nLens Snap.get+getI18N = with i18nLens get  -- | Get the @I18NMessage@ -- getI18NMessages :: HasI18N b => Handler b b I18NMessage-getI18NMessages = liftM _getI18NMessage getI18N+getI18NMessages = fmap _getI18NMessage getI18N  -- | Look up a value in, usuallly Handler Monad --@@ -100,7 +104,7 @@                   "i18n" ## i18nSplice                   "i18nSpan" ## i18nSpanSplice         -- config dir for current snaplet-        datadir = Just $ liftM (++ "/resources") getDataDir+        datadir = Just $ fmap (++ "/resources") getDataDir         description = "light weight i18n snaplet"