Browse Source

Handle singular/plurals in minutes counter

pull/913/head
Timothée Jaussoin 6 years ago
parent
commit
5cf19bb3ee
  1. 8
      app/helpers/StringHelper.php
  2. 4
      app/widgets/Post/_post.tpl
  3. 4
      app/widgets/Post/_post_card.tpl
  4. 3
      app/widgets/Post/locales.ini

8
app/helpers/StringHelper.php

@ -112,7 +112,13 @@ function prepareString($string, bool $preview = false)
*/
function readTime($content)
{
return floor(str_word_count(strip_tags($content)) / 200);
$minutes = floor(str_word_count(strip_tags($content)) / 200);
if ($minutes == 0) return false;
return $minutes == 1
? __('post.read_time_singular', $minutes)
: __('post.read_time_plural', $minutes);
}
/**

4
app/widgets/Post/_post.tpl

@ -145,8 +145,8 @@
edit
</i>
{/if}
{if="$post->contentcleaned && readTime($post->contentcleaned) > 0"}
· {$c->__('post.read_time', readTime($post->contentcleaned))}
{if="$post->contentcleaned && isset(readTime($post->contentcleaned))"}
· {$post->contentcleaned|readTime}
{/if}
</p>
{if="$post->isBrief()"}

4
app/widgets/Post/_post_card.tpl

@ -70,8 +70,8 @@
lock
</i>
{/if}
{if="$post->contentcleaned && readTime($post->contentcleaned) > 0"}
· {$c->__('post.read_time', readTime($post->contentcleaned))}
{if="$post->contentcleaned && readTime($post->contentcleaned)"}
· {$post->contentcleaned|readTime}
{/if}
</p>
{if="$post->isBrief()"}

3
app/widgets/Post/locales.ini

@ -11,7 +11,8 @@ repost = This is a re-post from %s
repost_profile = See %s profile
blog_last = Public posts from users
read_time = %s minutes
read_time_singular = %s minute
read_time_plural = %s minutes
public = Publish this post publicly?
public_yes = This post is public

Loading…
Cancel
Save