Localisation and URLs
The five endpoints behind the installation's language, currency, time zone and address structure.
Overview
These five endpoints decide which language, which currency and which addresses the installation runs on. They look like small settings, but three of them reach across the whole installation, and this article is largely about those.
The time zone and the date format change safely. The locale, the currency, the country and the address mode write files, flip tables or create folders; change those on a live installation with care.
Reference
Reading the Localisation
Returns the installation's language, currency, country and time zone.
curl 'https://panel.example.com/api/v1/admin/settings/localisation' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/settings/localisation', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/localisation');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The values you can pick come back in the SAME response; no separate reference call is needed.
$loc = Api::Settings()->GetLocalisationSettings()['data'];
$zones = $loc['available']['timezones'];Writing the Localisation
Applies the settings you send. Three of the fields have side effects across the installation.
curl -X PUT 'https://panel.example.com/api/v1/admin/settings/localisation' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"timezone":"America/New_York","date_format":"Y-m-d"}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/localisation', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
timezone: 'America/New_York',
date_format: 'Y-m-d',
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/localisation');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'timezone' => 'America/New_York',
'date_format' => 'Y-m-d',
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The time zone and the date format are the SAFE fields; the locale, currency and country are not.
Api::Settings()->UpdateLocalisationSettings([
'timezone' => 'America/New_York',
'date_format' => 'Y-m-d',
]);Reading the Address Settings
Returns how addresses are formed and the path names in each language.
curl 'https://panel.example.com/api/v1/admin/settings/url' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/settings/url', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/url');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The path names are per language: the same page opens on a different address in each.
$url = Api::Settings()->GetUrlSettings()['data'];
$en = $url['routes']['en']['products'];Changing the Address Mode
Switches addresses between clean and plain, testing the server's support live.
curl -X PUT 'https://panel.example.com/api/v1/admin/settings/url' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"rich_url":"on"}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/url', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ rich_url: 'on' }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/url');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['rich_url' => 'on']),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// This endpoint creates or removes the ADMIN FOLDER: a wrong mode can break the panel address.
// Read the current mode first; sending the same value is harmless.
$current = Api::Settings()->GetUrlSettings()['data']['rich_url'];
if ($current !== 'on') {
Api::Settings()->UpdateUrlSettings(['rich_url' => 'on']);
}Writing the Path Names
Writes the path names that appear in page addresses, per language.
curl -X PUT 'https://panel.example.com/api/v1/admin/settings/url/views' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"routes":{"en":{"products":"products","cart":"cart"}}}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/url/views', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
routes: { en: { products: 'products', cart: 'cart' } },
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/url/views');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'routes' => ['en' => ['products' => 'products']],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Changing a path name breaks the OLD address, the one in search engines and in links people saved.
// Read the keys from the current structure; an invented key is skipped without a word.
$routes = Api::Settings()->GetUrlSettings()['data']['routes'];
$routes['en']['products'] = 'shop';
Api::Settings()->UpdateUrlViews(['routes' => $routes]);Pitfalls
Changing the mode tests live whether the server supports clean addresses, and creates or removes the admin folder. A wrong mode can leave the panel unreachable. Sending the value it already has does nothing, so reading the current mode first is the safest route.
Changing the default currency does not merely update a preference: the local flag moves in the currency table and an exchange rate sync starts. How prices look changes across the installation. Do not do it during trading hours.
Changing the default locale causes the language package file to be rewritten. That is a different kind of act from saving a setting: a file on disk changes. The locale is best set once at installation and left alone.
Moving the default country away from one particular country switches off the identity number fields on the registration form. It is a silent side effect: the form changes though you touched nothing in the client registration settings.
Change a page's path name and the old address stops working: search engine entries and links clients saved go nowhere, and no redirect is set up. An unrecognised route key is also ignored without a word, so a path you thought you wrote may never have been written. Confirm the result through the read endpoint.
Related Articles
Thanks for your feedback!
Our support team is here around the clock for anything you can't find above.