Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmi-aw authored Aug 5, 2022
1 parent 5a48cb9 commit 0a294ce
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Localisation-lib
A java application to add localisation to your apps

Localisation is an open sour java Library, it's used to add localisation layer to your java apps, till now it contains, Countries,States and cities, later we will add languages separately.
Localisation is an open source java Library, it's used to add localisation layer to your java apps, till now it contains, Countries,States and cities, later we will add languages separately.

**Note**: This library executes an **http request** to fetch the needed data.

Expand All @@ -14,28 +12,31 @@ This library can be used in many different ways, all versions are published on M
<dependency>
<groupId>com.beastwall</groupId>
<artifactId>localisation</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
```

## 1.2 Gradle
```gradle
implementation 'com.beastwall:localisation:1.0.1'
implementation 'com.beastwall:localisation:1.0.2'
```

## 1.3 Other methods
For other usages (gradle kotlin, scala etc...), see the link below
https://search.maven.org/artifact/com.beastwall/localisation/1.0.1/jar
https://search.maven.org/artifact/com.beastwall/localisation/1.0.2/jar

# 2- How to use it ?
Till now, the only way to use this library is as follows:


## Getting all countries
```java

// Fetch all countries with their cities and states
List<Country> countries = Localisation.getAllCountriesStatesAndCities();

```
## Getting states

You might want to get states for a specific Country:
```java
Expand All @@ -46,7 +47,7 @@ You might want to get states for a specific Country:
}

```

## Getting cities
You might want to get cities for a specific state:
```java
//Get cities for a state
Expand All @@ -56,6 +57,22 @@ You might want to get cities for a specific state:

```

## Getting country flag
In some cases you might want to display a specific country flag, and **getCountryFlagSVG(...)** method returns a byte array of a flag than can be saved as an SVG file, since it was an svg file before fetching it.

To get a country flag, all you need to do is to specify it's code for examle **Algeria** => **dz**, and the format of the flag, whether it's a **RECTANGLE**, or a **SQUARE**.

```java
//Get countries Svg square flags
for (Country c : countries) {
byte[] countryFlag = Localisation.getCountryFlagSVG(c.getIso2(), Form.SQUARE);
//Do something like saving the file
}

//Get Algeria's square flag with code "dz"
byte[] dz = Localisation.getCountryFlagSVG("dz", Form.RECTANGLE);
```

# Android
As you all know, Google has removed HttpClient java class from Android Sdk, and since this library uses **HttpClient**, there's a solution which is telling the system that we still want to use HttpClient, by adding the next line in your gradle file.

Expand All @@ -67,3 +84,7 @@ useLibrary 'org.apache.http.legacy'
}
```

for more information check this response:
https://stackoverflow.com/questions/49644066/what-are-the-implications-of-the-removal-of-httpclient-in-android-m


0 comments on commit 0a294ce

Please sign in to comment.