ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: Jorin on July 03, 2014, 11:27:09 am

Title: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 03, 2014, 11:27:09 am
I choose the german language files. If I choose to use "today" and "yesterday", the time stamp on these two days will look like this:

18:45

On the other days it will look like this:

18:45 Uhr

Is there any chance to fix this?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 03, 2014, 04:55:19 pm
Looks good on my "test install"... except I don't know German and I rely on google... O:-)

Where does it look like that?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 04, 2014, 01:47:59 am
In forum index. With german language we need the "Uhr" every time.

Edit: "Am Heute um 16:45" too is not perfect. It should be "Heute um 16:45 Uhr". But that's nearly impossible to handle, right?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 04, 2014, 04:31:47 am
hmm...
Okay, without having realized it, that's exactly the problem I was thinking about yesterday while looking at the code.
The current strings are:
Code: [Select]
$txt['today'] = 'Today';
and used like:
Code: [Select]
$txt['today'] . $time
while it would be much better to have:
Code: [Select]
$txt['today'] = 'Today %1$s';
and use them like:
Code: [Select]
sprintf($txt['today'], $time)
that way in German it would become:
Code: [Select]
$txt['today'] = 'Heute um %1$s Uhr'];

That said, could you please have a look here:
http://www.elkarte.it/community/index.php?language=german
because it seems to me there is something different from your screen (the "vormittags"). Not sure how to relate it with the rest... :-[
The whole sentence is:
Quoteam Heute um 09:15:11 vormittags
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 04, 2014, 04:51:36 am
Quote from: emanuele – ...it would be much better to have:

Code: [Select]
$txt['today'] = 'Today %1$s';
and use them like:

Code: [Select]
sprintf($txt['today'], $time)
that way in German it would become:

Code: [Select]
$txt['today'] = 'Heute um %1$s Uhr'];

That said, could you please have a look here:
http://www.elkarte.it/community/index.php?language=german
because it seems to me there is something different from your screen (the "vormittags"). Not sure how to relate it with the rest... :-[
The whole sentence is:

Quoteam Heute um 09:15:11 vormittags

Much better. It would be perfect if it were like this:

am Heute um 09:15 Uhr vormittags  O:-)

"Vormittags" is only needed with 12h instead of 24h. Or without any hour. It's nearly the same as "am" (vormittags) and "pm" (nachmittags).
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 04, 2014, 07:03:44 am
Oh so the "am" there is not German but the English "am"?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 04, 2014, 07:19:56 am
Right. You can use one of these in german, they are all correct:

Heute vormittag um 9:45 Uhr. (which means today 9:45 am)
Gestern nachmittag um 17:45 Uhr. (which means yesterday 5:45 pm)
Heute um 9:45 Uhr.
Heute vormittag. (without time and s)
Gestern nachmittag. (without time and s)
Am 27.09. vormittags um 9:45 Uhr. (with time and s)
Am 27.09. nachmittags um 17:45 Uhr. (with time and s)
Am 27.09. um 9:45 Uhr.
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 04, 2014, 08:29:37 am
Thanks for the explanation! :D

/me keeps this unread
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 04, 2014, 08:38:15 am
You're welcome.
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 13, 2014, 05:26:13 am
By the way: The "who's online" site is missing the "Uhr" after the time completely.  O:-)
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 14, 2014, 07:24:44 am
Quote from: Jorin – Right. You can use one of these in german, they are all correct:

Heute vormittag um 9:45 Uhr. (which means today 9:45 am)
Gestern nachmittag um 17:45 Uhr. (which means yesterday 5:45 pm)
Heute um 9:45 Uhr.
Heute vormittag. (without time and s)
Gestern nachmittag. (without time and s)
Am 27.09. vormittags um 9:45 Uhr. (with time and s)
Am 27.09. nachmittags um 17:45 Uhr. (with time and s)
Am 27.09. um 9:45 Uhr.
Will this "problem" be fixed in RC2 or final? O:-)
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 14, 2014, 09:18:51 am
That one may be a bit tricky.
The main problem is that these strings are used in a kind of odd way in the "who is online" page too, and just replace them with an sprintf would create problems there.
In particular, in http://www.elkarte.net/community/index.php?action=who the "time" column is built like that:
* 1st the normal time is generated doing:
Code: [Select]
$time = $txt['today'] . $time
and obtaining "Today at 02:46:17 pm" for example,
* then, somewhere else, the "today at" is stripped out with a replace like this:
Code: [Select]
$time = strtr($time, array($txt['today'] => ''));

To solve that it requires to add two new strings in Who.{language}.php at least.

Let's see, try to apply these changes and see if the result looks good, then we can decide on applying it to RC2 or final.

In Subs.php:
Code: (find) [Select]
			return $txt['today'] . standardTime($log_time, $today_fmt, $offset_type);
Code: (replace with) [Select]
			return sprintf($txt['today'], standardTime($log_time, $today_fmt, $offset_type));

then:
Code: (find) [Select]
			return $txt['yesterday'] . standardTime($log_time, $today_fmt, $offset_type);
Code: (replace with) [Select]
			return sprintf($txt['yesterday'], standardTime($log_time, $today_fmt, $offset_type));

In index.english.php:
Code: (find) [Select]
$txt['today'] = 'Today at ';
$txt['yesterday'] = 'Yesterday at ';
Code: (replace with) [Select]
$txt['today'] = 'Today at %1$s';
$txt['yesterday'] = 'Yesterday at %1$s';
And the corresponding change in index.german.php.
Additionally, in Who.english.php and Who.german.php:
Code: (add at the end) [Select]
// Overrides the already defined strings to get clean results in the table
$txt['today'] = '%1$s';
$txt['yesterday'] = '%1$s';

Let me know if it works for you. ;)
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 14, 2014, 12:21:41 pm
Still have a "am Heute um 09:12"  :(
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 14, 2014, 12:24:57 pm
What did you put in $txt['today'] and $txt['yesterday'] of the index.german.php file?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 14, 2014, 12:40:27 pm
Code: [Select]
// Overrides the already defined strings to get clean results in the table

$txt['today'] = '%1$s';
$txt['yesterday'] = '%1$s';
Ah... There must be "Heute" und "Gestern" instead of "%1$s"? No... Now it's "Am Heute um" without any time.
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 14, 2014, 01:52:14 pm
Those have to go in Who, not in index.german.php.
In index.german.php you have to find the:
Code: [Select]
$txt['today'] = 'Heute um ';
$txt['yesterday'] = 'Gestern um ';
and replace then with something like:
Code: [Select]
$txt['today'] = 'Heute um %1$s Uhr.';
$txt['yesterday'] = 'Gestern um %1$s Uhr.';
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 14, 2014, 02:07:38 pm
Yeah, my mistake. Made the changes the way you explained earlier. Still is "Am Heute um 09:12 Uhr".
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 14, 2014, 03:23:10 pm
Can you attach here your index.german.php?
Never mind, it seems that transifex didn't recognize the commented out string...

ETA: https://github.com/elkarte/Elkarte/pull/1727
It was using the string I removed in that commit, that is also the one you have in the translation instead of the correct one (that is the one non commented).
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 15, 2014, 12:36:30 pm
Well, whatever, I sent the PR, it should work, if not... oh well, not the first time I break something. :P
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 16, 2014, 02:23:24 am
Oh, sorry. Do you want me to test something? :-[
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on July 16, 2014, 09:15:18 am
No problem. ;)
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on July 16, 2014, 09:20:19 am
If I can help give me concrete orders! I will obey!  :D
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on August 12, 2014, 12:01:32 am
Okay, let's see... In Subs.php I have:

Code: [Select]
		// Same day of the year, same year.... Today!
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
return sprintf($txt['today'], standardTime($log_time, $today_fmt, $offset_type));

// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
return sprintf($txt['yesterday'], standardTime($log_time, $today_fmt, $offset_type));
}
...and in index.german.php I have:

Code: [Select]
$txt['last_post'] = 'Letzter Beitrag';
$txt['first_post'] = 'Erster Beitrag';
$txt['last_poster'] = 'Antwort von';
$txt['last_post_message'] = 'Letzter Beitrag von %1$s<br />in %2$s<br />am %3$s';
// @todo - Clean this up a bit. See notes in template.
// Just moved a space, so the output looks better when things break to an extra line.
$txt['last_post_message'] = 'Letzter Beitrag von %1$s<br />in %2$s<br />am %3$s';
$txt['boardindex_total_posts'] = '%1$s Beiträge in %2$s Themen von %3$s Benutzern';

...and:
Code: [Select]
$txt['today'] = 'Heute um %1$s';
$txt['yesterday'] = 'Gestern um %1$s';

But: I still have the problem with the leading "am" before the date and time in the german translation.
See the screenshot please. In the list of the recent posts in info center there is no "am" before date and time and that's exactly what is needed in the index. Can't we copy this code part from the info center?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on August 12, 2014, 04:22:36 am
Why not use?
Code: [Select]
$txt['today'] = 'am heute um %1$s';
$txt['yesterday'] = 'am gestern um %1$s';
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on August 12, 2014, 07:02:50 am
Because it's wrong. We don't have the leading "am" in this sentence.

Code: [Select]
$txt['today'] = 'Heute um %1$s';
$txt['yesterday'] = 'Gestern um %1$s';

This is correct, but there seems to be a "am" for the index which is not part of the index.german.php.
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on August 12, 2014, 07:38:52 am
So you don't want the "am".
The "am" in the board index comes from:
Code: [Select]
$txt['last_post_message'] = 'Letzter Beitrag von %1$s<br />in %2$s<br />am %3$s'

So if I understood correctly you would like to have:
Code: [Select]
Letzter Beitrag von %1$s<br />in %2$s<br />am 17 January
and:
Code: [Select]
Letzter Beitrag von %1$s<br />in %2$s<br />today at
right?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on August 12, 2014, 07:56:06 am
Near, but if the last post was today, then we have again an "am" too much.

The "am" is only neccessary when a date in the format "12. Oktober 2013" is shown. With "Heute" and "Gestern" or "vormittags um 9:45" we don't need the "am".

Confusing, hm?

A solution I can live with can be:

Code: [Select]
$txt['last_post_message'] = 'Letzter Beitrag von: %1$s<br />Thema: %2$s<br />Datum: %3$s

Then it's not a whole sentence, but it will work with all kinds of date formats, because the "am" is nowhere then.

Edit: See the screenshot how this will look. Oh, maybe it's better looking if the third row will not be under the avatar, but building a line with the first and second row?

Edit2: Oh, sorry, didn't get it. I'm ill. You're right with your example, that's exactly what is needed.
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on August 12, 2014, 08:02:45 am
I guess the easiest way is:
Code: [Select]
$txt['last_post_message'] = '%2$s<br />by %1$s, %3$s';
or:
Code: [Select]
$txt['last_post_message'] = 'Latest: %2$s<br />by %1$s, %3$s';
Could work in German as well?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on August 12, 2014, 08:03:17 am
See my second edit please.  :-[

Quote from: emanuele – I guess the easiest way is:
Code: [Select]
$txt['last_post_message'] = '%2$s<br />by %1$s, %3$s';
or:
Code: [Select]
$txt['last_post_message'] = 'Latest: %2$s<br />by %1$s, %3$s';
Could work in German as well?
Yes, this will work too. But then the "Heute" and "Gestern" must be "heute" and "gestern", while in info center it must be "Heute" and "Gestern" because it starts a sentence there. OMG!!!

We could make it:

Code: [Select]
$txt['last_post_message'] = 'Latest: %2$s<br />by %1$s. %3$s';
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on August 12, 2014, 08:04:52 am
The problem is that my example is a hell to code and maintain/translate... :-\

What would you think of my last proposal:
Quote from: emanuele – I guess the easiest way is:
Code: [Select]
$txt['last_post_message'] = '%2$s<br />by %1$s, %3$s';
or:
Code: [Select]
$txt['last_post_message'] = 'Latest: %2$s<br />by %1$s, %3$s';
Could work in German as well?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on August 12, 2014, 08:07:49 am
I feel like I'm in a TARDIS!  :o

Yes, this will work too. But then the "Heute" and "Gestern" must be "heute" and "gestern", while in info center it must be "Heute" and "Gestern" because it starts a sentence there. OMG!!!


We could make it:

Code: [Select]
$txt['last_post_message'] = 'Latest: %2$s<br />by %1$s. %3$s';
Nah, looks better with:
Code: [Select]
$txt['last_post_message'] = 'Latest: %2$s<br />by %1$s - %3$s';
Look: http://support.elkarte-hilfe.de/index.php
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on August 12, 2014, 08:13:06 am
The last from me in this case. I tried:

Code: [Select]
$txt['last_post_message'] = 'Letzter Beitrag: %2$s<br />%3$s von %1$s';

...and it looks perfect cause it's the same as in board index. First the date and time, and then the author. But why don't make the board index 100% the same as the forum index?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on August 12, 2014, 11:55:45 am
There are too many options!! LOL (Actually it's true: full time, today, today+yesterday, relative times and find a way to accommodate them all in all languages is messy...really.)

Anyway, your last is like:
Code: [Select]
$txt['last_post_message'] = 'Last post: {subject}<br />{time} by {author}';
right? (Sorry, bug German is not in the list of languages I know... :()

Quote from: Jorin – But why don't make the board index 100% the same as the forum index?
Because in the two there are different elements: in board index there is subject+time+author, while in message index there is only time+author and the subject is on the left... If I got it right.
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on August 12, 2014, 12:16:03 pm
Quote from: emanuele – Anyway, your last is like:
Code: [Select]
$txt['last_post_message'] = 'Last post: {subject}<br />{time} by {author}';
right? (Sorry, bug German is not in the list of languages I know... :()

Yes, that's how I use it now.

Quote from: emanuele – Because in the two there are different elements: in board index there is subject+time+author, while in message index there is only time+author and the subject is on the left... If I got it right.

With board index you mean the forum index and with message index you mean the board index (the list of threads inside a board)?  :o lol

On board index you have date+time+author, and an image for the last message. But why this image? Why not a text link to the last message in the thread like it is on the forum index? What's so special that you need this icon?  ;)
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on August 12, 2014, 12:54:24 pm
I usually refer to:
Board Index: http://www.elkarte.net/community/index.php
Message Index: http://www.elkarte.net/community/index.php?board=2.0
I borrow the terms from the source code, where the files and all the functions that handle these pages are called like that.
Yes, it's a bit odd, though I know them like that. :P

That said, you have "date+time+author" if you don't use relative times. ;)

On Board Index (see attach 276) you have:
Line 1: {subject} by {author}
Line 2: last post: {date/time}
On Message Index (see attach 277) you have:
Line 1: {date/time}
Line 2: by {author}
On Message Index the subject is already on the left, so repeat it would be.. a repetition.
The reason for the arrow is because of space mainly: a text link in the place where the arrow is would take too much space and potentially overlap with the numbers on the right (replies/views/likes).
Of course it could be set on multiple lines, though I see a lot of repeated stuff...
It could be either:
Line 1: {subject} by {author}
Line 2: last post: {date/time}
With the {subject} already present on the left, or:
Line 1: <link>last post</link> by {author}
Line 2: last post: {date/time}
with "last post" repeated twice in the two lines... :-\

Or you wanted to say something different that I missed?
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: Jorin on August 12, 2014, 01:32:41 pm
I understand now, thank you very much.  :-[ :-X ;)

Okay, it works great for me the kind I have it now at http://support.elkarte-hilfe.de. Will you use this with the final version? Otherwise I need to explain this problem and a solution at my german support board (not forum  :P ).
Title: Re: [RC1] time format with "today" and "yesterday"
Post by: emanuele on August 12, 2014, 04:02:33 pm
Quote from: Jorin – Will you use this with the final version?
I guess is the safest one. ;)
I'll change it to that one tomorrow:
http://www.elkarte.net/community/index.php?topic=1672.msg11528#msg11528