halkyon_app: data locations as precise as a country or a state

An operator's DATA_LOCATION and BACKUP_LOCATION may name a subdivision
(ISO 3166-2, US-CA, DE-BY) besides the EU or a country. The app adds
"(EU)" to a member country and the country to a subdivision ("Germany
(EU)", "California, United States", "Bavaria, Germany (EU)"), in
English and German, and shows the most specific flag there is: a
subdivision's own where the flag package has one, else its country's.
Subdivision names come from Unicode CLDR 48.2 (tool/subdivision_names.py),
bundled with their licence, which the app registers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-19 18:47:25 +02:00
commit 96f2d14618
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
3 changed files with 616 additions and 49 deletions

View file

@ -73,9 +73,9 @@ abstract class InstanceBasics
int minimumAppBuild;
/// Where this instance keeps people's data, as its operator says
/// (DATA_LOCATION): a country's code (ISO 3166-1 alpha-2, `CH`) or `EU`;
/// where the disks are, not which law governs. Null where the operator
/// says nothing.
/// (DATA_LOCATION): `EU`, a country's code (ISO 3166-1 alpha-2, `DE`) or a
/// subdivision's (ISO 3166-2, `US-CA`, `DE-BY`), in capitals; where the
/// disks are, not which law governs. Null where the operator says nothing.
String? dataLocation;
/// Where it keeps its backups (BACKUP_LOCATION): as [dataLocation], or

View file

@ -4,9 +4,10 @@ import 'dart:io';
const noBackups = 'none';
/// Where this instance keeps people's data, as its operator says
/// (`DATA_LOCATION`, decided 2026-10-18): a country's code (ISO 3166-1
/// alpha-2, `CH`) or `EU`. Where the disks are, not which law governs: an
/// operator living elsewhere is bound by their own country's courts too.
/// (`DATA_LOCATION`, decided 2026-10-18): `EU`, a country's code (ISO 3166-1
/// alpha-2, `DE`) or, more precisely, a subdivision's (ISO 3166-2, `US-CA`,
/// `DE-BY`; decided 2026-10-19). Where the disks are, not which law governs:
/// an operator living elsewhere is bound by their own country's courts too.
/// Null where the operator says nothing.
String? dataLocation() =>
dataLocationFrom(Platform.environment['DATA_LOCATION']);
@ -16,13 +17,19 @@ String? dataLocation() =>
String? backupLocation() =>
backupLocationFrom(Platform.environment['BACKUP_LOCATION']);
/// [value] as a location: two letters, in capitals; null for anything
/// else.
/// [value] as a location, in capitals: a country's two letters, or a
/// subdivision's code, the country's two letters, a hyphen and one to three
/// letters or digits (`US-CA`, `FR-75`); null for anything else. The
/// European Union has no subdivisions.
String? dataLocationFrom(String? value) {
final code = value?.trim().toUpperCase();
return code != null && RegExp(r'^[A-Z]{2}$').hasMatch(code) ? code : null;
return code != null && _location.hasMatch(code) && !code.startsWith('EU-')
? code
: null;
}
final _location = RegExp(r'^[A-Z]{2}(-[A-Z0-9]{1,3})?$');
/// [value] as the backups' location: as [dataLocationFrom], or [noBackups].
String? backupLocationFrom(String? value) =>
value?.trim().toLowerCase() == noBackups

View file

@ -20,9 +20,9 @@ fields:
### server still works with; older apps ask to be updated.
minimumAppBuild: int
### Where this instance keeps people's data, as its operator says
### (DATA_LOCATION): a country's code (ISO 3166-1 alpha-2, `CH`) or `EU`;
### where the disks are, not which law governs. Null where the operator
### says nothing.
### (DATA_LOCATION): `EU`, a country's code (ISO 3166-1 alpha-2, `DE`) or a
### subdivision's (ISO 3166-2, `US-CA`, `DE-BY`), in capitals; where the
### disks are, not which law governs. Null where the operator says nothing.
dataLocation: String?
### Where it keeps its backups (BACKUP_LOCATION): as [dataLocation], or
### `none` where it keeps none. Null where the operator says nothing.