Hi,
I'm building a multilanguage site with blog functions in _uikit.php installed from Ryans site-regular.
The main translation is okay. I also have a Functional Field 'snips' in template 'snippets', and a page 'snippets' to create words and phrases. This works fine in any template with
<?=$pages->get('/snippets/')->snips->flowers?>
But I just can't figure how to translate phrases like 'Read more' or 'Posted by' in _uikit.php
I read a lot in this forum and tried several ways with no success, so I need your help here.
function ukBlogPost(Page $page, $options = array()) {
$defaults = array(
'summarize' => null, // Display blog post summary rather than full post? (null=auto-detect)
'metaIcon' => 'info',
'moreIcon' => 'arrow-right',
'moreText' => __('Read more'),
'categoryIcon' => 'hashtag',
'bylineText' => __('Posted by %1$s on %2$s'),
);
$options = _ukMergeOptions($defaults, $options);
$title = $page->title;
$date = $page->get('date|createdStr');
$name = $page->createdUser->name;
$body = $page->get('body');
$metaIcon = ukIcon($options['metaIcon']);
$moreIcon = ukIcon($options['moreIcon']);
$categoryIcon = ukIcon($options['categoryIcon']);
$n = $page->get('comments')->count();
$numComments = $n ? "<a href='$page->url#comments'>" . ukIcon('comments') . " $n</a>" : "";
if($options['summarize'] === null) {
// auto-detect: summarize if current page is not the same as the blog post
$options['summarize'] = page()->id != $page->id;
}
$categories = $page->get('categories')->each($categoryIcon .
"<a class='uk-button uk-button-text' href='{url}'>{title}</a> "
);
if($options['summarize']) {
// link to post in title, and use just the first paragraph in teaser mode
$title = "<a href='$page->url'>$title</a>";
$body = explode('</p>', $body);
$body = reset($body) . ' ';
$body .= "<a href='$page->url'>$options[moreText] $moreIcon</a></p>";
$class = 'blog-post-summary';
} else {
$class = 'blog-post-full';
}
if($options['summarize']) {
$heading = "<h2 class='uk-margin-remove'>$title</h2>";
} else {
$heading = "<h1 class='uk-article-title uk-margin-remove'>$title</h1>";
}
$byline = sprintf($options['bylineText'], $name, $date);
// return the blog post article markup
return "
<article class='uk-article blog-post $class'>
$heading
<p class='uk-margin-small'>
<span class='uk-article-meta'>
$metaIcon
$byline
</span>
<span class='categories'>
$categories
</span>
<span class='num-comments uk-margin-small-left uk-text-muted'>
$numComments
</span>
</p>
$body
</article>
<hr>
";
}