Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jxs/phoenix_linguist
linguist integration functions into phoenix
https://github.com/jxs/phoenix_linguist
Last synced: 3 months ago
JSON representation
linguist integration functions into phoenix
- Host: GitHub
- URL: https://github.com/jxs/phoenix_linguist
- Owner: jxs
- License: mit
- Created: 2015-02-25T18:32:57.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-02-10T12:19:13.000Z (almost 5 years ago)
- Last Synced: 2024-10-14T21:08:00.863Z (3 months ago)
- Language: Elixir
- Size: 11.7 KB
- Stars: 18
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - A project that integrates Phoenix with Linguist, providing a plug and view helpers. It looks abandoned: its last commit was on 2015 and its CI runs Elixir 1.0.3. Also beware that Linguist seems to be abandoned too, please refer to corresponding item for details. (Framework Components)
- fucking-awesome-elixir - phoenix_linguist - A project that integrates Phoenix with Linguist, providing a plug and view helpers. It looks abandoned: its last commit was on 2015 and its CI runs Elixir 1.0.3. (Framework Components)
- awesome-elixir - phoenix_linguist - A project that integrates Phoenix with Linguist, providing a plug and view helpers. It looks abandoned: its last commit was on 2015 and its CI runs Elixir 1.0.3. (Framework Components)
README
[![Build Status](https://travis-ci.org/jxs/phoenix_linguist.svg?branch=master)](https://travis-ci.org/jxs/phoenix_linguist)
# PhoenixLinguist
A project that integrates [Phoenix](http://github.com/phoenixframework/phoenix) with [Linguist](https://github.com/chrismccord/linguist), providing a plug and view helpers
`PhoenixLinguistPlug` checks if there's a :locale param on the requested route, if there is and matches the existing locales, puts the locale on the session. If the requested :locale does not exist, forwards the user to the `ErrorView` `404` handler defined. If there isn't a :locale defined, `PhoenixLinguistPlug` puts the default locale on the session
`PhoenixLinguist.Helpers` are a couple of view helpers that can be used on templates to help determine user's prefered localeYou can see the [online documentation](http://hexdocs.pm/phoenix_linguist/) for more information.
## Requirements
Elixir 1.0.2
[Phoenix](http://www.phoenixframework.org) 0.10.0
## Instructions
Define your I18n Module on `config.ex` next to other Endpoint Settings
```elixir
config :my_app, MyApp.Endpoint,
url: [host: "localhost"],
secret_key_base: "l6M/YRIzkiqMk5Irn9UNm7ANo1BoHIF0XchxNmcUJWhdKZdERA45ASDFIxZ",
debug_errors: false,
i18n: MyApp.I18n
```Add `PhoenixLinguist.Plug` to the plug list on your routes file, on the browser pipeline after Phoenix plugs
```elixir
pipeline :browser do
plug :accepts, ~w(html)
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug PhoenixLinguist.Plug
end
```If you need to use the helper functions, add `PhoenixLinguist.Helpers` to your web module:
```elixir
def view do
quote do
use Phoenix.View, root: "web/templates"import MyAPP.Router.Helpers
use Phoenix.HTML
import PhoenixLinguist.Helpers
end
end```
Check the [online documentation](http://hexdocs.pm/phoenix_linguist/PhoenixLinguist.Helpers.html) for the list of helpers available