Skip to content

Commit

Permalink
feat: add lang support
Browse files Browse the repository at this point in the history
  • Loading branch information
Coutable Bastien authored and KwabenBerko committed Jun 26, 2018
1 parent d692879 commit 945b76e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ helper.setUnits(Units.IMPERIAL);

2. ```Units.METRIC (Celsius)```

#### Set language (default : en)

``` java
helper.setLang(Lang.ENGLISH);
```

## Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.kwabenaberko.openweathermaplib.Lang;
import com.kwabenaberko.openweathermaplib.Units;
import com.kwabenaberko.openweathermaplib.implementation.OpenWeatherMapHelper;
import com.kwabenaberko.openweathermaplib.models.currentweather.CurrentWeather;
Expand All @@ -24,6 +25,8 @@ protected void onCreate(Bundle savedInstanceState) {
helper.setApiKey(getString(R.string.OPEN_WEATHER_MAP_API_KEY));
//Set Units
helper.setUnits(Units.METRIC);
//Set lang
helper.setLang(Lang.ENGLISH);

/*
This Example Only Shows how to get current weather by city name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.kwabenaberko.openweathermaplib;

public class Lang {

public static final String ARABIC = "ar";
public static final String BULGARIAN = "bg";
public static final String CATALAN = "ca";
public static final String CZECH = "cz";
public static final String GERMAN = "de";
public static final String GREEK = "el";
public static final String ENGLISH = "en";
public static final String PERSIAN = "fa";
public static final String FINNISH = "fi";
public static final String FRENCH = "fr";
public static final String GALICIAN = "gl";
public static final String CROATIAN = "hr";
public static final String HUNGARIAN = "hu";
public static final String ITALIAN = "it";
public static final String JAPANESE = "ja";
public static final String KOREAN = "kr";
public static final String LATVIAN = "la";
public static final String LITHUANIAN = "lt";
public static final String MACEDONIAN = "mk";
public static final String DUTCH = "nl";
public static final String POLISH = "pl";
public static final String PORTUGUESE = "pt";
public static final String ROMANIAN = "ro";
public static final String RUSSIAN = "ru";
public static final String SWEDISH = "se";
public static final String SLOVAK = "sk";
public static final String SLOVENIAN = "sl";
public static final String SPANISH = "es";
public static final String TURKISH = "tr";
public static final String UKRAINIAN = "ua";
public static final String VIETNAMESE = "vi";
public static final String CHINESE_SIMPLIFIED = "zh_cn";
public static final String CHINESE_TRADITIONAL = "zh_tw";
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public void setUnits(String units){
options.put("units", units);
}

public void setLang(String lang) {
options.put("lang", lang);
}


private Throwable NoAppIdErrMessage() {
return new Throwable("UnAuthorized. Please set a valid OpenWeatherMap API KEY by using the setApiKey method.");
Expand Down

0 comments on commit 945b76e

Please sign in to comment.