Jump to content
ngrmm

Date – Multilanguage Output

Recommended Posts

i did a multilanguage-install.

english and german are needed

i set german as default (install german languagepack at default)

then add english (en) as second language

my date-output is custom: %A %d %B %Y (Details Tab)
echo $page->date

the problem is that i always get the english ouput.

Share this post


Link to post
Share on other sites

Strange behavior. I have the following settings in my Details Tab:

German: %e. %B %G

English: %e %B %G

A slightly difference - German has a dot(.) after %e - it outputs all in correct language:

German: 22. Oktober 2015

English: 22 October 2015

Try it with this date formats and see if the result are the same as in this example.

Best regards

Jürgen

  • Like 1

Share this post


Link to post
Share on other sites

thanks Jürgen.

no luck. still in english

i noticed that my html begins always like this:

<html lang="en" …

is that a problem?

Share this post


Link to post
Share on other sites

and i treid it with this in the template-file

utf8_encode(strftime('%d. %B %Y', $page->getUnformatted('date')));

 
still everthing in english

Share this post


Link to post
Share on other sites

@martijn
yes, i added setlocale(LC_TIME, "de_DE.UTF8"); to the config.php

Share this post


Link to post
Share on other sites

UPDATE: i delted setlocale in config.php added it to the template-file

now both languageversion are german :)

is there a way to to setlocal as a variable?

Share this post


Link to post
Share on other sites

it works!
 

$lang = $user->language->name;
if($lang == 'default') {
setlocale(LC_TIME, "de_DE.UTF8");
}
else {
setlocale(LC_TIME, "en_EN.UTF8");
}
 
and 
 
utf8_encode(strftime('%A <br>%d %B %Y', $page->getUnformatted('postDate')))
 
 
 
 
THANKS!
  • Like 3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By sins7ven
      Hi community, I am wondering if its possible to display languages based on what host/domain has been requested.
      The use case is the following: I have one installation of PW - and within this installation I set up 5 different languages (default, english, spanish, french, dutch). Now I have 3 different domains (domainA.com, domainB.com, domainC.com) and I want to decide which languages to make available based on what domain has been navigated to. 
      For example:
      domainA.com
       - default (domainA.com)
       - english (domainA.com/en)
      domainB.com
        - default (domainB.com)
        - french (domainB.com/fr)
        - dutch (domainB.com/nl)
      domainC.com
        - default (domainC.com)
        - dutch (domainC.com/nl)
      So what I want to achieve is making only these particular languages selectable in the language switcher on the frontend. Since all pages share the same templates and overall site structure I don't see the benefits of running this installation as a multisite setup or would it be better to do so? But I assume that this would be difficult to handle since the default language might change as well. (On the french version of the page, french should be the default language and so on). Any suggestions how to accomplish that? Thanks!
    • By Elchin
      Hi.
      I want select pages where now between date and end_date or now bigger than date and end_date is empty.
      I have five tried variants:
      $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("foo=(date<$start,date_end=''),bar=(date<$start,date_end>=$start),sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("date<$start,(date_end='',date_end>=$start),sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("date_end=''|date_end>=$start,date<$start,sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("!date_end|date_end>=$start,date<$start,sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("date_end>=$start|!date_end,date<$start,sort=-date,limit=12"); All this variants not worked for me and returned zero results.
    • By MateThemes
      Hello everyone.
      I have a question that i can't find a way to solve.
      I have following function in _uikit.php 
      $date = $page->get('date|createdStr'); $dateModified = $page->get('datemodified'); But I need to output the $date in to different formats.
      My further function looks like this
      // return the blog post article markup return " <div> <article class='uk-article blog-post $class'> <meta property='name' content='$page->title'> <meta property='author' typeof='Person' content='Arra Lifte Harmanschlag'> <meta property='dateModified' content='$dateModified'> <meta property='datePublished' content='$date'> <meta class='uk-margin-remove-adjacent' property='articleSection' content='News'> <div property='image' typeof='ImageObject'> $featuredBlogPostImage </div> $heading <ul class='mt25 uk-margin-remove-bottom uk-subnav uk-subnav-divider'> <li class='uk-article-meta'> <time datetime='$date'>$byline</time> </li> </ul> <div class='mt25' property='text'> $body </div> </article> </div> "; Now I need to output the meta property in this format 2019-03-02CET05:23:00 and then a normal date format that is displayed on the Homepage with 2. März 2019 without time.
      Can anybody help me?
      Thanks in advance.
    • By MateThemes
      Hello!
      I am fairly new to Processwire. In the past I used OctoberCMS for my project. But I have more and more multilanguage projects and OctoberCMS don't fit my needs anymore.
      My first question to the community is, is it possible to hide/disable content based on the language. I mean, can a content editor say in German I want this content block and in Englisch I wanna hide this content block, based on the same layout?
      Thanks for your answers.
    • By Eunico Cornelius
      I am trying to get the strftime format from the function convertDateFormat(). However, the output has $ signs in it which i cannot use in strftime.(example of conversion : $d/$m/%Y what strftime actually uses: %d/%m/%Y). Am I in the wrong here or is there some way to format strftime? Thank you in advance :).
×
×
  • Create New...