├── .formatter.exs ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── config └── config.exs ├── lib ├── phoenix_html_simplified_helpers.ex └── phoenix_html_simplified_helpers │ ├── gettext.ex │ ├── number_with_delimiter.ex │ ├── time_ago_in_words.ex │ ├── truncate.ex │ └── url.ex ├── mix.exs ├── mix.lock ├── priv └── gettext │ ├── en │ └── LC_MESSAGES │ │ └── default.po │ ├── es │ └── LC_MESSAGES │ │ └── default.po │ ├── fr │ └── LC_MESSAGES │ │ └── default.po │ ├── ja │ └── LC_MESSAGES │ │ └── default.po │ └── zh │ └── LC_MESSAGES │ └── default.po └── test ├── phoenix_html_simplified_helpers ├── number_with_delimiter_test.exs ├── time_ago_in_words_test.exs ├── truncate_test.exs └── url_test.exs └── test_helper.exs /.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /cover 3 | /deps 4 | /docs 5 | /doc 6 | erl_crash.dump 7 | *.ez 8 | 9 | tags 10 | 11 | /working 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: elixir 2 | 3 | elixir: 4 | - 1.4 5 | - 1.5 6 | - 1.6 7 | - 1.7 8 | 9 | otp_release: 10 | - 18.3 11 | - 19.3 12 | - 20.0 13 | - 20.3 14 | - 21.0 15 | 16 | matrix: 17 | exclude: 18 | - elixir: 1.4 19 | otp_release: 21.0 20 | - elixir: 1.5 21 | otp_release: 21.0 22 | 23 | before_install: 24 | - sudo apt-get update -qq 25 | 26 | after_script: 27 | - mix deps.get --only docs 28 | - MIX_ENV=docs mix inch.report 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Tatsuo Ikeda / ikeikeikeike 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PhoenixHtmlSimplifiedHelpers 2 | 3 | [![Build Status](http://img.shields.io/travis/ikeikeikeike/phoenix_html_simplified_helpers.svg?style=flat-square)](http://travis-ci.org/ikeikeikeike/phoenix_html_simplified_helpers) 4 | [![Hex version](https://img.shields.io/hexpm/v/phoenix_html_simplified_helpers.svg "Hex version")](https://hex.pm/packages/phoenix_html_simplified_helpers) 5 | [![Hex downloads](https://img.shields.io/hexpm/dt/phoenix_html_simplified_helpers.svg "Hex downloads")](https://hex.pm/packages/phoenix_html_simplified_helpers) 6 | [![Deps Status](https://beta.hexfaktor.org/badge/all/github/ikeikeikeike/phoenix_html_simplified_helpers.svg)](https://beta.hexfaktor.org/github/ikeikeikeike/phoenix_html_simplified_helpers) 7 | [![Inline docs](https://inch-ci.org/github/ikeikeikeike/phoenix_html_simplified_helpers.svg)](http://inch-ci.org/github/ikeikeikeike/phoenix_html_simplified_helpers) 8 | [![hex.pm](https://img.shields.io/hexpm/l/ltsv.svg)](https://github.com/ikeikeikeike/phoenix_html_simplified_helpers/blob/master/LICENSE) 9 | 10 | ## Installation 11 | 12 | If [available in Hex](https://hex.pm/docs/publish), the package can be installed as: 13 | 14 | 1. Add phoenix_html_simplified_helpers to your list of dependencies in `mix.exs`: 15 | 16 | ```elixir 17 | def deps do 18 | [{:phoenix_html_simplified_helpers, "~> x.x.x"}] 19 | end 20 | ``` 21 | 22 | 2. Ensure phoenix_html_simplified_helpers is started before your application: 23 | 24 | ```elixir 25 | def application do 26 | [applications: [:phoenix_html_simplified_helpers]] 27 | end 28 | ``` 29 | 30 | 3. phoenix_html_simplified_helpers need to import(use) your Phoenix project. The following description is adding 'use syntax' into web.ex. 31 | 32 | ```elixir 33 | def view do 34 | quote do 35 | use Phoenix.View, root: "web/templates" 36 | 37 | # Import convenience functions from controllers 38 | import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1] 39 | 40 | # Use all HTML functionality (forms, tags, etc) 41 | use Phoenix.HTML 42 | use Phoenix.HTML.SimplifiedHelpers # <- this line. 43 | 44 | import MyApp.Router.Helpers 45 | import MyApp.ErrorHelpers 46 | import MyApp.Gettext 47 | end 48 | end 49 | ``` 50 | 51 | It is also able to import(use) in each view helper files. 52 | 53 | ```elixir 54 | defmodule MyApp.LayoutView do 55 | use MyApp.Web, :view 56 | import Phoenix.HTML.SimplifiedHelpers.Truncate # <- this line. 57 | import Phoenix.HTML.SimplifiedHelpers.TimeAgoInWords # <- this line. 58 | end 59 | ``` 60 | 61 | 4. time_ago_in_words has Gettext module that is changed translation file from project's locale. 62 | 63 | ```elixir 64 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "en") 65 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "ja") 66 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "es") 67 | ``` 68 | 69 | 70 | # Usage 71 | 72 | ## truncate 73 | 74 | ```elixir 75 | <%= truncate entity.content %> 76 | ``` 77 | ```elixir 78 | truncate "Once upon a time in a world far far away" 79 | # Once upon a time in a world... 80 | truncate "Once upon a time in a world far far away", length: 27 81 | # Once upon a time in a wo... 82 | truncate "And they found that many people were sleeping better.", length: 25, omission: "... (continued)" 83 | # And they f... (continued) 84 | truncate("Once upon a time in a world far far away", length: 17, separator: " ") 85 | # Once upon a... 86 | ``` 87 | 88 | ## time_ago_in_words 89 | 90 | ```elixir 91 | <%= time_ago_in_words entity.published_at %> ago 92 | ``` 93 | 94 | ```elixir 95 | time_ago_in_words :os.system_time 96 | # less than 5 seconds 97 | time_ago_in_words Timex.now 98 | # less than 5 seconds 99 | time_ago_in_words DateTime.utc_now 100 | # less than 5 seconds 101 | time_ago_in_words Ecto.DateTime.utc 102 | # less than 5 seconds 103 | time_ago_in_words NaiveDateTime.utc_now 104 | # less than 5 seconds 105 | time_ago_in_words ~N[2017-08-14 04:40:12.101212] 106 | # ...... 107 | ``` 108 | 109 | ### distance_of_time_in_words 110 | 111 | ```elixir 112 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 113 | to = Timex.shift(from, days: 45) 114 | distance_of_time_in_words(from, to) 115 | # about 2 months 116 | 117 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "ja") 118 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 119 | to = Timex.shift(from, months: 1) 120 | distance_of_time_in_words(from, to) 121 | # 約1ヶ月 122 | 123 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "es") 124 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 125 | to = Timex.shift(from, months: 18) 126 | distance_of_time_in_words(from, to) 127 | # más de 1 año 128 | ``` 129 | 130 | Or uses `Timex.format!("{relative}", :relative)` instead, like this. 131 | 132 | ```elixir 133 | Timex.shift(datetime, hours: -3) |> Timex.format!("{relative}", :relative) 134 | "3 hours ago" 135 | ``` 136 | 137 | ## number_with_delimiter 138 | 139 | ```elixir 140 | number_with_delimiter 1234567 141 | # 1,234,567 142 | ``` 143 | 144 | ## url_for 145 | 146 | Routes setting is [Here](https://github.com/ikeikeikeike/phoenix_html_simplified_helpers/blob/master/test/test_helper.exs). 147 | 148 | ```elixir 149 | url_for(conn, "home.index") 150 | # / 151 | 152 | url_for(conn, "entry.release:") 153 | # /release/ 154 | 155 | url_for(conn, "entry.release:percent") 156 | # /release/percent 157 | 158 | url_for(conn, "entry.release:", some: "query") 159 | # /release/?some=query 160 | 161 | url_for(conn, "entry.release:", some: "query", unko: "query2") 162 | # /release/?some=query&unko=query2 163 | ``` 164 | 165 | ## current_page? 166 | 167 | ```elixir 168 | conn = conn(:get, "/release/") 169 | 170 | current_page?(conn, "entry.release:") 171 | # true 172 | 173 | current_page?(conn, "home.index") 174 | # false 175 | -------------------------------------------------------------------------------- /config/config.exs: -------------------------------------------------------------------------------- 1 | # This file is responsible for configuring your application 2 | # and its dependencies with the aid of the Mix.Config module. 3 | use Mix.Config 4 | 5 | # This configuration is loaded before any dependency and is restricted 6 | # to this project. If another project depends on this project, this 7 | # file won't be loaded nor affect the parent project. For this reason, 8 | # if you want to provide default values for your application for 9 | # 3rd-party users, it should be done in your "mix.exs" file. 10 | 11 | # You can configure for your application as: 12 | # 13 | # config :phoenix_html_simplified_helpers, key: :value 14 | # 15 | # And access this configuration in your application as: 16 | # 17 | # Application.get_env(:phoenix_html_simplified_helpers, :key) 18 | # 19 | # Or configure a 3rd-party app: 20 | # 21 | # config :logger, level: :info 22 | # 23 | 24 | # It is also possible to import configuration files, relative to this 25 | # directory. For example, you can emulate configuration per environment 26 | # by uncommenting the line below and defining dev.exs, test.exs and such. 27 | # Configuration from the imported file will override the ones defined 28 | # here (which is why it is important to import them last). 29 | # 30 | # import_config "#{Mix.env}.exs" 31 | -------------------------------------------------------------------------------- /lib/phoenix_html_simplified_helpers.ex: -------------------------------------------------------------------------------- 1 | defmodule Phoenix.HTML.SimplifiedHelpers do 2 | @doc false 3 | defmacro __using__(_options) do 4 | quote do 5 | import Phoenix.HTML.SimplifiedHelpers.Truncate 6 | import Phoenix.HTML.SimplifiedHelpers.TimeAgoInWords 7 | import Phoenix.HTML.SimplifiedHelpers.NumberWithDelimiter 8 | import Phoenix.HTML.SimplifiedHelpers.URL 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/phoenix_html_simplified_helpers/gettext.ex: -------------------------------------------------------------------------------- 1 | defmodule Phoenix.HTML.SimplifiedHelpers.Gettext do 2 | use Gettext, otp_app: :phoenix_html_simplified_helpers 3 | end 4 | -------------------------------------------------------------------------------- /lib/phoenix_html_simplified_helpers/number_with_delimiter.ex: -------------------------------------------------------------------------------- 1 | defmodule Phoenix.HTML.SimplifiedHelpers.NumberWithDelimiter do 2 | def number_with_delimiter(i) when is_binary(i), do: number_with_delimiter(String.to_integer(i)) 3 | 4 | def number_with_delimiter(i) when is_integer(i) do 5 | i 6 | |> Integer.to_charlist() 7 | |> Enum.reverse() 8 | |> Enum.chunk(3, 3, []) 9 | |> Enum.join(",") 10 | |> String.reverse() 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/phoenix_html_simplified_helpers/time_ago_in_words.ex: -------------------------------------------------------------------------------- 1 | defmodule Phoenix.HTML.SimplifiedHelpers.TimeAgoInWords do 2 | import Phoenix.HTML.SimplifiedHelpers.Gettext 3 | 4 | @minutes_in_year 525_600 5 | @minutes_in_quarter_year 131_400 6 | @minutes_in_three_quarters_year 394_200 7 | 8 | def time_ago_in_words(from_time), 9 | do: distance_of_time_in_words(from_time, :os.system_time(:seconds)) 10 | 11 | def distance_of_time_in_words_to_now(from_time), do: time_ago_in_words(from_time) 12 | 13 | def distance_of_time_in_words(from_time) when is_integer(from_time), 14 | do: distance_of_time_in_words(from_time, 0) 15 | 16 | def distance_of_time_in_words(%DateTime{} = from_time), 17 | do: distance_of_time_in_words(Timex.to_unix(from_time), 0) 18 | 19 | def distance_of_time_in_words(%NaiveDateTime{} = from_time), 20 | do: distance_of_time_in_words(Timex.to_unix(from_time), 0) 21 | 22 | if Code.ensure_loaded?(Ecto.DateTime) do 23 | def distance_of_time_in_words(%Ecto.DateTime{} = from_time) do 24 | from = Ecto.DateTime.to_erl(from_time) 25 | distance_of_time_in_words(Timex.to_unix(from), 0) 26 | end 27 | end 28 | 29 | def distance_of_time_in_words(%DateTime{} = from_time, to_time) when is_integer(to_time) do 30 | distance_of_time_in_words(Timex.to_unix(from_time), to_time) 31 | end 32 | 33 | def distance_of_time_in_words(%NaiveDateTime{} = from_time, to_time) when is_integer(to_time) do 34 | distance_of_time_in_words(Timex.to_unix(from_time), to_time) 35 | end 36 | 37 | if Code.ensure_loaded?(Ecto.DateTime) do 38 | def distance_of_time_in_words(%Ecto.DateTime{} = from_time, to_time) 39 | when is_integer(to_time) do 40 | from = Ecto.DateTime.to_erl(from_time) 41 | distance_of_time_in_words(Timex.to_unix(from), to_time) 42 | end 43 | end 44 | 45 | def distance_of_time_in_words(%DateTime{} = from_time, %DateTime{} = to_time) do 46 | distance_of_time_in_words(Timex.to_unix(from_time), Timex.to_unix(to_time)) 47 | end 48 | 49 | def distance_of_time_in_words(%NaiveDateTime{} = from_time, %NaiveDateTime{} = to_time) do 50 | distance_of_time_in_words(Timex.to_unix(from_time), Timex.to_unix(to_time)) 51 | end 52 | 53 | if Code.ensure_loaded?(Ecto.DateTime) do 54 | def distance_of_time_in_words(%Ecto.DateTime{} = from_time, %Ecto.DateTime{} = to_time) do 55 | from = Ecto.DateTime.to_erl(from_time) 56 | to = Ecto.DateTime.to_erl(to_time) 57 | distance_of_time_in_words(Timex.to_unix(from), Timex.to_unix(to)) 58 | end 59 | end 60 | 61 | @spec distance_of_time_in_words(Integer.t(), Integer.t()) :: String.t() 62 | def distance_of_time_in_words(from_time, to_time) 63 | when is_integer(from_time) and is_integer(to_time) do 64 | from_time = Enum.min([from_time, to_time]) 65 | 66 | distance_in_minutes = round((to_time - from_time) / 60.0) 67 | distance_in_seconds = round(to_time - from_time) 68 | 69 | case distance_in_minutes do 70 | x when x in 0..1 -> 71 | case distance_in_seconds do 72 | x when x in 0..4 -> gettext("less than %{count} seconds", count: 5) 73 | x when x in 5..9 -> gettext("less than %{count} seconds", count: 10) 74 | x when x in 10..19 -> gettext("less than %{count} seconds", count: 20) 75 | x when x in 20..39 -> gettext("half a minute") 76 | x when x in 40..59 -> gettext("less than %{count} minute", count: 1) 77 | _ -> gettext("%{count} minute", count: 1) 78 | end 79 | 80 | x when x in 2..44 -> 81 | gettext("%{count} minutes", count: distance_in_minutes) 82 | 83 | x when x in 45..89 -> 84 | gettext("about %{count} hour", count: 1) 85 | 86 | # 90 mins up to 24 hours 87 | x when x in 90..1439 -> 88 | gettext("about %{count} hours", count: round(distance_in_minutes / 60.0)) 89 | 90 | # 24 hours up to 42 hours 91 | x when x in 1440..2519 -> 92 | gettext("%{count} day", count: 1) 93 | 94 | # 42 hours up to 30 days 95 | x when x in 2520..43199 -> 96 | gettext("%{count} days", count: round(distance_in_minutes / 1440.0)) 97 | 98 | # 30 days up to 60 days 99 | x when x in 43200..86399 -> 100 | gettext("about %{count} months", count: round(distance_in_minutes / 43200.0)) 101 | 102 | # 60 days up to 365 days 103 | x when x in 86400..525_599 -> 104 | gettext("%{count} months", count: round(distance_in_minutes / 43200.0)) 105 | 106 | _ -> 107 | remainder = rem(distance_in_minutes, @minutes_in_year) 108 | distance_in_years = div(distance_in_minutes, @minutes_in_year) 109 | 110 | cond do 111 | remainder < @minutes_in_quarter_year -> 112 | case distance_in_years do 113 | 1 -> gettext("about %{count} year", count: distance_in_years) 114 | _ -> gettext("about %{count} years", count: distance_in_years) 115 | end 116 | 117 | remainder < @minutes_in_three_quarters_year -> 118 | case distance_in_years do 119 | 1 -> gettext("over %{count} year", count: distance_in_years) 120 | _ -> gettext("over %{count} years", count: distance_in_years) 121 | end 122 | 123 | true -> 124 | case distance_in_years do 125 | 1 -> gettext("almost %{count} year", count: distance_in_years + 1) 126 | _ -> gettext("almost %{count} years", count: distance_in_years + 1) 127 | end 128 | end 129 | end 130 | end 131 | end 132 | -------------------------------------------------------------------------------- /lib/phoenix_html_simplified_helpers/truncate.ex: -------------------------------------------------------------------------------- 1 | defmodule Phoenix.HTML.SimplifiedHelpers.Truncate do 2 | def truncate(text, options \\ []) do 3 | len = options[:length] || 30 4 | omi = options[:omission] || "..." 5 | 6 | cond do 7 | !String.valid?(text) -> 8 | text 9 | 10 | String.length(text) < len -> 11 | text 12 | 13 | true -> 14 | len_with_omi = len - String.length(omi) 15 | 16 | stop = 17 | if options[:separator] do 18 | rindex(text, options[:separator], len_with_omi) || len_with_omi 19 | else 20 | len_with_omi 21 | end 22 | 23 | "#{String.slice(text, 0, stop)}#{omi}" 24 | end 25 | end 26 | 27 | defp rindex(text, str, offset) do 28 | text = 29 | if offset do 30 | String.slice(text, 0, offset) 31 | else 32 | text 33 | end 34 | 35 | revesed = text |> String.reverse() 36 | matchword = String.reverse(str) 37 | 38 | case :binary.match(revesed, matchword) do 39 | {at, strlen} -> 40 | String.length(text) - at - strlen 41 | 42 | :nomatch -> 43 | nil 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/phoenix_html_simplified_helpers/url.ex: -------------------------------------------------------------------------------- 1 | defmodule Phoenix.HTML.SimplifiedHelpers.URL do 2 | @moduledoc """ 3 | URL Helpers 4 | 5 | Routes setting is [Here](https://github.com/ikeikeikeike/phoenix_html_simplified_helpers/blob/master/test/test_helper.exs). 6 | """ 7 | 8 | @doc """ 9 | Generate URL 10 | 11 | # Example 12 | 13 | url_for(conn, "home.index") 14 | # / 15 | 16 | url_for(conn, "entry.release:") 17 | # /release/ 18 | 19 | url_for(conn, "entry.release:percent") 20 | # /release/percent 21 | 22 | url_for(conn, "entry.release:", some: "query") 23 | # /release/?some=query 24 | 25 | url_for(conn, "entry.release:", some: "query", unko: "query2") 26 | # /release/?some=query&unko=query2 27 | """ 28 | def url_for(conn, ctrl_act_param, opts \\ []) do 29 | [ctrl_act | params] = String.split(ctrl_act_param, ":") 30 | [ctrl, act] = String.split(ctrl_act, ".") 31 | 32 | helper = Module.concat(conn.private.phoenix_router, Helpers) 33 | apply(helper, :"#{ctrl}_path", [conn, :"#{act}"] ++ params ++ [opts]) 34 | end 35 | 36 | @doc """ 37 | Make sure current URL 38 | 39 | # Example 40 | 41 | 42 | conn = conn(:get, "/release/") 43 | 44 | current_page?(conn, "entry.release:") 45 | # true 46 | 47 | current_page?(conn, "home.index") 48 | # false 49 | """ 50 | def current_page?(conn, ctrl_act_param, opts \\ []) do 51 | left = url_for(conn, ctrl_act_param, opts) 52 | 53 | right = 54 | to_string(%URI{ 55 | path: conn.request_path, 56 | query: if(conn.query_string != "", do: conn.query_string) 57 | }) 58 | 59 | left == right 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /mix.exs: -------------------------------------------------------------------------------- 1 | defmodule Phoenix.HTML.SimplifiedHelpers.Mixfile do 2 | use Mix.Project 3 | 4 | @description """ 5 | Some view helpers for phoenix html( truncate, time_ago_in_words, number_with_delimiter, url_for, current_page? ) 6 | """ 7 | 8 | def project do 9 | [ 10 | app: :phoenix_html_simplified_helpers, 11 | version: "2.1.0", 12 | elixir: ">= 1.3.0", 13 | source_url: "https://github.com/ikeikeikeike/phoenix_html_simplified_helpers", 14 | compilers: [:gettext] ++ Mix.compilers(), 15 | docs: [extras: ["README.md"]], 16 | description: @description, 17 | package: package(), 18 | deps: deps() 19 | ] 20 | end 21 | 22 | # Configuration for the OTP application 23 | # 24 | # Type "mix help compile.app" for more information 25 | def application do 26 | [applications: [:logger, :timex, :tzdata, :gettext]] 27 | end 28 | 29 | # Dependencies can be Hex packages: 30 | # 31 | # {:mydep, "~> 0.3.0"} 32 | # 33 | # Or git/path repositories: 34 | # 35 | # {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"} 36 | # 37 | # Type "mix help deps" for more examples and options 38 | defp deps do 39 | [ 40 | {:timex, "~> 3.4 or ~> 3.3 or ~> 3.2"}, 41 | {:ecto, "~> 3.0 or ~> 2.2 or ~> 2.1"}, 42 | {:gettext, ">= 0.11.0"}, 43 | {:phoenix, "~> 1.3 or ~> 1.4", only: :test}, 44 | {:ex_doc, ">= 0.0.0", only: :dev}, 45 | {:inch_ex, ">= 0.0.0", only: :docs}, 46 | {:earmark, ">= 0.0.0", only: :dev} 47 | ] 48 | end 49 | 50 | defp package do 51 | [ 52 | maintainers: ["Tatsuo Ikeda / ikeikeikeike"], 53 | licenses: ["MIT"], 54 | links: %{"GitHub" => "https://github.com/ikeikeikeike/phoenix_html_simplified_helpers"} 55 | ] 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /mix.lock: -------------------------------------------------------------------------------- 1 | %{ 2 | "calendar": {:hex, :calendar, "0.12.4"}, 3 | "certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, 4 | "combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm"}, 5 | "decimal": {:hex, :decimal, "1.6.0", "bfd84d90ff966e1f5d4370bdd3943432d8f65f07d3bab48001aebd7030590dcc", [:mix], [], "hexpm"}, 6 | "earmark": {:hex, :earmark, "1.3.0", "17f0c38eaafb4800f746b457313af4b2442a8c2405b49c645768680f900be603", [:mix], [], "hexpm"}, 7 | "ecto": {:hex, :ecto, "3.0.4", "5d0e2b89baaa03eac37ec49f9018c39a4e2fb6501dc3ff5a839de742e171a09f", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"}, 8 | "ex_doc": {:hex, :ex_doc, "0.19.1", "519bb9c19526ca51d326c060cb1778d4a9056b190086a8c6c115828eaccea6cf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, 9 | "gettext": {:hex, :gettext, "0.16.1", "e2130b25eebcbe02bb343b119a07ae2c7e28bd4b146c4a154da2ffb2b3507af2", [:mix], [], "hexpm"}, 10 | "hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, 11 | "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, 12 | "inch_ex": {:hex, :inch_ex, "1.0.1", "1f0af1a83cec8e56f6fc91738a09c838e858db3d78ef5f2ec040fe4d5a62dabf", [:mix], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, 13 | "makeup": {:hex, :makeup, "0.5.5", "9e08dfc45280c5684d771ad58159f718a7b5788596099bdfb0284597d368a882", [:mix], [{:nimble_parsec, "~> 0.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, 14 | "makeup_elixir": {:hex, :makeup_elixir, "0.10.0", "0f09c2ddf352887a956d84f8f7e702111122ca32fbbc84c2f0569b8b65cbf7fa", [:mix], [{:makeup, "~> 0.5.5", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, 15 | "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, 16 | "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, 17 | "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, 18 | "nimble_parsec": {:hex, :nimble_parsec, "0.4.0", "ee261bb53214943679422be70f1658fff573c5d0b0a1ecd0f18738944f818efe", [:mix], [], "hexpm"}, 19 | "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, 20 | "phoenix": {:hex, :phoenix, "1.4.0", "56fe9a809e0e735f3e3b9b31c1b749d4b436e466d8da627b8d82f90eaae714d2", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"}, 21 | "phoenix_ecto": {:hex, :phoenix_ecto, "2.0.1"}, 22 | "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"}, 23 | "plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"}, 24 | "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"}, 25 | "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, 26 | "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"}, 27 | "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"}, 28 | "ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5"}, 29 | "timex": {:hex, :timex, "3.4.2", "d74649c93ad0e12ce5b17cf5e11fbd1fb1b24a3d114643e86dba194b64439547", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm"}, 30 | "timex_ecto": {:hex, :timex_ecto, "3.1.1", "37d54f6879d96a6789bb497296531cfb853631de78e152969d95cff03c1368dd", [:mix], [{:ecto, "~> 2.1.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:timex, "~> 3.0", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm"}, 31 | "tzdata": {:hex, :tzdata, "0.5.19", "7962a3997bf06303b7d1772988ede22260f3dae1bf897408ebdac2b4435f4e6a", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, 32 | "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, 33 | } 34 | -------------------------------------------------------------------------------- /priv/gettext/en/LC_MESSAGES/default.po: -------------------------------------------------------------------------------- 1 | ## `msgid`s in this file come from POT (.pot) files. 2 | ## 3 | ## Do not add, change, or remove `msgid`s manually here as 4 | ## they're tied to the ones in the corresponding POT file 5 | ## (with the same domain). 6 | ## 7 | ## Use `mix gettext.extract --merge` or `mix gettext.merge` 8 | ## to merge POT files into PO files. 9 | msgid "" 10 | msgstr "" 11 | "Language: en\n" 12 | 13 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:59 14 | msgid "%{count} day" 15 | msgstr "" 16 | 17 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:61 18 | msgid "%{count} days" 19 | msgstr "" 20 | 21 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:52 22 | msgid "%{count} minute" 23 | msgstr "" 24 | 25 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:54 26 | msgid "%{count} minutes" 27 | msgstr "" 28 | 29 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:65 30 | msgid "%{count} months" 31 | msgstr "" 32 | 33 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:55 34 | msgid "about %{count} hour" 35 | msgstr "" 36 | 37 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:57 38 | msgid "about %{count} hours" 39 | msgstr "" 40 | 41 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:63 42 | msgid "about %{count} months" 43 | msgstr "" 44 | 45 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:73 46 | msgid "about %{count} year" 47 | msgstr "" 48 | 49 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:74 50 | msgid "about %{count} years" 51 | msgstr "" 52 | 53 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:83 54 | msgid "almost %{count} year" 55 | msgstr "" 56 | 57 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:84 58 | msgid "almost %{count} years" 59 | msgstr "" 60 | 61 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:50 62 | msgid "half a minute" 63 | msgstr "" 64 | 65 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:51 66 | msgid "less than %{count} minute" 67 | msgstr "" 68 | 69 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:47 70 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:48 71 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:49 72 | msgid "less than %{count} seconds" 73 | msgstr "" 74 | 75 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:78 76 | msgid "over %{count} year" 77 | msgstr "" 78 | 79 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:79 80 | msgid "over %{count} years" 81 | msgstr "" 82 | -------------------------------------------------------------------------------- /priv/gettext/es/LC_MESSAGES/default.po: -------------------------------------------------------------------------------- 1 | ## `msgid`s in this file come from POT (.pot) files. 2 | ## 3 | ## Do not add, change, or remove `msgid`s manually here as 4 | ## they're tied to the ones in the corresponding POT file 5 | ## (with the same domain). 6 | ## 7 | ## Use `mix gettext.extract --merge` or `mix gettext.merge` 8 | ## to merge POT files into PO files. 9 | msgid "" 10 | msgstr "" 11 | "Language: es\n" 12 | 13 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:59 14 | msgid "%{count} day" 15 | msgstr "%{count} día" 16 | 17 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:61 18 | msgid "%{count} days" 19 | msgstr "%{count} días" 20 | 21 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:52 22 | msgid "%{count} minute" 23 | msgstr "%{count} minuto" 24 | 25 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:54 26 | msgid "%{count} minutes" 27 | msgstr "%{count} minutos" 28 | 29 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:65 30 | msgid "%{count} months" 31 | msgstr "%{count} meses" 32 | 33 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:55 34 | msgid "about %{count} hour" 35 | msgstr "alrededor de %{count} hora" 36 | 37 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:57 38 | msgid "about %{count} hours" 39 | msgstr "alrededor de %{count} horas" 40 | 41 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:63 42 | msgid "about %{count} months" 43 | msgstr "alrededor de %{count} meses" 44 | 45 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:73 46 | msgid "about %{count} year" 47 | msgstr "alrededor de %{count} año" 48 | 49 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:74 50 | msgid "about %{count} years" 51 | msgstr "alrededor de %{count} años" 52 | 53 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:83 54 | msgid "almost %{count} year" 55 | msgstr "casi %{count} año" 56 | 57 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:84 58 | msgid "almost %{count} years" 59 | msgstr "casi %{count} años" 60 | 61 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:50 62 | msgid "half a minute" 63 | msgstr "menos de 1 minuto" 64 | 65 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:51 66 | msgid "less than %{count} minute" 67 | msgstr "menos de %{count} minutos" 68 | 69 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:47 70 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:48 71 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:49 72 | msgid "less than %{count} seconds" 73 | msgstr "menos de %{count} segundos" 74 | 75 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:78 76 | msgid "over %{count} year" 77 | msgstr "más de %{count} año" 78 | 79 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:79 80 | msgid "over %{count} years" 81 | msgstr "más de %{count} años" 82 | -------------------------------------------------------------------------------- /priv/gettext/fr/LC_MESSAGES/default.po: -------------------------------------------------------------------------------- 1 | ## `msgid`s in this file come from POT (.pot) files. 2 | ## 3 | ## Do not add, change, or remove `msgid`s manually here as 4 | ## they're tied to the ones in the corresponding POT file 5 | ## (with the same domain). 6 | ## 7 | ## Use `mix gettext.extract --merge` or `mix gettext.merge` 8 | ## to merge POT files into PO files. 9 | msgid "" 10 | msgstr "" 11 | "Language: fr\n" 12 | 13 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:59 14 | msgid "%{count} day" 15 | msgstr "%{count} jour" 16 | 17 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:61 18 | msgid "%{count} days" 19 | msgstr "%{count} jours" 20 | 21 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:52 22 | msgid "%{count} minute" 23 | msgstr "%{count} minute" 24 | 25 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:54 26 | msgid "%{count} minutes" 27 | msgstr "%{count} minutes" 28 | 29 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:65 30 | msgid "%{count} months" 31 | msgstr "%{count} mois" 32 | 33 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:55 34 | msgid "about %{count} hour" 35 | msgstr "environ %{count} heure" 36 | 37 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:57 38 | msgid "about %{count} hours" 39 | msgstr "environ %{count} heures" 40 | 41 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:63 42 | msgid "about %{count} months" 43 | msgstr "environ %{count} mois" 44 | 45 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:73 46 | msgid "about %{count} year" 47 | msgstr "environ %{count} an" 48 | 49 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:74 50 | msgid "about %{count} years" 51 | msgstr "environ %{count} ans" 52 | 53 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:83 54 | msgid "almost %{count} year" 55 | msgstr "presque %{count} an" 56 | 57 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:84 58 | msgid "almost %{count} years" 59 | msgstr "presque %{count} ans" 60 | 61 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:50 62 | msgid "half a minute" 63 | msgstr "moins d'une minute" 64 | 65 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:51 66 | msgid "less than %{count} minute" 67 | msgstr "moins de %{count} minutes" 68 | 69 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:47 70 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:48 71 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:49 72 | msgid "less than %{count} seconds" 73 | msgstr "moins de %{count} secondes" 74 | 75 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:78 76 | msgid "over %{count} year" 77 | msgstr "plus de %{count} an" 78 | 79 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:79 80 | msgid "over %{count} years" 81 | msgstr "plus de %{count} ans" 82 | -------------------------------------------------------------------------------- /priv/gettext/ja/LC_MESSAGES/default.po: -------------------------------------------------------------------------------- 1 | ## `msgid`s in this file come from POT (.pot) files. 2 | ## 3 | ## Do not add, change, or remove `msgid`s manually here as 4 | ## they're tied to the ones in the corresponding POT file 5 | ## (with the same domain). 6 | ## 7 | ## Use `mix gettext.extract --merge` or `mix gettext.merge` 8 | ## to merge POT files into PO files. 9 | msgid "" 10 | msgstr "" 11 | "Language: ja\n" 12 | 13 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:59 14 | msgid "%{count} day" 15 | msgstr "%{count}日" 16 | 17 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:61 18 | msgid "%{count} days" 19 | msgstr "%{count}日" 20 | 21 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:52 22 | msgid "%{count} minute" 23 | msgstr "%{count}分" 24 | 25 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:54 26 | msgid "%{count} minutes" 27 | msgstr "%{count}分" 28 | 29 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:65 30 | msgid "%{count} months" 31 | msgstr "%{count}ヶ月" 32 | 33 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:55 34 | msgid "about %{count} hour" 35 | msgstr "約%{count}時間" 36 | 37 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:57 38 | msgid "about %{count} hours" 39 | msgstr "約%{count}時間" 40 | 41 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:63 42 | msgid "about %{count} months" 43 | msgstr "約%{count}ヶ月" 44 | 45 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:73 46 | msgid "about %{count} year" 47 | msgstr "約%{count}年" 48 | 49 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:74 50 | msgid "about %{count} years" 51 | msgstr "約%{count}年" 52 | 53 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:83 54 | msgid "almost %{count} year" 55 | msgstr "%{count}年弱" 56 | 57 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:84 58 | msgid "almost %{count} years" 59 | msgstr "%{count}年弱" 60 | 61 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:50 62 | msgid "half a minute" 63 | msgstr "30秒前後" 64 | 65 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:51 66 | msgid "less than %{count} minute" 67 | msgstr "%{count}分以内" 68 | 69 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:47 70 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:48 71 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:49 72 | msgid "less than %{count} seconds" 73 | msgstr "%{count}秒以内" 74 | 75 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:78 76 | msgid "over %{count} year" 77 | msgstr "%{count}年以上" 78 | 79 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:79 80 | msgid "over %{count} years" 81 | msgstr "%{count}年以上" 82 | -------------------------------------------------------------------------------- /priv/gettext/zh/LC_MESSAGES/default.po: -------------------------------------------------------------------------------- 1 | ## `msgid`s in this file come from POT (.pot) files. 2 | ## 3 | ## Do not add, change, or remove `msgid`s manually here as 4 | ## they're tied to the ones in the corresponding POT file 5 | ## (with the same domain). 6 | ## 7 | ## Use `mix gettext.extract --merge` or `mix gettext.merge` 8 | ## to merge POT files into PO files. 9 | msgid "" 10 | msgstr "" 11 | "Language: zh\n" 12 | 13 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:59 14 | msgid "%{count} day" 15 | msgstr "%{count}日" 16 | 17 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:61 18 | msgid "%{count} days" 19 | msgstr "%{count}日" 20 | 21 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:52 22 | msgid "%{count} minute" 23 | msgstr "%{count}分" 24 | 25 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:54 26 | msgid "%{count} minutes" 27 | msgstr "%{count}分" 28 | 29 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:65 30 | msgid "%{count} months" 31 | msgstr "%{count}个月" 32 | 33 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:55 34 | msgid "about %{count} hour" 35 | msgstr "大约%{count}小时" 36 | 37 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:57 38 | msgid "about %{count} hours" 39 | msgstr "大约%{count}小时" 40 | 41 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:63 42 | msgid "about %{count} months" 43 | msgstr "大约%{count}个月" 44 | 45 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:73 46 | msgid "about %{count} year" 47 | msgstr "大约%{count}年" 48 | 49 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:74 50 | msgid "about %{count} years" 51 | msgstr "大约%{count}年" 52 | 53 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:83 54 | msgid "almost %{count} year" 55 | msgstr "大约%{count}年" 56 | 57 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:84 58 | msgid "almost %{count} years" 59 | msgstr "大约%{count}年" 60 | 61 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:50 62 | msgid "half a minute" 63 | msgstr "30秒左右" 64 | 65 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:51 66 | msgid "less than %{count} minute" 67 | msgstr "%{count}分钟以内" 68 | 69 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:47 70 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:48 71 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:49 72 | msgid "less than %{count} seconds" 73 | msgstr "%{count}秒以内" 74 | 75 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:78 76 | msgid "over %{count} year" 77 | msgstr "%{count}年以上" 78 | 79 | #: lib/phoenix_html_simplified_helpers/time_ago_in_words.ex:79 80 | msgid "over %{count} years" 81 | msgstr "%{count}年以上" -------------------------------------------------------------------------------- /test/phoenix_html_simplified_helpers/number_with_delimiter_test.exs: -------------------------------------------------------------------------------- 1 | Code.require_file("../../test_helper.exs", __ENV__.file) 2 | 3 | defmodule Phoenix.HTML.SimplifiedHelpers.NumberWithDelimiterTest do 4 | use ExUnit.Case 5 | use Phoenix.HTML.SimplifiedHelpers 6 | 7 | doctest Phoenix.HTML.SimplifiedHelpers 8 | 9 | test "int into number_with_delimiter" do 10 | assert number_with_delimiter(1_234_567) == "1,234,567" 11 | end 12 | 13 | test "string into number_with_delimiter" do 14 | assert number_with_delimiter("1234567") == "1,234,567" 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /test/phoenix_html_simplified_helpers/time_ago_in_words_test.exs: -------------------------------------------------------------------------------- 1 | Code.require_file("../../test_helper.exs", __ENV__.file) 2 | 3 | defmodule Phoenix.HTML.SimplifiedHelpers.TimeAgoInWordsTest do 4 | use ExUnit.Case 5 | use Phoenix.HTML.SimplifiedHelpers 6 | 7 | doctest Phoenix.HTML.SimplifiedHelpers 8 | 9 | test "time_ago_in_words normally" do 10 | assert time_ago_in_words(Timex.now()) == "less than 5 seconds" 11 | end 12 | 13 | test "time_ago_in_words epoch" do 14 | assert time_ago_in_words(:os.system_time(:seconds)) == "less than 5 seconds" 15 | end 16 | 17 | if Code.ensure_loaded?(Ecto.DateTime) do 18 | test "time_ago_in_words with ecto" do 19 | assert time_ago_in_words(Ecto.DateTime.utc()) == "less than 5 seconds" 20 | end 21 | end 22 | 23 | test "time_ago_in_words normally in English" do 24 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "en") 25 | assert time_ago_in_words(Timex.now()) == "less than 5 seconds" 26 | end 27 | 28 | test "time_ago_in_words epoch in English" do 29 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "en") 30 | assert time_ago_in_words(:os.system_time(:seconds)) == "less than 5 seconds" 31 | end 32 | 33 | if Code.ensure_loaded?(Ecto.DateTime) do 34 | test "time_ago_in_words with ecto in English" do 35 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "en") 36 | assert time_ago_in_words(Ecto.DateTime.utc()) == "less than 5 seconds" 37 | end 38 | end 39 | 40 | test "time_ago_in_words normally in Japanese" do 41 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "ja") 42 | assert time_ago_in_words(Timex.now()) == "5秒以内" 43 | end 44 | 45 | test "time_ago_in_words epoch in Japanese" do 46 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "ja") 47 | assert time_ago_in_words(:os.system_time(:seconds)) == "5秒以内" 48 | end 49 | 50 | if Code.ensure_loaded?(Ecto.DateTime) do 51 | test "time_ago_in_words with ecto in Japanese" do 52 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "ja") 53 | assert time_ago_in_words(Ecto.DateTime.utc()) == "5秒以内" 54 | end 55 | end 56 | 57 | test "time_ago_in_words normally in Español" do 58 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "es") 59 | assert time_ago_in_words(Timex.now()) == "menos de 5 segundos" 60 | end 61 | 62 | test "time_ago_in_words epoch in Español" do 63 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "es") 64 | assert time_ago_in_words(:os.system_time(:seconds)) == "menos de 5 segundos" 65 | end 66 | 67 | if Code.ensure_loaded?(Ecto.DateTime) do 68 | test "time_ago_in_words with ecto in Español" do 69 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "es") 70 | assert time_ago_in_words(Ecto.DateTime.utc()) == "menos de 5 segundos" 71 | end 72 | end 73 | 74 | test "time_ago_in_words normally in Chinese" do 75 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "zh") 76 | assert time_ago_in_words(Timex.now()) == "5秒以内" 77 | end 78 | 79 | test "time_ago_in_words epoch in Chinese" do 80 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "zh") 81 | assert time_ago_in_words(:os.system_time(:seconds)) == "5秒以内" 82 | end 83 | 84 | if Code.ensure_loaded?(Ecto.DateTime) do 85 | test "time_ago_in_words with ecto in Chinese" do 86 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "zh") 87 | assert time_ago_in_words(Ecto.DateTime.utc()) == "5秒以内" 88 | end 89 | end 90 | 91 | test "distance_of_time_in_words advance one month" do 92 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 93 | to = Timex.shift(from, months: 1) 94 | assert distance_of_time_in_words(from, to) == "about 1 months" 95 | end 96 | 97 | test "distance_of_time_in_words advance one month and half a month" do 98 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 99 | to = Timex.shift(from, days: 45) 100 | assert distance_of_time_in_words(from, to) == "about 2 months" 101 | end 102 | 103 | test "distance_of_time_in_words advance one year" do 104 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 105 | to = Timex.shift(from, years: 1) 106 | assert distance_of_time_in_words(from, to) == "about 1 year" 107 | end 108 | 109 | test "distance_of_time_in_words advance 2 years" do 110 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 111 | to = Timex.shift(from, years: 2) 112 | assert distance_of_time_in_words(from, to) == "about 2 years" 113 | end 114 | 115 | test "distance_of_time_in_words advance 1 year and half a year" do 116 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 117 | to = Timex.shift(from, months: 18) 118 | assert distance_of_time_in_words(from, to) == "over 1 year" 119 | end 120 | 121 | test "distance_of_time_in_words advance one month in Japanese" do 122 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "ja") 123 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 124 | to = Timex.shift(from, months: 1) 125 | assert distance_of_time_in_words(from, to) == "約1ヶ月" 126 | end 127 | 128 | test "distance_of_time_in_words advance one month and half a month in Japanese" do 129 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "ja") 130 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 131 | to = Timex.shift(from, days: 45) 132 | assert distance_of_time_in_words(from, to) == "約2ヶ月" 133 | end 134 | 135 | test "distance_of_time_in_words advance one year in Japanese" do 136 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "ja") 137 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 138 | to = Timex.shift(from, years: 1) 139 | assert distance_of_time_in_words(from, to) == "約1年" 140 | end 141 | 142 | test "distance_of_time_in_words advance 2 years in Japanese" do 143 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "ja") 144 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 145 | to = Timex.shift(from, years: 2) 146 | assert distance_of_time_in_words(from, to) == "約2年" 147 | end 148 | 149 | test "distance_of_time_in_words advance 1 year and half a year in Español" do 150 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "es") 151 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 152 | to = Timex.shift(from, months: 18) 153 | assert distance_of_time_in_words(from, to) == "más de 1 año" 154 | end 155 | 156 | test "distance_of_time_in_words advance one month in Chinese" do 157 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "zh") 158 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 159 | to = Timex.shift(from, months: 1) 160 | assert distance_of_time_in_words(from, to) == "大约1个月" 161 | end 162 | 163 | test "distance_of_time_in_words advance one month and half a month in Chinese" do 164 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "zh") 165 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 166 | to = Timex.shift(from, days: 45) 167 | assert distance_of_time_in_words(from, to) == "大约2个月" 168 | end 169 | 170 | test "distance_of_time_in_words advance one year in Chinese" do 171 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "zh") 172 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 173 | to = Timex.shift(from, years: 1) 174 | assert distance_of_time_in_words(from, to) == "大约1年" 175 | end 176 | 177 | test "distance_of_time_in_words advance 2 years in Chinese" do 178 | Gettext.put_locale(Phoenix.HTML.SimplifiedHelpers.Gettext, "zh") 179 | from = Timex.to_datetime({{2015, 10, 31}, {0, 0, 0}}) 180 | to = Timex.shift(from, years: 2) 181 | assert distance_of_time_in_words(from, to) == "大约2年" 182 | end 183 | end 184 | -------------------------------------------------------------------------------- /test/phoenix_html_simplified_helpers/truncate_test.exs: -------------------------------------------------------------------------------- 1 | Code.require_file("../../test_helper.exs", __ENV__.file) 2 | 3 | defmodule Phoenix.HTML.SimplifiedHelpers.TruncateTest do 4 | use ExUnit.Case 5 | use Phoenix.HTML.SimplifiedHelpers 6 | 7 | doctest Phoenix.HTML.SimplifiedHelpers 8 | 9 | test "truncate" do 10 | assert "Once upon a time in a world..." == 11 | truncate("Once upon a time in a world far far away") 12 | end 13 | 14 | test "truncate with length option" do 15 | assert "Once upon a ti..." == truncate("Once upon a time in a world far far away", length: 17) 16 | end 17 | 18 | test "truncate with omission option" do 19 | assert "And they f... (continued)" == 20 | truncate( 21 | "And they found that many people were sleeping better.", 22 | length: 25, 23 | omission: "... (continued)" 24 | ) 25 | end 26 | 27 | test "truncate no applying" do 28 | assert "Once upon a time in a world far far away" == 29 | truncate("Once upon a time in a world far far away", length: 50) 30 | end 31 | 32 | test "truncate nil" do 33 | assert nil == truncate(nil) 34 | end 35 | 36 | test "truncate bool" do 37 | assert false == truncate(false) 38 | end 39 | 40 | test "truncate with separator option" do 41 | assert "Once upon a..." == 42 | truncate("Once upon a time in a world far far away", length: 17, separator: " ") 43 | end 44 | 45 | test "truncate with separator option one" do 46 | assert "username@..." == 47 | truncate("username@username-username.com", length: 20, separator: "user") 48 | end 49 | 50 | test "truncate with separator option two" do 51 | assert "username@username-..." == 52 | truncate( 53 | "username@username-username.comusername@username-username.com", 54 | separator: "user" 55 | ) 56 | end 57 | 58 | test "truncate with separator option three" do 59 | assert "..." == 60 | truncate( 61 | "username@username-username.comusername@username-username.com", 62 | length: 3, 63 | separator: "user" 64 | ) 65 | end 66 | 67 | # test "truncate with escape option" do 68 | # truncate "kjkjkjk" 69 | # assert 1 + 1 == 2 70 | # end 71 | end 72 | -------------------------------------------------------------------------------- /test/phoenix_html_simplified_helpers/url_test.exs: -------------------------------------------------------------------------------- 1 | Code.require_file("../../test_helper.exs", __ENV__.file) 2 | 3 | defmodule Phoenix.HTML.SimplifiedHelpers.URLTest do 4 | alias Phoenix.HTML.SimplifiedHelpers 5 | 6 | use ExUnit.Case 7 | use Plug.Test 8 | use SimplifiedHelpers 9 | 10 | import SimplifiedHelpers 11 | 12 | doctest SimplifiedHelpers 13 | 14 | # @opts SimplifiedHelpers.Router.init([]) 15 | 16 | test "url_for home" do 17 | conn = conn(:get, "/") |> Map.put(:private, %{phoenix_router: SimplifiedHelpers.Router}) 18 | assert "/" == url_for(conn, "home.index") 19 | end 20 | 21 | test "url_for entry" do 22 | conn = conn(:get, "/") |> Map.put(:private, %{phoenix_router: SimplifiedHelpers.Router}) 23 | assert "/release/" == url_for(conn, "entry.release:") 24 | end 25 | 26 | test "url_for with params" do 27 | conn = conn(:get, "/") |> Map.put(:private, %{phoenix_router: SimplifiedHelpers.Router}) 28 | assert "/release/percent" == url_for(conn, "entry.release:percent") 29 | end 30 | 31 | test "url_for with options" do 32 | conn = conn(:get, "/") |> Map.put(:private, %{phoenix_router: SimplifiedHelpers.Router}) 33 | assert "/release/?some=query" == url_for(conn, "entry.release:", some: "query") 34 | end 35 | 36 | test "url_for with options two" do 37 | conn = conn(:get, "/") |> Map.put(:private, %{phoenix_router: SimplifiedHelpers.Router}) 38 | 39 | assert "/release/?some=query&unko=query2" == 40 | url_for(conn, "entry.release:", some: "query", unko: "query2") 41 | end 42 | 43 | test "current_pate? one" do 44 | conn = 45 | conn(:get, "/release/?percent=oh+yes%21") 46 | |> Map.put(:private, %{phoenix_router: SimplifiedHelpers.Router}) 47 | 48 | assert true == current_page?(conn, "entry.release:", percent: "oh yes!") 49 | end 50 | 51 | test "current_pate? two" do 52 | conn = 53 | conn(:get, "/release/?unko1=1&unko2=3") 54 | |> Map.put(:private, %{phoenix_router: SimplifiedHelpers.Router}) 55 | 56 | assert false == current_page?(conn, "entry.release:", unko1: "1", unko2: "2") 57 | end 58 | 59 | test "current_pate? three" do 60 | conn = 61 | conn(:get, "/release/") |> Map.put(:private, %{phoenix_router: SimplifiedHelpers.Router}) 62 | 63 | assert true == current_page?(conn, "entry.release:") 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /test/test_helper.exs: -------------------------------------------------------------------------------- 1 | defmodule Phoenix.HTML.SimplifiedHelpers.Router do 2 | use Phoenix.Router 3 | 4 | pipeline :browser do 5 | plug(:accepts, ~w(html)) 6 | plug(:fetch_session) 7 | plug(:fetch_flash) 8 | plug(:protect_from_forgery) 9 | end 10 | 11 | pipeline :api do 12 | plug(:accepts, ~w(json)) 13 | end 14 | 15 | scope "/", Phoenix.HTML.SimplifiedHelpers do 16 | # Use the default browser stack 17 | pipe_through(:browser) 18 | 19 | get("/", HomeController, :index) 20 | 21 | scope "/release" do 22 | get("/:alias", EntryController, :release) 23 | get("/", EntryController, :release) 24 | end 25 | end 26 | end 27 | 28 | ExUnit.start() 29 | --------------------------------------------------------------------------------