README.md

# BackblazeRegions

A simple Elixir library providing a list of all Backblaze B2 regions with their names, geography, and continent data.

## Installation

Add `backblaze_regions` to your list of dependencies in `mix.exs`:

```elixir
def deps do
  [
    {:backblaze_regions, "~> 0.1.0"}
  ]
end
```

## Functions

| Function | Description | Return Type |
|---|---|---|
| `BackblazeRegions.list(opts)` | Returns all 2 Backblaze B2 regions | `[%{code, name, geography, continent}]` |
| `BackblazeRegions.codes()` | Returns all region codes | `["us-west-002", "eu-central-003"]` |
| `BackblazeRegions.names()` | Returns all region names (English) | `["US West (Sacramento)", ...]` |
| `BackblazeRegions.get(code, opts)` | Looks up a region by code | `{:ok, region}` or `:error` |
| `BackblazeRegions.count()` | Returns the total number of regions | `2` |
| `BackblazeRegions.continents()` | Returns all continent groupings | `["Europe", "North America"]` |
| `BackblazeRegions.by_continent(name, opts)` | Returns all regions in a continent | `[%{code, name, geography, continent}]` |
| `BackblazeRegions.group_by_continent(opts)` | Returns all regions grouped by continent | `[{"Europe", [regions]}, ...]` |
| `BackblazeRegions.supported_languages()` | Returns all supported language codes | `["ar", "de", "en", ...]` |

Functions that accept `opts` support `lang: "xx"` for translated output. Unsupported languages return `{:error, :unsupported_language}`.

## Region Data Structure

Each region is a map with the following keys:

```elixir
%{
  code: "us-west-002",
  name: "US West (Sacramento)",
  geography: "United States of America",
  continent: "North America"
}
```

## Usage Examples

```elixir
# List all regions
BackblazeRegions.list()
# => [%{code: "us-west-002", name: "US West (Sacramento)", geography: "United States of America", continent: "North America"}, ...]

# Get all region codes
BackblazeRegions.codes()
# => ["us-west-002", "eu-central-003"]

# Get all region names
BackblazeRegions.names()
# => ["US West (Sacramento)", "EU Central (Amsterdam)"]

# Look up a specific region
BackblazeRegions.get("eu-central-003")
# => {:ok, %{code: "eu-central-003", name: "EU Central (Amsterdam)", geography: "Netherlands", continent: "Europe"}}

BackblazeRegions.get("invalid")
# => :error

# Filter by continent
BackblazeRegions.by_continent("Europe")
# => [%{code: "eu-central-003", name: "EU Central (Amsterdam)", geography: "Netherlands", continent: "Europe"}]

# List all continents
BackblazeRegions.continents()
# => ["Europe", "North America"]

# Group all regions by continent
BackblazeRegions.group_by_continent()
# => [
#   {"Europe", [%{code: "eu-central-003", ...}]},
#   {"North America", [%{code: "us-west-002", ...}]}
# ]

# Get region count
BackblazeRegions.count()
# => 2
```

## Translation Support

By default all functions return English data. Pass `lang: "xx"` to get translated region names and geography. Region codes and continent keys always stay in English.

| Code | Language   |
|------|------------|
| `en` | English (default) |
| `ar` | Arabic     |
| `de` | German     |
| `es` | Spanish    |
| `et` | Estonian   |
| `fr` | French     |
| `hi` | Hindi      |
| `ja` | Japanese   |
| `pt` | Portuguese |
| `ru` | Russian    |
| `zh` | Chinese    |

```elixir
# Check supported languages
BackblazeRegions.supported_languages()
# => ["ar", "de", "en", "es", "et", "fr", "hi", "ja", "pt", "ru", "zh"]

# List regions in Japanese
BackblazeRegions.list(lang: "ja")
# => [%{code: "us-west-002", name: "米国西部(サクラメント)", geography: "アメリカ合衆国", continent: "North America"}, ...]

# Look up a region in French
BackblazeRegions.get("eu-central-003", lang: "fr")
# => {:ok, %{code: "eu-central-003", name: "UE Central (Amsterdam)", geography: "Pays-Bas", continent: "Europe"}}

# Filter by continent in Spanish
BackblazeRegions.by_continent("Europe", lang: "es")
# => [%{code: "eu-central-003", name: "UE Central (Ámsterdam)", geography: "Países Bajos", continent: "Europe"}]

# Group by continent in German
BackblazeRegions.group_by_continent(lang: "de")
# => [{"Europe", [%{code: "eu-central-003", name: "EU Zentral (Amsterdam)", ...}]}, ...]

# Unsupported language
BackblazeRegions.list(lang: "xx")
# => {:error, :unsupported_language}
```

## Documentation

Full docs are available at [HexDocs](https://hexdocs.pm/backblaze_regions).