homepage: https://github.com/hexresearch/ergvein
changelog-type: markdown
hash: 41e41561cce86973ec93415272934d3537402c53d87955894758e4bef1f11615
test-bench-deps: {}
maintainer: |-
  - Anton Gushcha <ncrashed@gmail.com>
  - Aminion <>
  - Vladimir Krutkin <krutkinvs@gmail.com>
  - Levon Oganyan
synopsis: Localization library for reflex
changelog: |
  # 1.0.0.0

  * Initial release
basic-deps:
  base: '>=4.5 && <4.15'
  text: -any
  reflex-external-ref: -any
  mtl: -any
  reflex: '>=0.4 && <0.8'
  jsaddle: -any
all-versions:
- 1.0.0.0
author: |-
  - Anton Gushcha
  - Aminion
  - Vladimir Krutkin
  - Levon Oganyan
latest: 1.0.0.0
description-type: markdown
description: |
  # reflex-localize

  Library provides helpers for dynamic strings that depends on current selected
  language.

  # How to use

  First, you should define which languages your app supports:
  ``` haskell
  module App.Language(
      Language(..)
    , module Reflex.Localize
    ) where

  import Reflex.Localize
  import Reflex.Localize.Language

  data instance Language
    = English
    | Russian
  ```

  Second, define enumeration for strings ids.

  ``` haskell
  module App.Localization(
      module App.Localization
    , module App.Language
    ) where

  import App.Language

  data AboutPageStrings =
      AboutTitle
    | AboutVersion
    | AboutLicence
    | AboutHomepage
    | AboutDevelopers

  instance LocalizedPrint AboutPageStrings where
    localizedShow l v = case l of
      English -> case v of
        AboutTitle      -> "About"
        AboutVersion    -> "Version"
        AboutLicence    -> "Licence"
        AboutHomepage   -> "Homepage"
        AboutDevelopers -> "Developers"
      Russian -> case v of
        AboutTitle      -> "О продукте"
        AboutVersion    -> "Версия"
        AboutLicence    -> "Лицензия"
        AboutHomepage   -> "Сайт"
        AboutDevelopers -> "Разработчики"
  ```

  You can either collect all strings to one data sum or split strings for each
  widget.

  Finally, you should implement `MonadLocalized` type class in you application monad.
  We suggest using monad transformer `LocalizeT` via `runLocalize` function:

  ``` haskell
  runLocalize :: (Reflex t, TriggerEvent t m, MonadIO m) => Language -> LocalizeT t m a -> m a
  ```
license-name: MIT

Update from Hackage at 2020-11-24T22:39:59Z
Update from Hackage at 2020-11-24T22:39:59Z
