Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Now available: AJAX/PHP multilingual website templates

Discussion of Ken True's web site templates

Moderator: saratogaWX

User avatar
actioman
Posts: 118
Joined: Sat 20 Mar 2010 1:01 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Windows XP SP3
Location: Elvas, Portugal
Contact:

Re: Now available: AJAX/PHP multilingual website templates

Post by actioman »

gemini06720 wrote:Manuel and kinder find attached my 'Weather Data' PHP template.

Also included in the ZIP file is the 'wxcudata_language-en.txt' file which contains all the english terms (words/phrases) contained in the template. I have made the file external so the terms (words/phrases) can be easily translated - once translation is completed, the file must be merge with the language file you use with the templates - for example, my french language file is called 'language-fr.txt', thus, once I had the terms (words/phrases) translated to french, I merged the file 'wxcudata_language-en.txt' with the file 'language-fr.txt'.
Thanks Ray, You were fast! :o

And you still have good memory! ;)

Cheers! :)
Kind Regards, Manuel.

Image
User avatar
saratogaWX
Posts: 1238
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Now available: AJAX/PHP multilingual website templates

Post by saratogaWX »

n9mfk wrote:hi Ken im tring to learn
what did i miss on this url
aa.usno.navy.mil,cgi-bin/aa_pap.pl/FFX=2&ID=AA&xxy=2011&xxm=3&xxd=15&place=Springfield%2C+IL%2C+USA&xx0=-1&xx1=89&xx2=37&yy0=1&yy1=39&yy2=42&zz1=5&zz0=-1&ZZZ=END
thanks Beau
Beau,
That URL is constructed by the get-USNO-sunmoon.php getUSNOsunmoon() function. The USNO (unlike most other sites) only accepts a POST query to it's website.. a GET query with that string will not work. The function getUSNOsunmoon() does the assembly of the correct arguments and a POST query to aa.usno.navy.mil for the data and parses the results and returns the data in an array for use by the programs.
gemini06720 wrote:
kinder wrote:limitation of strotime.Handle dates with / in m/d/y format.probably thats the reason.
The 'strtotime' function is supposed to (as written in the documentation) "...parse about any English textual datetime description into a Unix time...".

I guess having the date in the 'dd/mm/yyyy' format (as '16/03/2011') is not one of the formats accepted by the function... :x
gemini06720 wrote:
saratogaWX wrote:Also, check your Settings.php entry for

Code: Select all

$SITE['WDdateMDY'] = false;
that instructs the date functions to process the dates from Cumulus as M/D/Y (for =true) or as D/M/Y (for =false) .. if it's set incorrectly, all bets are off :)
Ken, just to be sure I understand clearly the purposes/results of the '$SITE['WDdateMDY']' variable:
  • true=dates are in the 'month/day/year' format
    false=dates are in the 'day/month/year' format
You also mentioned
saratogaWX wrote:...Ah, yes... it's that 'PHP is confused by European-style-dates' issue...
Is PHP not a global project with people from almost every countries of the world participating - why would one PHP function not be able to handle the European-style date formats without having to go through additional setups... :?
Ray, yes, PHP is an international project, and it does handle multiple date formats, but by default, it's format is USA-style dates (mm/dd/yyyy) and only a setlocale() can change that default. As I'd posted before, the arguments for setlocale() are not really standardized across the various platforms hosting PHP, and the strings even differ amongst different distributions of Linux/Unix, so I'd not directly incorporated that into the template sets .. instead, I'd tried to accomodate mm/dd/yyyy v.s. dd/mm/yyyy (and dd-mm-yyyy and dd.mm.yyyy) by using functions in the various scripts to take the date given by the weather software, and compose a yyyy-mm-dd hh:mm string that strtotime() could correctly parse into a unix timestamp based on the default US-English format for the dates in the majority of PHP installations. The key is to set $SITE['WDdateMDY'] to help the functions determine which format to use when assembling the strtotime() argument in US-English format.
beteljuice wrote:
Note:

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.
Link: strtotime() function
Beteljuice,

Weather-Display uses m/d/y or d/m/y for the dates (based on the WD setting), and even Cumulus will use the / format for either m/d/y or d/m/y based on the local PC setting. I agree that the ISO 8601 format is best and always non-ambiguous, but not all the weather software produce dates in that format, so we just try to adapt as best we can :)

Best regards,
Ken
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Now available: AJAX/PHP multilingual website templates

Post by beteljuice »

'Twas a not a 'knock' at you Ken - simply a clarification of the 'default' php reasoning.

I remain, as ever, your humble servant Image
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Now available: AJAX/PHP multilingual website templates

Post by steve »

saratogaWX wrote:and even Cumulus will use the / format for either m/d/y or d/m/y based on the local PC setting. I agree that the ISO 8601 format is best and always non-ambiguous, but not all the weather software produce dates in that format, so we just try to adapt as best we can :)
Date formatting in Cumulus is, I admit, a bit of a disaster. It wasn't originally intended to be internationalized, and to add to that there's the fact that I hadn't realised that when you tell Delphi to format a date with a slash in it, you're actually telling it to use the Windows locale date separator, so sometimes it's a hyphen-minus, sometimes a full stop, and possibly sometimes, I guess, whatever weird character the user has chosen.
Steve
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: Now available: AJAX/PHP multilingual website templates

Post by n9mfk »

HI Ken,
just for me to lean how wood the url blow be entered in firefox to see data


aa.usno.navy.mil,cgi-bin/aa_pap.pl/FFX=2&ID=AA&xxy=2011&xxm=3&xxd=15&place=Springfield%2C+IL%2C+USA&xx0=-1&xx1=89&xx2=37&yy0=1&yy1=39&yy2=42&zz1=5&zz0=-1&ZZZ=END

thanks Beau
User avatar
saratogaWX
Posts: 1238
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Now available: AJAX/PHP multilingual website templates

Post by saratogaWX »

n9mfk wrote:HI Ken,
just for me to lean how wood the url blow be entered in firefox to see data


aa.usno.navy.mil,cgi-bin/aa_pap.pl/FFX=2&ID=AA&xxy=2011&xxm=3&xxd=15&place=Springfield%2C+IL%2C+USA&xx0=-1&xx1=89&xx2=37&yy0=1&yy1=39&yy2=42&zz1=5&zz0=-1&ZZZ=END

thanks Beau
Hi Beau,
In short, you can't use that URL in Firefox since Firefox itself can only do GET-mode posts .. the aa.usno.navy.mil site requires POST-mode access.

If you want to see what the script returns... look in the cache file USNO-moondata.txt in your cache directory.


Best regards,
Ken
User avatar
saratogaWX
Posts: 1238
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Now available: AJAX/PHP multilingual website templates

Post by saratogaWX »

beteljuice wrote:'Twas a not a 'knock' at you Ken - simply a clarification of the 'default' php reasoning.

I remain, as ever, your humble servant Image
No worries, Betel... I was just explaining to Ray why strtotime() doesn't handle the formats as you'd hope it would :)
steve wrote:
saratogaWX wrote:and even Cumulus will use the / format for either m/d/y or d/m/y based on the local PC setting. I agree that the ISO 8601 format is best and always non-ambiguous, but not all the weather software produce dates in that format, so we just try to adapt as best we can :)
Date formatting in Cumulus is, I admit, a bit of a disaster. It wasn't originally intended to be internationalized, and to add to that there's the fact that I hadn't realised that when you tell Delphi to format a date with a slash in it, you're actually telling it to use the Windows locale date separator, so sometimes it's a hyphen-minus, sometimes a full stop, and possibly sometimes, I guess, whatever weird character the user has chosen.
Hi Steve,
I don't think that "date formatting in Cumulus is a bit of a disaster" at all, it just uses what the PC sets for the time setup and that varies a good bit from country to country. The scripts just try to accommodate what the station emits, and since each weather software does it a bit differently, that seemed the sensible thing to do :)

Best regards,
Ken
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: Now available: AJAX/PHP multilingual website templates

Post by gemini06720 »

beteljuice wrote:Link: strtotime() function
beteljuice, thank you for the link...

I do not rely on the online PHP manual as I am not always online when I work on scripts/templates - when I need assistance for PHP or CSS or JavaScript while doing some editing, I rely on the CHM help files already installed on my computer (and updated whenever I notice a new version of the help file has been released) and available directly from my editor help menu - the local help file is usually almost always open.

The particular paragraph you quoted was not in my present local help file - I have checked the PHP web site and have downloaded what appears to be a newer release of the help file ... and the quoted paragraph has now been added.
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: Now available: AJAX/PHP multilingual website templates

Post by gemini06720 »

actioman wrote:Thanks Ray, You were fast! :o
Well, I am a retiree and I have a lot of free time to occupy, and I enjoy learning and trying new scripts... :mrgreen:

So, what I did was to look my template over, be completely discussed when I click on the french language option, completely modify the texts to be translated and re-package the template - I do not know who made the original translation, but it was obviously made by someone whom had/has no knowledge of other languages and does not understand that when a word is re-used for different phrases, it cannot simply be separated from the phrase, translated by itself and merge back into the phrase, such as the following code:

Code: Select all

<?php echo langtransstr('High').' '.langtransstr('Temperature'); ?>
which need to be reversed when translated to french (and possibly many other languages):

Code: Select all

<?php echo langtransstr('Temperature').' '.langtransstr('High'); ?>
So, all those separated terms had to be recombined, such as:

Code: Select all

<?php echo langtransstr('High Temperature') ?>
to make translation to other languages more flexible.
actioman wrote:And you still have good memory! ;)
What memory are you writing about Manuel --- I seem to have forgotten... :D
User avatar
saratogaWX
Posts: 1238
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Now available: AJAX/PHP multilingual website templates

Post by saratogaWX »

gemini06720 wrote:
actioman wrote:Thanks Ray, You were fast! :o
Well, I am a retiree and I have a lot of free time to occupy, and I enjoy learning and trying new scripts... :mrgreen:

So, what I did was to look my template over, be completely discussed when I click on the french language option, completely modify the texts to be translated and re-package the template - I do not know who made the original translation, but it was obviously made by someone whom had/has no knowledge of other languages and does not understand that when a word is re-used for different phrases, it cannot simply be separated from the phrase, translated by itself and merge back into the phrase, such as the following code:

Code: Select all

<?php echo langtransstr('High').' '.langtransstr('Temperature'); ?>
which need to be reversed when translated to french (and possibly many other languages):

Code: Select all

<?php echo langtransstr('Temperature').' '.langtransstr('High'); ?>
So, all those separated terms had to be recombined, such as:

Code: Select all

<?php echo langtransstr('High Temperature') ?>
to make translation to other languages more flexible.
That idiot who did the page that "was obviously made by someone whom had/has no knowledge of other languages and does not understand that when a word is re-used for different phrases, it cannot simply be separated from the phrase, translated by itself and merge back into the phrase" is me (but you already knew that since I'd posted the page in the templates).

And, I did it deliberately, not to tweak your language sensitivity, but instead, it was to maximize reuse of the simple words already translated in the languages supplied with the Base-World template.

I've never met anyone who had such a strong disdain for possibly grammatically-incorrect language usage before, but it is a bit tiring to see your rants about the (French) language usage. Strangely enough, with many international sites using the templates with multiple languages, you are the only critic ... possibly you are just too sensitive on what is correct instead of what is usable.

The key point is to have the data labels understandable to a native speaker as a courtesy, not to have perfection in the mechanical translation lookup.

You are free to modify the code as you see fit, just kindly refrain from the righteous umbrage and denigration of the efforts of those trying to make the personal weather websites understandable to a wider audience.

BTW... instead of "discussed", I think you meant "disgusted" in your posting.
JESUS HEREDERO
Posts: 12
Joined: Fri 19 Mar 2010 12:19 pm
Weather Station: PCE-FWS 20 = VH1080/81
Operating System: VISTA

Re: Now available: AJAX/PHP multilingual website templates

Post by JESUS HEREDERO »

good afternoon Ken:

In the file wxcurecords.php out the initial date of 1970 which is what must be corrected to take the current date or date of events.

The two files that are in the post are equal and are not corrected as of the date, say to correct month dd yyyy and I want to get the date is dd mm yy.

Thanks

Jesus
JESUS
User avatar
saratogaWX
Posts: 1238
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Now available: AJAX/PHP multilingual website templates

Post by saratogaWX »

JESUS HEREDERO wrote:good afternoon Ken:

In the file wxcurecords.php out the initial date of 1970 which is what must be corrected to take the current date or date of events.

The two files that are in the post are equal and are not corrected as of the date, say to correct month dd yyyy and I want to get the date is dd mm yy.

Thanks

Jesus
Hi Jesus,

The problem is that your weather station is uploading the records dates with Spanish month names. If you put in Settings.php

Code: Select all

$SITE['monthNames'] = array(
"Enero","Febrero","Marzo","Abril","Mayo",
			"Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"
);
then the dates should show correctly. For that setting, you currently have the English month names (default) in Settings.php.

Best regards,
Ken

Ref: website http://meteoestremera.es/tiempo/wxindex.php
JESUS HEREDERO
Posts: 12
Joined: Fri 19 Mar 2010 12:19 pm
Weather Station: PCE-FWS 20 = VH1080/81
Operating System: VISTA

Re: Now available: AJAX/PHP multilingual website templates

Post by JESUS HEREDERO »

Thanks Ken

Work.

You remind me of a professor of mathematics "very good" that made me understand them correctly. I'd love to have you as a professor of computer science. Learn much
JESUS
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: Now available: AJAX/PHP multilingual website templates

Post by n9mfk »

Hi Ken,
on the moon page is there a way to switch GMT to UTC
thanks Beau
User avatar
saratogaWX
Posts: 1238
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Now available: AJAX/PHP multilingual website templates

Post by saratogaWX »

JESUS HEREDERO wrote:Thanks Ken

Work.

You remind me of a professor of mathematics "very good" that made me understand them correctly. I'd love to have you as a professor of computer science. Learn much
:oops: Thanks, Jesus .. I'm glad I could be of assistance :)
n9mfk wrote:Hi Ken,
on the moon page is there a way to switch GMT to UTC
thanks Beau
Ummm... not at present. The 'T' argument on the date() string in PHP returns 'GMT' for basic server time (not 'UTC'). For most purposes, the terms are synonymous except where high precision is needed (and this case doesn't require high precision).
Was there a special reason for wanting it to show 'UTC' instead of 'GMT' from the cGetMoonInfo() function inside of common.php?

Best regards,
Ken
Post Reply