B4A Library ICOSWorldForecast 3.50

View attachment 14755 View attachment 14754 View attachment 16846 Hi guys, ICOSWorldForecast is here.


It's a pleasure to introduce the new library of weather forecast.

The zip include:

The library, and the demo

INSTALLATION:

Copy the Library in your Basic For Android Library.

Copy the folder weathericon is located in files in the demo. In your one.


RENAME:
ICOSWorldForecast2.71.part1.zip and ICOSWorldForecast2.71.part2.zip

TO:
ICOSWorldForecast2.71.part1.rar and ICOSWorldForecast2.71.part1.rar

In this version I add WeatherUrl and 2 more days forecast.

You can use your own icons, instead of my icons.

For this new version 2.71 you need the new key.

You must register to obtain the new key, otherwise you will get error.

Use the address below to register.

World Weather Online - Welcome to the World Weather Online Developer Network!

don't forget to replace the ApiKey="XXXXXXXXXXXXXX" with your private key

This demos, I made with my galaxy tab 7 600x1024

any question or bugs please report to me.

big Thx to warwound for is fantastic auto-generated reference.


ICOSWorldForecast
Author:
Giuseppe Salvi
Version: 2.81
  • ICOSWorldForecast
    Methods:
    • FCDate (index As Int) As String
      Return Date for which the weather is forecasted
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCDate(0)
    • FCIcon (index As Int) As Bitmap
      Return Weather symbol image
      example:
      Dim a As ICOSWorldForecast
      Image1.SetBackgroundImage=a.FCWeatherIcon(0)
    • FCIconUrl (index As Int) As String
      Return URLIcon For Forecast Condition
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCIconUrl(0)
    • FCPrecipitationMM (index As Int) As String
      Return Precipitation amount in millimeter
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCPrecipitationMM(0)
    • FCTempMaxCelsius (index As Int) As String
      Return Day and night max temperature in Celcius
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMaxCelsius(0)
    • FCTempMaxFahrenheit (index As Int) As String
      Return Day and night max temperature in Fahrenheit
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMaxFahrenheit(0)
    • FCTempMinCelsius (index As Int) As String
      Return Day and night min temperature in Celcius
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMinCelsius(0)
    • FCTempMinFahrenheit (index As Int) As String
      Return Day and night max temperature in Fahrenheit
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMinFahrenheit(0)
    • FCWeatherCode (index As Int) As String
      Return Weather Code
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWeatherCode(0)
    • FCWeatherDesc (index As Int) As String
      Return Weather description
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWeatherDesc(0)
    • FCWinddir16Point (index As Int) As String
      Return 16-Point compass wind direction
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWinddir16Point(0)
    • FCWinddirDegree (index As Int) As String
      Return Wind direction in degree
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWinddirDegree(0)
    • FCWinddirection (index As Int) As String
      Return Compass Wind direction
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWinddirection(0)
    • FCWindspeedKmph (index As Int) As String
      Return Wind speed in kilometer per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWindspeedKmph(0)
    • FCWindspeedMiles (index As Int) As String
      Return Wind speed in Miles per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWindspeedMiles(0)
    • FindLatAndLong As String
      Retrieve accurate latitude and longitude from GPS or network services
    • FindLocation As String
      Retrieve accurate location from GPS or network services
    • Full7DayName (day As Int) As String
      Return Full name of the day ( Monday )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Full7DayName(0) ' 0 = today - 1 = tomorrow etc etc
    • GetList (mCity As String) As ArrayList
      Set the City Name you wish to get the weather
      example:
      Dim a As ICOSWorldForecast
      Dim l As List
      Dim lv1 As ListView
      l = a.GetList("Los Angeles")
      For n = 0 To l.Size-1
      lv1.AddSingleLine(l.Get(n))
      Next
      Sub lv1_ItemClick (Position As Int, Value As Object)ics.CityName = lv1.GetItem(Position)
      lv1.Clear
      End Sub
    • Initialize (EventName As String)
      Initilize the object
    • Short7DayName (day As Int) As String
      Return Short name of the day ( Mon )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Short7DayName(0) ' 0 = today - 1 = tomorrow etc etc
    • StringFormat (format As String, object As Object, object1 As Object) As String
      Return Formatted String
      example:
      Label1.Text=StringFormat("Lat: %1$s - Long: %2$s ",Latitude,Longitude)
    • isWiFiConnected As Boolean
      Check if WiFi is Connected
    Permissions:
    • android.permission.ACCESS_ASSISTED_GPS
    • android.permission.ACCESS_COARSE_LOCATION
    • android.permission.ACCESS_FINE_LOCATION
    • android.permission.ACCESS_GPS
    • android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
    • android.permission.ACCESS_NETWORK_STATE
    • android.permission.ACCESS_WIFI_STATE
    • android.permission.CONTROL_LOCATION_UPDATES
    • android.permission.INTERNET
    Properties:
    • ApiKey As String [write only]
      Set your personal ApiKey
      example:
      Dim a As ICOSWorldForecast
      a.ApiKey="XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    • AreaName As String [read only]
      Return Name of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.AreaName
    • CCCloudCover As String [read only]
      Return Cloud Cover in %
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCCloudCover
    • CCHumidity As String [read only]
      Return Humidity in %
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCHumidity
    • CCIcon As Bitmap [read only]
      Return Weather symbol image
      example:
      Dim a As ICOSWorldForecast
      Image1.SetBackgroundImage=a.CCWeatherIcon
    • CCIconUrl As String [read only]
      Return URLIcon For Current Condition
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCIconUrl
    • CCLocalObsDateTime As String [read only]
      Return Local Observation date and time
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCLocalObsDateTime
    • CCObservationTime As String [read only]
      Return Observation time (UTC)
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCObservationTime
    • CCPrecipitationMM As String [read only]
      Return Precipitation Amount in Millimeter
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.PrecipitationMM
    • CCPressure As String [read only]
      Return Atmospheric pressure in Milibars
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCPressure
    • CCTempCelsius As String [read only]
      Return Temperature in Celsius
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCTempCelsius
    • CCTempFahrenheit As String [read only]
      Return Temperature in Fahrenheit
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCTempFahrenheit
    • CCVisibility As String [read only]
      Return Visibility kilometers per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCVisibility
    • CCWeatherCode As String [read only]
      Return Weather Code
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWeatherCode
    • CCWeatherDescription As String [read only]
      Return Weather Description
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWeatherDescription
    • CCWinddir16Point As String [read only]
      Return 16-Point wind direction compass
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWinddir16Point
    • CCWinddirDegree As String [read only]
      Return Wind direction in degree
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWinddirDegree
    • CCWindspeedKmph As String [read only]
      Return Wind speed in kilometer per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWindspeedKmph
    • CCWindspeedMiles As String [read only]
      Return Wind speed in Miles per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWindspeedMiles
    • CityName As String [write only]
      Set City you wish to get the weather
      example:
      Dim a As ICOSWorldForecast
      a.CityName="New York"
    • Country As String [read only]
      Return Name of the Country
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Country
    • CurrentDate As String [read only]
      Return Current Day,Month,Year ( Friday, 28 September, 2012 )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CurrentDate
    • CurrentTime As String [read only]
      Return Current time ( 02.09 PM )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CurrentTime
    • DstOffset As String [read only]
      Return DstOffset = ( GMT +2 )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.DstOffset
    • GmtOffset As String [read only]
      Return GmtOffset = ( GMT +1 )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.GmtOffset
    • LatAndLong As String [write only]
      Set Lat and Long you wish to get the weather
      example:
      Dim a As ICOSWorldForecast
      a.LatAndLong="40.714,-74.006"
    • Latitude As Object [read only]
      Return Latitude of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Latitude
    • Longitude As Object [read only]
      Return Longitude of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Longitude
    • Population As String [read only]
      Return Population of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Population
    • Region As String [read only]
      Return Name of the Region
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Region
    • Sunrise As String [read only]
      Return Sunrise = 06:04
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Sunrise
    • Sunset As String [read only]
      Return Sunset = 19:36
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Sunset
    • TimeZoneID As String [read only]
      Return TimeZoneID = Europe/Rome
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.TimeZoneID
    • Version As Double [read only]
      Return the version of this library
    • WeatherUrl As String [read only]
      Return url of the city [ http://www.worldweatheronline.com/London-weather/City-of-London-Greater-London/GB.aspx ]
      example:
      Dim Webview1 As Webview
      Webview1.LoadUrl(a.WeatherUrl)
 

Attachments

  • ICOSWorldForecast_DEMO.part1.zip
    293 KB · Views: 983
  • ICOSWorldForecast_DEMO.part2.zip
    167.1 KB · Views: 787
  • Main.png
    Main.png
    86.8 KB · Views: 936
  • Widget.jpg
    Widget.jpg
    81.8 KB · Views: 922
  • ICOSWorldForecast.png
    ICOSWorldForecast.png
    156.3 KB · Views: 983
  • ICOSWorldForecastFree_v3.50_lib_fix.zip
    53.9 KB · Views: 532
Last edited:

microbox

Active Member
Licensed User
Longtime User

Laurent95

Active Member
Licensed User
Longtime User
Hello there, I want to try the example given...but I'm lost during the process. Please give guidance...
I Downloaded the ICOSWorldForecastFree-Lib_v3.10.zip and unzip files copied to library folder. I then download ICOSWorldForecast_DEMO.part1.zip and ICOSWorldForecast_DEMO.part2.zip and rename to ICOSWorldForecast_DEMO.part1.rar/ICOSWorldForecast_DEMO.part2.rar but when unzipping them it contains Files folder only. What do you think I'm doing bad?

Thanks in advance,
tacbanon

Hello,
You probably had does a mistake somewhere.
I have try again the download and the two parts are different, the second contains the B4A files and a bit more folder resources.
Which zipper you use ? I have Winrar and no problem with it.

@Giuseppe,
Hi and thanks for the new version, that works like a charm. My widget has got a new teen age now ;)
Grazie
 

microbox

Active Member
Licensed User
Longtime User
Hi, thanks for replying. I have winrar...I'll try it again.

kind regards,
tacbanon
 

microbox

Active Member
Licensed User
Longtime User
Hi..I'm sorry if this is so basic but I'm having trouble with the right files when unzipping..
Please check the image I attached.
When I unzipped the ICOSWorldForecast_DEMO.part1.rar it gave me ICOSWorldForecast_DEMO folder and when I tried to unzip the ICOSWorldForecast_DEMO.part2.rar I think it still gave me ICOSWorldForecast_DEMO folder because it warns a file already exist. Hope anyone can shade some light what I'm doing wrong.

Thanks in advance...
 

Attachments

  • ForecastFolder.png
    ForecastFolder.png
    25.9 KB · Views: 181

microbox

Active Member
Licensed User
Longtime User
Hi, I just download the demo par 1 and part 2 i dind rename it, just unrar successfully.


P.S.

This is the first demo whit the first library U've to cange Dim a as ICOSWorldForecast to dim a as ICOSWorldForecastFree
Hi thanks for the time...I did follow your advice (change Dim a as ICOSWorldForecast to dim a as ICOSWorldForecastFree) but it gives an error when compiling

B4X:
Parsing code.                          0.02
Compiling code.                        Error
Error compiling program.
Error description: Unknown member: getlist
Occurred on line: 46
l=a.GetList(mGetList)
Word: getlist
any idea what I'm missing?
 

Laurent95

Active Member
Licensed User
Longtime User
Hi thanks for the time...I did follow your advice (change Dim a as ICOSWorldForecast to dim a as ICOSWorldForecastFree) but it gives an error when compiling

B4X:
Parsing code.                          0.02
Compiling code.                        Error
Error compiling program.
Error description: Unknown member: getlist
Occurred on line: 46
l=a.GetList(mGetList)
Word: getlist
any idea what I'm missing?

Yeah you haven't only the ICOSWorldForecastFree who has changed since the first version.
You have also this one, GetCityList for GetList.

But, you seem also a newby with B4A, otherwise you know that if you typing the dot after any instance of an object in your code, you have all the functions and properties who are accessible in a list. Even for some a pop up with sometime an example.

Then you can choose one, with mouse or arrows for navigate, and validate with a click or the "Tab" touch.
And, also, you can control if the property is correctly spelled or not ;)
(no worries if you have the old spelling who stay or not, if you typing a dot again, you will have the list)

Good programing now.
 

microbox

Active Member
Licensed User
Longtime User
Yeah you haven't only the ICOSWorldForecastFree who has changed since the first version.
You have also this one, GetCityList for GetList.

But, you seem also a newby with B4A, otherwise you know that if you typing the dot after any instance of an object in your code, you have all the functions and properties who are accessible in a list. Even for some a pop up with sometime an example.

Then you can choose one, with mouse or arrows for navigate, and validate with a click or the "Tab" touch.
And, also, you can control if the property is correctly spelled or not ;)
(no worries if you have the old spelling who stay or not, if you typing a dot again, you will have the list)

Good programing now.

Hi Laurent95...I appreciate very much for helping me out. I got it now(compiled)...
I'm learning little by little with b4a.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi, microbox I appreciate too the Laurent's help but did U see that U've also SearchCity exsample:

B4X:
Sub Globals   
 
   Dim da As ICOSForecastGetList
   Dim ed0 As EditText
End Sub



Dim s As String
    If ed0.Text.Length > 0 Then
        Try
          s=da.SearchCity(ed0.Text,"ICOSWorld Forecast Demo v3.00",True)
            If s.Length > 0 Then
          a.CityName=s
          StartActivity(Forecast)
          End If
        Catch
          ToastMessageShow(" Probably server error!! ",True)
        End Try
    End If


it's more better than GetCityList
 

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent95...I appreciate very much for helping me out. I got it now(compiled)...
I'm learning little by little with b4a.

You're welcome, it's very nice that it works for you now.
The example of Giuseppe gives you more about the library who is really useful.
B4A is also a very good tool for programming under Android, simple and complete

@Giuseppe,
Why you say it's better with the SearchCity than GesCityList ?
I ask because you know that i use it with a widget, then i can't use a function with a dialog box, otherwise i get an error.
Thanks for reply.

Best regards to all.
 

GMan

Well-Known Member
Licensed User
Longtime User
Some years ago i worked with this API with VisualBasic and wrote a little translation for the weather descriptions to German.
It was easy to adopt it, so here it is.

I call the sub after setting the CCWeatherDescription value to lb1 (Label):
B4X:
DateTime.DateFormat = "dd.MM.yyyy"
lb1.Text = a.CCWeatherDescription
WeatherTrans ' Translate


B4X:
Sub WeatherTrans
'    Translator CCWEATHERDISCRIPTION > DE by GMAN
    If lb1.Text <> "" Then
    Select True
        Case lb1.Text.Contains("Sunny")
            lb1.Text = "Sonnig"
        Case lb1.Text.Contains("Clear")
            lb1.Text = "Klar"
        Case lb1.Text.Contains("Clear/Sunny")
            lb1.Text = "Klar & Sonnig"   
        Case lb1.Text.Contains("Cloudy")
            lb1.Text = "Bewölkt"
        Case lb1.Text.Contains("Partly Cloudy")
            lb1.Text = "teilweise Bewölkt"
        Case lb1.Text.Contains("Snowy")
            lb1.Text = "Schnee"
        Case lb1.Text.Contains("Stormy")
            lb1.Text = "Sturm"
        Case lb1.Text.Contains("Mist")
            lb1.Text = "Dunst"
        Case lb1.Text.Contains("Moderate rain")
            lb1.Text = "Regen"   
        Case lb1.Text.Contains("Light rain")
            lb1.Text = "leichter Regen"
        Case lb1.Text.Contains("Moderate rain at times")
            lb1.Text = "zeitweise Schauer"
        Case lb1.Text.Contains("Heavy rain at times")
            lb1.Text = "zeitweise starke Schauer"
        Case lb1.Text.Contains("Heavy rain")
            lb1.Text = "starker Regen"
        Case lb1.Text.Contains("Light freezing rain")
            lb1.Text = "leichter gefrierender Regen"
        Case lb1.Text.Contains("Moderate OR Heavy freezing rain")
            lb1.Text = "mittlerer bis starker gefrierender Regen"
        Case lb1.Text.Contains("Light drizzle")
            lb1.Text = "leichter Nieselregen"
        Case lb1.Text.Contains("Fog")
            lb1.Text = "Nebel"
        Case lb1.Text.Contains("Overcast")
            lb1.Text = "Bewölkt"
        Case lb1.Text.Contains("Light rain shower")
            lb1.Text = "leichte Regenschauer"
        Case lb1.Text.Contains("Moderate OR heavy rain shower")
            lb1.Text = "mittlere bis starke Regenschauer"
        Case lb1.Text.Contains("Torrential rain shower")
            lb1.Text = "Sintflutartige Regenfälle !"
        Case lb1.Text.Contains("Light sleet showers")
            lb1.Text = "leichte Graupelschauer"
        Case lb1.Text.Contains("Moderate OR heavy sleet showers")
            lb1.Text = "mittlere bis starke Graupelschauer"
        Case lb1.Text.Contains("Moderate OR heavy snow showers")
            lb1.Text = "mittlere bis starke Schneeschauer"
        Case lb1.Text.Contains("Light showers of ice pellets")
            lb1.Text = "leichte Hagelschauer"
        Case lb1.Text.Contains("Light snow showers")
            lb1.Text = "leichte Schneeschauer"
        Case lb1.Text.Contains("Moderate OR heavy showers of ice pellets")
            lb1.Text = "mittlere bis starke Hagelschauer"
        Case lb1.Text.Contains("Patchy light rain In area with thunder")
            lb1.Text = "leichter örtlicher Regen mit Donner"
        Case lb1.Text.Contains("Moderate OR heavy rain In area with thunder")
            lb1.Text = "mittlere bis starker örtlicher Regen mit Donner"
        Case lb1.Text.Contains("Patchy light snow In area with thunder")
            lb1.Text = "leichter örtlicher Schnee mit Donner"
        Case lb1.Text.Contains("Moderate OR heavy snow In area with thunder")
            lb1.Text = "mittlere bis starker örtlicher Schnee mit Donner"
        Case lb1.Text.Contains("Ice pellets")
            lb1.Text = "Hagel"
        Case lb1.Text.Contains("Heavy snow")
            lb1.Text = "starker Schneefall"
        Case lb1.Text.Contains("Patchy heavy snow")
            lb1.Text = "teilweise starker Schnee"
        Case lb1.Text.Contains("Moderate snow")
            lb1.Text = "mittlerer Schnee"
        Case lb1.Text.Contains("Patchy moderate snow")
            lb1.Text = "teilweise mittlerer Schnee"
        Case lb1.Text.Contains("Light snow")
            lb1.Text = "leichter Schnee"
        Case lb1.Text.Contains("Patchy light snow")
            lb1.Text = "teilweise leichter Schnee"
        Case lb1.Text.Contains("Moderate OR heavy sleet")
            lb1.Text = "mittlerer bis starker Schnee"
        Case lb1.Text.Contains("Light sleet")
            lb1.Text = "leichter Schneeregen"
        Case lb1.Text.Contains("Patchy light rain")
            lb1.Text = "teilweise leichter Regen"
        Case lb1.Text.Contains("Heavy freezing drizzle")
            lb1.Text = "starker gefrierender Nieselregen"
        Case lb1.Text.Contains("Freezing drizzle")
            lb1.Text = "gefrierender Nieselregen"
        Case lb1.Text.Contains("Patchy light drizzle")
            lb1.Text = "teilweise leichter Nieselregen"
        Case lb1.Text.Contains("Freezing fog")
            lb1.Text = "gefrierender Nebel"
        Case lb1.Text.Contains("Blizzard")
            lb1.Text = "Schneesturm"
        Case lb1.Text.Contains("Blowing snow")
            lb1.Text = "Schneetreiben"
        Case lb1.Text.Contains("Thundery outbreaks In nearby")
            lb1.Text = "Gewitter in der Nähe"
        Case lb1.Text.Contains("Patchy freezing drizzle nearby")
            lb1.Text = "teilweise gefrierender Nieselregen in der Nähe"
        Case lb1.Text.Contains("Patchy sleet nearby")
            lb1.Text = "leichter Schneeregen in der Nähe"
        Case lb1.Text.Contains("Patchy snow nearby")
            lb1.Text = "leichter Schneefall in der Nähe"
        Case lb1.Text.Contains("Patchy rain nearby")
            lb1.Text = "leichter Regen in der Nähe"
    End Select
    End If
End Sub
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Laurent, some time ago i think Dominex asked me why when He used GetList after he used FindLocation and WeaterByLocalIpAddress He got the same city from GetList.
I found the bug and fixed and that's why I implemented also SearchCity.

The bug was in List example:

Dim l as List

l.Initialize

l = getlist after this calling FindLocation and WeaterByLocalIpAddress gave the same city.
 
Last edited:

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, some time ago i think Dominex asked me why when He used GetList after he used FindLocation and WeaterByLocalIpAddress He got the same city from GetList.
I found the bug and fixed and that's why I implemented also SearchCity.

The bug was in List example:

Dim l as List

l.Initialize

l = getlist after this calling FindLocation and WeaterByLocalIpAddress gave the same city.

Hi Giuseppe, ok for that.

For the second reply to GMan, i send you below an extract of my "French" string.xml for my widget.
That contains all translation for the weather by code of WWO, if it can help.

And emmmmm forgive me for Japanese and Chinese if i pass the hand ;)

@GMan, thank you for sharing, now i will use it for be sure that my German translation is good :)

Regards.
 

Attachments

  • FrenchCodeStrings.zip
    733 bytes · Views: 195

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, thank you so much for the translation. I hope that others send other translations.

You're welcome, just i am interrogate me with the translation of GMan.

@GMan, without abuse of your time, can i ask if you can indicate us the codes of "World Weather Online" for your translation.
I don't find several of them like :
Snowy, Stormy

Unless if i have does a mistake when i got the WWO codes.
Thanks by advance if you can do it.

For now i will build the same Sub like you but with French translation, who could help some developer.

Regards
 

Laurent95

Active Member
Licensed User
Longtime User
Some years ago i worked with this API with VisualBasic and wrote a little translation for the weather descriptions to German.
It was easy to adopt it, so here it is.

As i have say i have translated this code for French.
B4X:
Sub WeatherTrans
'  Translator CCWEATHERDESCRIPTION > FR by Laurent From the code of GMan
    If lb1.Text <> "" Then
        Select True
            Case lb1.Text.Contains("Sunny")                                            'Code 113
                lb1.Text = "Ensoleillé"
            Case lb1.Text.Contains("Clear")                                            'Code 113
                lb1.Text = "Clair"
            Case lb1.Text.Contains("Clear/Sunny")                                    'Code 113
                lb1.Text = "Clair & Ensoleillé"
            Case lb1.Text.Contains("Partly Cloudy")                                    'Code 116
                lb1.Text = "Partiellement nuageux"
            Case lb1.Text.Contains("Cloudy")                                        'Code 119
                lb1.Text = "Nuageux"
            Case lb1.Text.Contains("Overcast")                                        'Code 122
                lb1.Text = "Couvert"
            Case lb1.Text.Contains("Snowy")                                            'Not Found in codes
                lb1.Text = "Neigeux"
            Case lb1.Text.Contains("Stormy")                                        'Not Found in codes
                lb1.Text = "Venteux"
            Case lb1.Text.Contains("Mist")                                            'Code 143
                lb1.Text = "Brume"
            Case lb1.Text.Contains("Patchy rain nearby")                            'Code 176
                lb1.Text = "Pluie Légère possible"
            Case lb1.Text.Contains("Patchy snow nearby")                            'Code 179
                lb1.Text = "Neige légère possible"
            Case lb1.Text.Contains("Patchy sleet nearby")                            'Code 182
                lb1.Text = "Légère neige fondue possible"
            Case lb1.Text.Contains("Patchy freezing drizzle nearby")                'Code 185
                lb1.Text = "Légère bruine verglaçante possible"
            Case lb1.Text.Contains("Thundery outbreaks In nearby")                    'Code 200
                lb1.Text = "Orage possible"
            Case lb1.Text.Contains("Blowing snow")                                    'Code 227
                lb1.Text = "Neige poudreuse"
            Case lb1.Text.Contains("Blizzard")                                        'Code 230
                lb1.Text = "Blizzard"
            Case lb1.Text.Contains("Fog")                                            'Code 248
                lb1.Text = "Brouillard"
            Case lb1.Text.Contains("Freezing fog")                                  'Code 260
                lb1.Text = "Brouillard givrant"
            Case lb1.Text.Contains("Patchy light drizzle")                            'Code 263
                lb1.Text = "Faible bruine éparse"
            Case lb1.Text.Contains("Light drizzle")                                    'Code 266
                lb1.Text = "Faible bruine"
            Case lb1.Text.Contains("Freezing drizzle")                                'Code 281
                lb1.Text = "Bruine verglaçante"
            Case lb1.Text.Contains("Heavy freezing drizzle")                        'Code 284
                lb1.Text = "Forte bruine verglaçante"
            Case lb1.Text.Contains("Patchy light rain")                                'Code 293
                lb1.Text = "Légères pluie éparse"
            Case lb1.Text.Contains("Light rain")                                    'Code 296
                lb1.Text = "Légère pluie"
            Case lb1.Text.Contains("Moderate rain at times")                        'Code 299
                lb1.Text = "Pluie modérée intermittente"
            Case lb1.Text.Contains("Moderate rain")                                    'Code 302
                lb1.Text = "Pluie modérée"
            Case lb1.Text.Contains("Heavy rain at times")                            'Code 305
                lb1.Text = "Forte pluie intermittente"
            Case lb1.Text.Contains("Heavy rain")                                    'Code 308
                lb1.Text = "Forte pluie"
            Case lb1.Text.Contains("Light freezing rain")                            'Code 311
                lb1.Text = "Faible pluie verglaçante"
            Case lb1.Text.Contains("Moderate or Heavy freezing rain")                'Code 314
                lb1.Text = "Pluie verglaçante modérée à forte"
            Case lb1.Text.Contains("Light sleet")                                      'Code 317
                lb1.Text = "Neige fondue"
            Case lb1.Text.Contains("Moderate or heavy sleet")                        'Code 320
                lb1.Text = "Neige fondue modérée à forte"
            Case lb1.Text.Contains("Patchy light snow")                                'Code 323
                lb1.Text = "Légère neige éparse"
            Case lb1.Text.Contains("Light snow")                                    'Code 326
                lb1.Text = "Neige légère"
            Case lb1.Text.Contains("Patchy moderate snow")                            'Code 329
                lb1.Text = "Neige modérée éparse"
            Case lb1.Text.Contains("Moderate snow")                                    'Code 332
                lb1.Text = "Neige modérée"
            Case lb1.Text.Contains("Patchy heavy snow")                                'Code 335
                lb1.Text = "Fortes chutes de neige éparses"
            Case lb1.Text.Contains("Heavy snow")                                    'Code 338
                lb1.Text = "Fortes chutes de neige"
            Case lb1.Text.Contains("Ice pellets")                                  'Code 350
                lb1.Text = "Grêle"
            Case lb1.Text.Contains("Light rain shower")                                'Code 353
                lb1.Text = "Averses légères"     
                'Or "Faible pluie" the both are correct
            Case lb1.Text.Contains("Moderate OR heavy rain shower")                    'Code 356
                lb1.Text = "Averses modérées à fortes"   
                'Or "Pluie modérée à forte" the both are correct
            Case lb1.Text.Contains("Torrential rain shower")                        'Code 359
                lb1.Text = "Pluies torrentielles"     
                'Here you can't use "Averses" that not related with torrential
            Case lb1.Text.Contains("Light sleet showers")                            'Code 362
                lb1.Text = "Averses de neige fondue éparses"
            Case lb1.Text.Contains("Moderate OR heavy sleet showers")                'Code 365
                lb1.Text = "Averses de neige fondue modérés à fortes"
            Case lb1.Text.Contains("Light snow showers")                            'Code 368
                lb1.Text = "Averses de neige légères"
            Case lb1.Text.Contains("Moderate OR heavy snow showers")                'Code 371
                lb1.Text = "Averses de neige modérées à fortes"
            Case lb1.Text.Contains("Light showers of ice pellets")                    'Code 374
                lb1.Text = "Faibles averses de grêlons"
            Case lb1.Text.Contains("Moderate OR heavy showers of ice pellets")        'Code 377
                lb1.Text = "Averses modérées à fortes de grêlons"
            Case lb1.Text.Contains("Patchy light rain In area with thunder")        'Code 386
                lb1.Text = "Pluie légère éparse avec orage"
            Case lb1.Text.Contains("Moderate OR heavy rain In area with thunder")    'Code 389
                lb1.Text = "Pluie modérée à forte avec orage"
            Case lb1.Text.Contains("Patchy light snow In area with thunder")        'Code 392
                lb1.Text = "Neige légère éparses avec orage"
            Case lb1.Text.Contains("Moderate OR heavy snow In area with thunder")    'Code 395
                lb1.Text = "Neige modérée à forte avec orage"
        End Select
    End If
End Sub

It's done.
Another possibility for use with the library, and a string.xml file like i post before.
B4X:
Sub Globals
    'The instance of Giuseppe's library
    Dim weather As ICOSWorldForecastFree
    'Access to the android application resources (for the translation)
    Dim AResource1 As AndroidResources
End Sub

    Dim lblDescr As Label
    CCCode = weather.CCWeatherCode
    lblDescr.Text = AResource1.GetApplicationString("Code"&CCCode)

Of course you need to add the AndroidResources library to your project.

Regards
 

GMan

Well-Known Member
Licensed User
Longtime User
Hi GMan, thanks for this routine, I'll implements it directly in the library.
If anyone else is interested in translating into other languages, so that it becomes MultiLanguage.
Feel free to do so :)
In addition is here a DUTCH and a POLISH translation (ok ok, very strange languages but all of my soft (win or android or whatever) is multi-lingual, and always (beneath ES,IT,EN,DE and CN) theese two are implemented, too :cool:

1. in de Nederlandse taal:
B4X:
Sub WeatherTrans
'    Translator CCWEATHERDISCRIPTION > NL by GMAN
    If lb1.Text <> "" Then
    Select True
        Case lb1.Text.Contains("Sunny")
            lb1.Text = "Zonnig"
        Case lb1.Text.Contains("Clear")
            lb1.Text = "Helder"
        Case lb1.Text.Contains("Clear/Sunny")
            lb1.Text = "Helder & Zonnig"   
        Case lb1.Text.Contains("Cloudy")
            lb1.Text = "Bewolkt"
        Case lb1.Text.Contains("Partly Cloudy")
            lb1.Text = "Gedeeltelijk bewolkt"
        Case lb1.Text.Contains("Snowy")
            lb1.Text = "Besneeuwd"
        Case lb1.Text.Contains("Stormy")
            lb1.Text = "Atormachtig"
        Case lb1.Text.Contains("Mist")
            lb1.Text = "Floers"
        Case lb1.Text.Contains("Moderate rain")
            lb1.Text = "Matige Regen"   
        Case lb1.Text.Contains("Light rain")
            lb1.Text = "Lichte Regen"
        Case lb1.Text.Contains("Moderate rain at times")
            lb1.Text = "Matige Regen in tijden"
        Case lb1.Text.Contains("Heavy rain at times")
            lb1.Text = "Zware Regen in tijden"
        Case lb1.Text.Contains("Heavy rain")
            lb1.Text = "Zware Regenval"
        Case lb1.Text.Contains("Light freezing rain")
            lb1.Text = "Lichte aanvriezende Regen"
        Case lb1.Text.Contains("Moderate OR Heavy freezing rain")
            lb1.Text = "Matige of zware bevriezing regen"
        Case lb1.Text.Contains("Light drizzle")
            lb1.Text = "Lichte motregen"
        Case lb1.Text.Contains("Fog")
            lb1.Text = "Nevel"
        Case lb1.Text.Contains("Overcast")
            lb1.Text = "Bewolking"
        Case lb1.Text.Contains("Light rain shower")
            lb1.Text = "Lichte regen douche"
        Case lb1.Text.Contains("Moderate OR heavy rain shower")
            lb1.Text = "Matige of zware regenbui"
        Case lb1.Text.Contains("Torrential rain shower")
            lb1.Text = "Hevige regenbui !"
        Case lb1.Text.Contains("Light sleet showers")
            lb1.Text = "Lichte natte sneeuwbuien"
        Case lb1.Text.Contains("Moderate OR heavy sleet showers")
            lb1.Text = "Matige of zware natte sneeuwbuien"
        Case lb1.Text.Contains("Moderate OR heavy snow showers")
            lb1.Text = "Matige of zware sneeuwbuien"
        Case lb1.Text.Contains("Light showers of ice pellets")
            lb1.Text = "Buien ijs pellets"
        Case lb1.Text.Contains("Light snow showers")
            lb1.Text = "Lichte sneeuwbuien"
        Case lb1.Text.Contains("Moderate OR heavy showers of ice pellets")
            lb1.Text = "Matige of zware buien ijs pellets"
        Case lb1.Text.Contains("Patchy light rain In area with thunder")
            lb1.Text = "Gedeeltelijk lichte regen In gebieden met donder"
        Case lb1.Text.Contains("Moderate OR heavy rain In area with thunder")
            lb1.Text = "Matige of zware regen In gebieden met donder"
        Case lb1.Text.Contains("Patchy light snow In area with thunder")
            lb1.Text = "Gedeeltelijk lichte sneeuw In gebieden met donder"
        Case lb1.Text.Contains("Moderate OR heavy snow In area with thunder")
            lb1.Text = "Matige of zware sneeuw In gebieden met donder"
        Case lb1.Text.Contains("Ice pellets")
            lb1.Text = "Ijs pellets"
        Case lb1.Text.Contains("Heavy snow")
            lb1.Text = "Zware sneeuw"
        Case lb1.Text.Contains("Patchy heavy snow")
            lb1.Text = "Fragmentarisch zware sneeuw"
        Case lb1.Text.Contains("Moderate snow")
            lb1.Text = "Matige sneeuw"
        Case lb1.Text.Contains("Patchy moderate snow")
            lb1.Text = "Fragmentarisch matige sneeuw"
        Case lb1.Text.Contains("Light snow")
            lb1.Text = "Lichte sneeuw"
        Case lb1.Text.Contains("Patchy light snow")
            lb1.Text = "Gedeeltelijk lichte sneeuw"
        Case lb1.Text.Contains("Moderate OR heavy sleet")
            lb1.Text = "Matige of zware natte sneeuw"
        Case lb1.Text.Contains("Light sleet")
            lb1.Text = "Lichte natte sneeuw"
        Case lb1.Text.Contains("Patchy light rain")
            lb1.Text = "Gedeeltelijk lichte regen"
        Case lb1.Text.Contains("Heavy freezing drizzle")
            lb1.Text = "Zware bevriezing motregen"
        Case lb1.Text.Contains("Freezing drizzle")
            lb1.Text = "Invriezen motregen"
        Case lb1.Text.Contains("Patchy light drizzle")
            lb1.Text = "Gedeeltelijk lichte motregen"
        Case lb1.Text.Contains("Freezing fog")
            lb1.Text = "Aanvriezende Nevel"
        Case lb1.Text.Contains("Blizzard")
            lb1.Text = "Sneeuwstorm"
        Case lb1.Text.Contains("Blowing snow")
            lb1.Text = "Sneeuwbuien"
        Case lb1.Text.Contains("Thundery outbreaks In nearby")
            lb1.Text = "Donder uitbraken In het nabijgelegen"
        Case lb1.Text.Contains("Patchy freezing drizzle nearby")
            lb1.Text = "Fragmentarisch bevriezing motregen buurt"
        Case lb1.Text.Contains("Patchy sleet nearby")
            lb1.Text = "Fragmentarisch ijzel buurt"
        Case lb1.Text.Contains("Patchy snow nearby")
            lb1.Text = "Fragmentarisch sneeuw buurt"
        Case lb1.Text.Contains("Patchy rain nearby")
            lb1.Text = "Fragmentarisch regen buurt"
    End Select
    End If
End Sub

2. w języku polskim (the polish language has very funny (and ugly characters (in writing ;-) )
B4X:
Sub WeatherTrans
'    Translator CCWEATHERDISCRIPTION > PL by GMAN
    If lb1.Text <> "" Then
    Select True
        Case lb1.Text.Contains("Sunny")
            lb1.Text = "Słoneczny"
        Case lb1.Text.Contains("Clear")
            lb1.Text = "Jasne"
        Case lb1.Text.Contains("Clear/Sunny")
            lb1.Text = "Jasne i słoneczne"   
        Case lb1.Text.Contains("Cloudy")
            lb1.Text = "Mętny"
        Case lb1.Text.Contains("Partly Cloudy")
            lb1.Text = "Częściowe zachmurzenie"
        Case lb1.Text.Contains("Snowy")
            lb1.Text = "Snieżny"
        Case lb1.Text.Contains("Stormy")
            lb1.Text = "Burzliwy"
        Case lb1.Text.Contains("Mist")
            lb1.Text = "Mgła"
        Case lb1.Text.Contains("Moderate rain")
            lb1.Text = "Umiarkowany deszcz"   
        Case lb1.Text.Contains("Light rain")
            lb1.Text = "Lekki deszcz"
        Case lb1.Text.Contains("Moderate rain at times")
            lb1.Text = "Umiarkowany deszcz czasami"
        Case lb1.Text.Contains("Heavy rain at times")
            lb1.Text = "Ulewny deszcz w czasie"
        Case lb1.Text.Contains("Heavy rain")
            lb1.Text = "Ulewa"
        Case lb1.Text.Contains("Light freezing rain")
            lb1.Text = "Światło marznący deszcz"
        Case lb1.Text.Contains("Moderate OR Heavy freezing rain")
            lb1.Text = "Umiarkowany lub ciężki zamrożenie deszcz"
        Case lb1.Text.Contains("Light drizzle")
            lb1.Text = "Lekka mżawka"
        Case lb1.Text.Contains("Fog")
            lb1.Text = "Potraw"
        Case lb1.Text.Contains("Overcast")
            lb1.Text = "Pochmurny"
        Case lb1.Text.Contains("Light rain shower")
            lb1.Text = "Bezchmurnie"
        Case lb1.Text.Contains("Moderate OR heavy rain shower")
            lb1.Text = "Umiarkowane lub intensywne opady deszczu prysznic"
        Case lb1.Text.Contains("Torrential rain shower")
            lb1.Text = "Ulewny deszcz prysznic !"
        Case lb1.Text.Contains("Light sleet showers")
            lb1.Text = "Opady śniegu z deszczem"
        Case lb1.Text.Contains("Moderate OR heavy sleet showers")
            lb1.Text = "Umiarkowane lub intensywne opady przelotne śniegu z deszczem"
        Case lb1.Text.Contains("Moderate OR heavy snow showers")
            lb1.Text = "miarkowane lub ciężkie opady śniegu"
        Case lb1.Text.Contains("Opady grudek lodu")
            lb1.Text = "Opady grudek lodu"
        Case lb1.Text.Contains("Light snow showers")
            lb1.Text = "Lekkie opady śniegu"
        Case lb1.Text.Contains("Moderate OR heavy showers of ice pellets")
            lb1.Text = "Umiarkowane lub intensywne opady przelotne grudek lodu"
        Case lb1.Text.Contains("Patchy light rain In area with thunder")
            lb1.Text = "Przelotne opady deszczu w okolicy z gromu"
        Case lb1.Text.Contains("Moderate OR heavy rain In area with thunder")
            lb1.Text = "Umiarkowane lub intensywne opady deszczu w okolicy z gromu"
        Case lb1.Text.Contains("Patchy light snow In area with thunder")
            lb1.Text = "Przelotne opady śniegu W obszarze z gromu"
        Case lb1.Text.Contains("Moderate OR heavy snow In area with thunder")
            lb1.Text = "Umiarkowany lub ciężki śnieg obszarze grzmot"
        Case lb1.Text.Contains("Ice pellets")
            lb1.Text = "Granulki lodu"
        Case lb1.Text.Contains("Heavy snow")
            lb1.Text = "Ciężki śnieg"
        Case lb1.Text.Contains("Patchy heavy snow")
            lb1.Text = "Przelotne ciężki śnieg"
        Case lb1.Text.Contains("Moderate snow")
            lb1.Text = "Umiarkowany śnieg"
        Case lb1.Text.Contains("Patchy moderate snow")
            lb1.Text = "Przelotne Umiarkowany śnieg"
        Case lb1.Text.Contains("Light snow")
            lb1.Text = "lekki śnieg"
        Case lb1.Text.Contains("Patchy light snow")
            lb1.Text = "Przelotne opady śniegu"
        Case lb1.Text.Contains("Moderate OR heavy sleet")
            lb1.Text = "Umiarkowany lub ciężki śnieg z deszczem"
        Case lb1.Text.Contains("Light sleet")
            lb1.Text = "Lekki deszcz ze śniegiem"
        Case lb1.Text.Contains("Patchy light rain")
            lb1.Text = "Przelotne opady deszczu"
        Case lb1.Text.Contains("Heavy freezing drizzle")
            lb1.Text = "Ciężki zamrożenie mżawka"
        Case lb1.Text.Contains("Freezing drizzle")
            lb1.Text = "Zamrożenie mżawka"
        Case lb1.Text.Contains("Patchy light drizzle")
            lb1.Text = "Przelotne bezchmurnie"
        Case lb1.Text.Contains("Freezing fog")
            lb1.Text = "Zamrożenie mgła"
        Case lb1.Text.Contains("Blizzard")
            lb1.Text = "Zamieć"
        Case lb1.Text.Contains("Blowing snow")
            lb1.Text = "Snieżek"
        Case lb1.Text.Contains("Thundery outbreaks In nearby")
            lb1.Text = "W pobliżu ogniska burzowe"
        Case lb1.Text.Contains("Patchy freezing drizzle nearby")
            lb1.Text = "Przelotne mżawka zamrożenie pobliżu"
        Case lb1.Text.Contains("Patchy sleet nearby")
            lb1.Text = "Przelotne opady deszczu ze śniegiem w pobliżu"
        Case lb1.Text.Contains("Patchy snow nearby")
            lb1.Text = "Przelotne śniegu w pobliżu"
        Case lb1.Text.Contains("Patchy rain nearby")
            lb1.Text = "Przelotne opady w pobliżu"
    End Select
    End If
End Sub

Hier ga je & Proszę bardzo :eek:
 
Top