Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: /www/gimpster.com/php/phpweather/locales/locale_common.php
PHP Weather - PHP Weather

locale_common

base_object
   |
  +-- locale_common

Provides all the function needed to generate (English) output.

 

private class locale_common extends base_object

Provides all the function needed to generate (English) output.
This class has the capability to do a pretty-print, if it is provided with the right set of strings. It's up to child-classes to provide these strings, and override the methods in this class, as necessary. The logic in the pretty-print is built around the English output, but it should still be possible to make a good translation, by just translating the strings.

AuthorsMartin Geisler <gimpster@gimpster.com>
Versionlocale_common.html,v 1.8 2001/06/27 11:35:43 gimpster Exp

 
Direct known subclasses: locale_en

Methods inherited from base_object

base_object, error, debug, print_properties

Public Method Summary

void

locale_common(array $input)

Constructor.
void

set_marks(string $new_mark_begin, string $new_mark_end)

Sets the marks (the strings inserted before and after every number)
array

get_marks()

Gets the marks
void

set_pref_units(string $new_pref_units)

Specifies which kind of units to display.
string

get_pref_units()

Gets the preferred units.
void

set_exclude(array $new_exclude)

Used to specify which elements one wants to exclude from the pretty-print.
array

get_exclude()

Gets the array of excluded elements of the pretty-print.
string

print_pretty(array $data)

The pretty-print function.
string

print_table(array $data)

Makes a short weather-report in a table.

Private Method Summary

string

pref_units(string $str1, string $str2)

Used to format strings with regard to the preferred units.
string

list_sentences()

Builds sentences from smaller bits.
string

parse_precip(integer $in, integer $mm)

Used to parse precipitation.
string

parse_cloud_group(array $cloud_group)

Function used to parse a cloud-group.
string

parse_weather_group(array $weather_group)

Function used to parse a weather-group.
string

runway_tendency(string $tendency)

Function used to parse the tendency in a runway-group.
string

parse_runway_group(array $runway_group)

Function used to parse a runway-group.
string

parse_visibility_group(array $visibility_group)

Function used to parse a visibility-group.

Fields inherited from base_object

$properties, $version

Private Field Summary

array

$strings

The strings used in the translation is stored here.

Public Method Details

locale_common

public void locale_common( array $input )

  Constructor.

Parameter
array $input
initial properties of the object. If you omit some properties, the defaults will kick-in.
Returns void


set_marks

public void set_marks( string $new_mark_begin, string $new_mark_end )

  Sets the marks (the strings inserted before and after every number)

Parameter
string $new_mark_begin
mark used before numbers and other data elements, for example '<font color="red">'
string $new_mark_end
mark used after numbers and other data elements, for example '</font>'. If you use HTML tags, it's your responsibility to ensure that they match up. If they don't, then you pages might not render properly.
Returns void

See Also get_marks()

get_marks

public array get_marks( )

  Gets the marks

Returns array

The first element is the string is inserted before any number, and the second element is the string inserted after. The first element is also know as 'mark_begin' and the second as 'mark_end'.

See Also set_marks()

set_pref_units

public void set_pref_units( string $new_pref_units )

  Specifies which kind of units to display.
$new_pref_units can be one of the following strings:- 'both_metric' if one wants to produce output like this '10 kilometers (16.1 miles)'- 'both_imperial' if one wants to produce output like this '16.1 miles (10 kilometers)'- 'only_metric' if one wants to produce output like this '10 kilometers'- 'only_imperial' if one wants to produce output like this '16.1 miles'If $new_pref_units isn't recognized, 'both_imperial' will be used instead.

Parameter
string $new_pref_units
new kind of units one wants to use.
Returns void

See Also get_pref_units()

get_pref_units

public string get_pref_units( )

  Gets the preferred units.

Returns string

The preferred kind of units. This will be one of 'both_metric', 'both_imperial', 'only_metric' or 'only_imperial'.

See Also set_pref_units()

set_exclude

public void set_exclude( array $new_exclude )

  Used to specify which elements one wants to exclude from the pretty-print.

Parameter
array $new_exclude
array should contain the names of the sections one doesn't want to have displayed, like 'wind' or 'time' if one wants to skip the wind or time parts of the pretty-print.
Returns void

See Also get_exclude()

get_exclude

public array get_exclude( )

  Gets the array of excluded elements of the pretty-print.

Returns array

The excluded elements.

See Also set_exclude()

print_pretty

public string print_pretty( array $data )

  The pretty-print function.
This is the function responsible for making the weather-report, also know as the 'pretty-print'.

Parameter
array $data
taken from decode_metar()
Returns string

The pretty-printed output.


print_table

public string print_table( array $data )

  Makes a short weather-report in a table.

Parameter
array $data
taken from decode_metar()
Returns string

The table with weather-data.


Private Method Details

pref_units

private string pref_units( string $str1, string $str2 )

  Used to format strings with regard to the preferred units.
If 'pref_units' isn't recognized, the function will set it to 'both_imperial', and try again.

Parameter
string $str1
string should always contain the metric value.
string $str2
string should always contain the imperial value.
Returns string

The two arguments in the correct order with regard to the preferred units.

See Also set_pref_units()

list_sentences

private string list_sentences( )

  Builds sentences from smaller bits.
Takes an arbitrary number of strings as its arguments, and returns them with commas between. The strings used between the arguments, are controlled by these variables:- $strings['list_sentences_and']- $strings['list_sentences_comma']- $strings['list_sentences_final_and']Only non-empty arguments are used, so it's safe to call this function with empty strings. But if you try to call it with uninitialized variables, then PHP might warn you about it anyway.

Returns string

The arguments put together.


parse_precip

private string parse_precip( integer $in, integer $mm )

  Used to parse precipitation.

Parameter
integer $in
amount of precipitation measured in inches.
integer $mm
amount of precipitation measured in millimeters.
Returns string

A formatted string with information about the precipitation.


parse_cloud_group

private string parse_cloud_group( array $cloud_group )

  Function used to parse a cloud-group.

Parameter
array $cloud_group
cloud-group to be parsed. This should be a group as parse_metar() would return it.
Returns string

the string used in the pretty-print.


parse_weather_group

private string parse_weather_group( array $weather_group )

  Function used to parse a weather-group.

Parameter
array $weather_group
weather-group to be parsed.
Returns string

the string used in the pretty-print.


runway_tendency

private string runway_tendency( string $tendency )

  Function used to parse the tendency in a runway-group.

Parameter
string $tendency
tendency
Returns string

the string used in the pretty-print.


parse_runway_group

private string parse_runway_group( array $runway_group )

  Function used to parse a runway-group.

Parameter
array $runway_group
runway-group to be parsed.
Returns string

the string used in the pretty-print.


parse_visibility_group

private string parse_visibility_group( array $visibility_group )

  Function used to parse a visibility-group.

Parameter
array $visibility_group
visibility-group to be parsed.
Returns string

the string used in the pretty-print.


Private Field Details

$strings

private array $strings

>>array()<<

The strings used in the translation is stored here.
Each string is identified by it's key in the array. Some strings are used between the dynamic parts, and others are used as format-strings to sprintf().



Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta