Hi all,
I've been thinking about how to make PHP Weather more extensible. The
solution has to be object-oriented programming.
That way, it should be easy to extend PHP Weather, so that it uses a
different kind of database. But I also plan to use objects to make the
translations better.
The idea is this: The current system works reasonable well. Most
sentences can be translated by using format-strings, at least, as long
there's only one variable in each sentence.
But with some languages (French and Polish, I believe), it's hard to
make a good translation by using only format-strings.
By making each language a different object, it would be possible for
the French object, to override the methods in a more common
language-object, that is causing the trouble.
One doesn't have to override every method, so most of the code from
the common language-object will be reused. All the methods in the
common class, should use format-strings for the formatting. This means
that we can keep the current system with a locale-file for each
language, thus making it easy for non-programmers to make a
translation.
So, please have a look at these files. I'm particular interested in
knowing, whether or not this code works in PHP3. I'm not sure that
this works in PHP3:
$obj->db->query('SELECT * FROM metars');
So, please report any problems you have with the code.
Currently they show how I'm going to do the database-abstraction. They
support two database-engines: 'mysql' and 'none'. The 'none'
database-engine just returns false on every query, so the script gets
the METARs directly from the source.
index.php
error_handling.inc
db_layer.inc
mysql_db.inc
none_db.inc
data_retrieval.inc
--
Best regards,
Martin Geisler
Checkout http://www.gimpster.com for:
PHP Weather => Shows the current weather on your webpages.
PHP Shell => A telnet-connection (almost :-) in a PHP page.