reflex-localize: Localization library for reflex

[ frp, gui, html, javascript, library, mit, reactive, reactivity, reflex, user-interface, user-interfaces, web ] [ Propose Tags ] [ Report a vulnerability ]

Library provides helpers for dynamic strings that depends on current selected language. See also `reflex-localize-dom` for examples and DOM related helpers.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0.0, 1.0.1.0, 1.0.2.0, 1.1.0.0, 1.2.0.0
Change log CHANGELOG.md
Dependencies base (>=4.5 && <4.15), commutative-semigroups, jsaddle, mtl, reflex (>=0.4 && <0.10), reflex-external-ref, text [details]
License MIT
Copyright 2019 ATUM SOLUTIONS AG
Author - Anton Gushcha - Aminion - Vladimir Krutkin - Levon Oganyan
Maintainer - Anton Gushcha <ncrashed@gmail.com> - Aminion <> - Vladimir Krutkin <krutkinvs@gmail.com> - Levon Oganyan <lemarwin42@protonmail.com>
Category Reflex, FRP, Web, GUI, HTML, Javascript, Reactive, Reactivity, User Interfaces, User-interface
Home page https://github.com/hexresearch/ergvein
Bug tracker https://github.com/hexresearch/ergvein/issues
Source repo head: git clone https://github.com/hexresearch/ergvein(reflex-localize)
Uploaded by NCrashed at 2024-03-16T18:41:19Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 667 total (13 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for reflex-localize-1.2.0.0

[back to package 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:

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.

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:

runLocalize :: (Reflex t, TriggerEvent t m, MonadIO m) => Language -> LocalizeT t m a -> m a