Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ NORBIX_API_KEY=sk_live_...
NORBIX_PROJECT_ID=proj_123
NORBIX_ACCOUNT_ID=acc_456 # optional
NORBIX_REGION=nb-eu-germany # optional — no default region (see "Regions")
NORBIX_LANGUAGE=lt # optional — sent as Accept-Language (see "Language")
NORBIX_API_URL=https://api.norbix.ai
NORBIX_HUB_URL=https://hub.norbix.ai
NORBIX_API_VERSION=v3
Expand Down Expand Up @@ -235,6 +236,31 @@ await client.Account.UpdateProjectRegionsAsync(new UpdateProjectRegions

Every other project setting (name, CORS, languages, admin URL, legal, Admin Portal, AI) is on [docs/hub/project.md](./docs/hub/project.md).

## Language

The gateway reads exactly one language input: the standard `Accept-Language` header (q-values are honoured; the project's default language is used when nothing matches). The response says which language it picked in `Content-Language`. The old `cultureCode` request field and the `CultureCode` / `norbix-language` headers are gone — the SDK never sends them.

The SDK resolves the language like the region — there is **no default language**:

1. Per-call override — `client.WithLanguage("...")`
2. `Language` on `NorbixClientOptions` (explicit values win over env vars)
3. `NORBIX_LANGUAGE` environment variable
4. Unset — no `Accept-Language` header is sent and the gateway uses the project default

The value is sent as-is, so a single tag or a full header value both work:

```csharp
var client = new NorbixApiClient(new NorbixClientOptions
{
ProjectId = "proj_123",
ApiKey = "<api_key>",
Language = "lt-LT, en;q=0.8",
});

var lt = client.WithLanguage("lt"); // shares the HttpClient, like WithRegion
var dflt = client.WithLanguage(null); // clears it — header omitted, project default
```

## Project vs Account Scope

- `ProjectId` is required. The SDK works at project scope by default.
Expand Down
15 changes: 15 additions & 0 deletions src/Norbix.Contracts/NorbixClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ public sealed class NorbixClientOptions
/// </summary>
public string? Region { get; set; }

/// <summary>
/// Preferred response language, sent as the standard <c>Accept-Language</c>
/// header — a single tag (e.g. <c>lt</c>, <c>lt-LT</c>) or a full header
/// value with q-values (e.g. <c>lt-LT, en;q=0.8</c>). The gateway honours
/// the q-values and falls back to the project's default language when
/// nothing matches; the chosen language comes back as
/// <c>Content-Language</c>. Like <see cref="Region"/> there is NO default —
/// when unset, no header is sent. Resolution order: per-call
/// <c>WithLanguage</c> override on the client → this option →
/// <c>NORBIX_LANGUAGE</c> environment variable → unset.
/// </summary>
public string? Language { get; set; }

/// <summary>API gateway base URL. Default <c>https://api.norbix.ai</c> (or <c>NORBIX_API_URL</c>).</summary>
public string ApiBaseUrl { get; set; } = DefaultApiBaseUrl;

Expand Down Expand Up @@ -102,6 +115,7 @@ public NorbixClientOptions Clone()
AccountId = AccountId,
Env = Env,
Region = Region,
Language = Language,
ApiBaseUrl = ApiBaseUrl,
HubBaseUrl = HubBaseUrl,
ApiVersion = ApiVersion,
Expand Down Expand Up @@ -142,6 +156,7 @@ source is null
if (env is not null) Env = env;

Region ??= NullIfEmpty(Read("NORBIX_REGION"));
Language ??= NullIfEmpty(Read("NORBIX_LANGUAGE"));

var apiUrl = NullIfEmpty(Read("NORBIX_API_URL"));
if (apiUrl is not null) ApiBaseUrl = apiUrl;
Expand Down
Loading
Loading