Skip to content

Commit

Permalink
Document timeago for i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
crownedgrouse committed Mar 25, 2023
1 parent 294d8ff commit a1617fb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions manual/templates-go.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,17 @@ Assists in constructing a HTML checkbox `input` element, eg:

Format a date according to the application's default [date](appconf.html#formatdate) and [datetime](appconf.html#formatdatetime) format.

`timeago` accept a second argument, either string or variable set in `ViewArgs` telling (ISO 639-1 code) as language to be used, otherwise use `i18n.default_language` config value, for preconfigured language : de, fr, ko, pt, sp, tr, zh and default en.
In last resort, internationalisation will apply on timeago english term, and missing translation will be displayed with `i18n.unknown_format` config value.

The example below assumes `dateArg := time.Now()`:

{% capture ex %}{% raw %}
{{date .MyDate}}
{{datetime .MyDateTime}}
{{timeago .MyDateTime}}
{{timeago .MyDateTime "fr"}}
{{timeago .MyDateTime .lang}}
{% endraw %}{% endcapture %}
{% highlight htmldjango %}{{ex}}{% endhighlight %}

Expand Down

0 comments on commit a1617fb

Please sign in to comment.