Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No translation for timestamps with ISO 8601 #76

Closed
felixwerner opened this Issue Mar 11, 2015 · 13 comments

Comments

Projects
None yet
3 participants
@felixwerner
Copy link

felixwerner commented Mar 11, 2015

timestamps are translated if time format convert function is turned on.
a exception in the qtranxf_convertFormat() function would be great for iso timestamps if using get_the_date('c')

@fburatti

This comment has been minimized.

Copy link

fburatti commented Mar 13, 2015

When I used Mqtranslate, the ideal setting for the dates in my themes was "Use strftime instead of date formats and replace with the predefined formats for each language."

Now with Qtranslate-x seems more compatible "Use emulated date function".

get_the_date ('c') does not work, then I use this snippet to get a valid date format according to [RFC 3339]:

 <?php echo date('c',strtotime(qtranxf_formatPostDateTime('%D %T','',''))); ?>
@johnclause

This comment has been minimized.

Copy link
Member

johnclause commented Mar 17, 2015

Hi guys, could you test the latest version from GitHub? It has some changes in date/time functions, but I am not sure it they would address this problem.

@fburatti

This comment has been minimized.

Copy link

fburatti commented Mar 17, 2015

Hi John, in a fresh install, I can confirm that get_the_date ('c') work correctly, both with version 3.2.7 that with the 3.2.8 pre-release (with "use emulated date function" enabled).

@johnclause

This comment has been minimized.

Copy link
Member

johnclause commented Mar 17, 2015

Thank you, @filippo, I guess we can close this one then? You can still write to closed issue and we can re-open it again if needed.

@johnclause johnclause closed this Mar 17, 2015

@felixwerner

This comment has been minimized.

Copy link
Author

felixwerner commented Mar 17, 2015

on both versions i still have the same problem when using get_the_date( 'c' ).
but maybe i wasnt clear enough the last time.
it works well if i use the emulated date option but if i use the the emulated date with language translation i still see: March 11th, 2015 instead of: 2015-03-11T17:20:39+00:00

crawling through the plugin files i found this function qtranxf_convertFormat() which has a exception for
get_the_date( 'U' ) to not convert this date format. would it be possible to do this for c as well?

this would be especially useful for other plugins like yoast seo which are using for meta fields ISO timestamps with get_the_date( 'c' )

@johnclause

This comment has been minimized.

Copy link
Member

johnclause commented Mar 17, 2015

@felixwerner: the date/time code of former qTranslate almost never got updated and apparently quite obsolete by now. There must be a better way of doing the whole thing by now in a more native way. Do you understand PHP code? Would you mind to take a lead to find out the best way and to implement it?

@johnclause johnclause reopened this Mar 17, 2015

@johnclause

This comment has been minimized.

Copy link
Member

johnclause commented Mar 18, 2015

@felixwerner: Please, help me to understand how it is supposed to work, I never paid close attention to date/time conversions so far. Do you mean by "emulated date with language translation" the choice "Use emulated date function and replace formats with the predefined formats for each language."? If this is so, then 'c' will be overridden with what you have in the field "Date Format" of language configuration, and then it worked correctly in my test. Is this how it should be?

@felixwerner

This comment has been minimized.

Copy link
Author

felixwerner commented Mar 18, 2015

yes if using the 'Use emulated date function and replace formats with the predefined formats for each language.' the 'c' will be overridden with general language date settings
there is a exception for 'U' to not overwrite the format if you choose this option.
i now added to the qtranxf_convertFormat() function in qtranslate_utils.php following line:

if('c'==$format) return qtranxf_convertDateFormatToStrftimeFormat($format);

it seems to work now if this line is added the 'c' date will show correctly.

@johnclause

This comment has been minimized.

Copy link
Member

johnclause commented Mar 18, 2015

I believe, exception for 'U' is there because 'U' basically means unformatted, raw format, so it stays raw in any case. But 'c' would not fit this logic. Why do you need exception, could not you use "Use emulated date function" option without override, if you provide your own format?

@johnclause

This comment has been minimized.

Copy link
Member

johnclause commented Mar 19, 2015

In fact it seems that there are 4 special formats, which may not need to be converted: 'Z', 'c', 'r' and 'U'.
Maybe all 4 need to be excluded? I am afraid to break people sites by changing this behavior.

I do not really know how it should be, I did not designed this thing, and I am pretty sure there is a better WP standardized way by now. Please, help me to design it, if you have knowledge on how WP now expects to do date time localization.

@johnclause

This comment has been minimized.

Copy link
Member

johnclause commented Mar 19, 2015

I added exceptions language-neutral formats exceptions ( 'Z', 'c', 'r', 'U') to the qtranxf_convertFormat on the latest on GitHub development version (3.2.8): https://github.com/qTranslate-Team/qtranslate-x. Please, @felixwerner, test that it does what you need, and @fburatti test that it does not break anything for you. Thanks.

@fburatti

This comment has been minimized.

Copy link

fburatti commented Mar 19, 2015

I was trying the beta version 3.8 but then you have already published the 3.9!
It all seems to go well, including seo Yoast meta tags (article: published_time, etc ...)
I tried all options but "Use emulated date function" remains the most accurate.

@johnclause

This comment has been minimized.

Copy link
Member

johnclause commented Mar 20, 2015

Thank you, @fburatti, 3.2.9 is the same as 3.2.8, I just increased the number, so that when people update the release, it would not mix with development version. Thanks a lot for your testing, if you found something I would do another release right away ;)

I guess, we can close this issue. We can still write to closed issue and may reopen it later if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.