aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/I18n.hs21
-rw-r--r--src/Plugin/GitHubCommit.hs5
2 files changed, 22 insertions, 4 deletions
diff --git a/src/I18n.hs b/src/I18n.hs
index 9b9f870..988c823 100644
--- a/src/I18n.hs
+++ b/src/I18n.hs
@@ -1,13 +1,30 @@
+{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
-module I18n where
+module I18n
+ ( Locale(..)
+ , RenderMessage
+
+ , mkMessage
+ , translate
+ ) where
import qualified Data.Text as T
-import Text.Shakespeare.I18N (mkMessage, renderMessage)
+import Text.Shakespeare.I18N (mkMessage, renderMessage, RenderMessage)
data Bot = Bot
+data Locale = EN | FR
+
+toISOLocale :: Locale -> T.Text
+toISOLocale EN = "en"
+toISOLocale FR = "fr"
+
mkMessage "Bot" "messages" "en"
+
+translate :: (RenderMessage Bot b) => Locale -> b -> T.Text
+translate locale message =
+ renderMessage Bot [(toISOLocale locale)] message
diff --git a/src/Plugin/GitHubCommit.hs b/src/Plugin/GitHubCommit.hs
index a857604..23de2fa 100644
--- a/src/Plugin/GitHubCommit.hs
+++ b/src/Plugin/GitHubCommit.hs
@@ -33,8 +33,9 @@ gitHubCommitAction message = do
return $ respond rs
where
respond [] =
- Left "I couldn't find a repo URL for this channel. \
- \Try `git remote set origin REPO_URL`."
+ -- Left "I couldn't find a repo URL for this channel. \
+ -- \Try `git remote set origin REPO_URL`."
+ Left $ translate EN MsgGitHubCommitRepoURLNotFound
respond ((RepoUrlRow r):_) =
Right $ r `T.append` "/commits/" `T.append` T.pack (
M.textStr message =~ matchRegex gitHubCommit)