Tweaks and fixes throughout the project (#27)
This PR contains the work done to do a little bit of housekeeping pass across all packages and the Website service. To provide further details about the work: * Refreshed the READMEs and source documentation to match the current code; * Tagged every test case consistently across the Infrastructure, Localization, Persistence, and Website test targets; * Removed Website middleware tests now covered by Infrastructure's own suite; * Conformed the `PrepareDB` method to Sendable; * Relaxes the production Compose DATABASE_TLS default from require to prefer; * Added Persistence test verifying the prefer posture falls back to plaintext connections. Reviewed-on: rock-n-code/loud-amsterdam#27 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit is contained in:
@@ -2,22 +2,19 @@ import Foundation
|
||||
|
||||
/// A backend that resolves localized strings for an explicit locale and reports the languages it serves.
|
||||
///
|
||||
/// This is the seam that decouples ``Localize`` and ``LanguageList`` from *how* localizations are stored
|
||||
/// and resolved. The shipping implementation, ``StringCatalog``, reads a raw `.xcstrings` catalog so it
|
||||
/// behaves identically on Darwin and Linux. A future backend — for example one built on
|
||||
/// `String(localized:)` for a native Apple app that needs plural and device variations — can conform
|
||||
/// without changing any caller.
|
||||
/// This is the seam that decouples ``Localize`` and ``LanguageList`` from *how* localizations are stored and resolved. The shipping implementation,
|
||||
/// ``StringCatalog``, reads a raw `.xcstrings` catalog so it behaves identically on Darwin and Linux. A future backend — for example one built on
|
||||
/// `String(localized:)` for a native Apple app that needs plural and device variations — can conform without changing any caller.
|
||||
///
|
||||
/// Resolution never fails: an implementation returns the key itself when it has no localization for it,
|
||||
/// mirroring Foundation's `String(localized:)`. This is the contract both a dictionary lookup and the
|
||||
/// native API can honour, since the native API cannot distinguish a missing key from a translation that
|
||||
/// Resolution never fails: an implementation returns the key itself when it has no localization for it, mirroring Foundation's `String(localized:)`.
|
||||
/// This is the contract both a dictionary lookup and the native API can honour, since the native API cannot distinguish a missing key from a translation that
|
||||
/// happens to equal the key.
|
||||
protocol CatalogResolving: Sendable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The source (development) language, used as the final fallback when a locale has no localization
|
||||
/// and as the default language a ``LanguageList`` serves.
|
||||
/// The source (development) language, used as the final fallback when a locale has no localization and as the default language a ``LanguageList``
|
||||
/// serves.
|
||||
var sourceLanguage: String { get }
|
||||
|
||||
/// The outcome of reading the backing catalog, for consumers to surface at startup.
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/// A single language range parsed from an `Accept-Language` header entry.
|
||||
///
|
||||
/// A range pairs the language tag a client asked for with the `q` weight expressing how much the
|
||||
/// client prefers it, as RFC 9110 defines them. ``Negotiate`` parses each comma-separated header
|
||||
/// entry into one of these, then orders the ranges by descending weight so the most preferred tag
|
||||
/// A range pairs the language tag a client asked for with the `q` weight expressing how much the client prefers it, as RFC 9110 defines them.
|
||||
/// ``Negotiate`` parses each comma-separated header entry into one of these, then orders the ranges by descending weight so the most preferred tag
|
||||
/// is matched first.
|
||||
struct LanguageRange {
|
||||
|
||||
@@ -11,8 +10,7 @@ struct LanguageRange {
|
||||
/// The language tag the client asked for, such as `de` or `de-AT`, or the `*` wildcard.
|
||||
let tag: String
|
||||
|
||||
/// The tag's `q` weight, from 0 ("not acceptable") to 1 (most preferred, the default when
|
||||
/// an entry names no weight).
|
||||
/// The tag's `q` weight, from 0 ("not acceptable") to 1 (most preferred, the default when an entry names no weight).
|
||||
let quality: Double
|
||||
|
||||
}
|
||||
|
||||
@@ -95,8 +95,8 @@ extension StringCatalog {
|
||||
|
||||
/// Returns the catalog for the given bundle and table, decoding it on first access.
|
||||
///
|
||||
/// Catalogs are immutable at runtime, so every ``Localize``, ``Negotiate``, and ``LanguageList``
|
||||
/// bound to the same bundle shares one decoded catalog instead of re-reading its JSON.
|
||||
/// Catalogs are immutable at runtime, so every ``Localize``, ``Negotiate``, and ``LanguageList`` bound to the same bundle shares one
|
||||
/// decoded catalog instead of re-reading its JSON.
|
||||
/// - Parameters:
|
||||
/// - bundle: the bundle whose resources contain the String Catalog.
|
||||
/// - table: the name of the String Catalog resource, without the `.xcstrings` extension.
|
||||
@@ -132,9 +132,8 @@ extension StringCatalog {
|
||||
|
||||
extension StringCatalog: CatalogResolving {
|
||||
|
||||
/// Resolves a key by the most specific language tag first: the locale's full tag (`pt-BR`), then its
|
||||
/// primary language code (`pt`), then the source language, then the key itself. Tags are matched
|
||||
/// case-insensitively, so a regional catalog entry resolves for the locale ``Negotiate`` picked it for.
|
||||
/// Resolves a key by the most specific language tag first: the locale's full tag (`pt-BR`), then its primary language code (`pt`), then the source
|
||||
/// language, then the key itself. Tags are matched case-insensitively, so a regional catalog entry resolves for the locale ``Negotiate`` picked it for.
|
||||
func string(
|
||||
for key: String,
|
||||
in locale: Locale
|
||||
@@ -162,8 +161,8 @@ private extension Locale {
|
||||
|
||||
/// The language tags to resolve a catalog entry against, most specific first.
|
||||
///
|
||||
/// The locale's full identifier comes first, as a hyphenated, lowercased tag (`pt_BR` becomes
|
||||
/// `pt-br`), followed by its primary language code when the two differ.
|
||||
/// The locale's full identifier comes first, as a hyphenated, lowercased tag (`pt_BR` becomes `pt-br`), followed by its primary language code when
|
||||
/// the two differ.
|
||||
var catalogTags: [String] {
|
||||
var tags: [String] = []
|
||||
let identifier = identifier
|
||||
|
||||
Reference in New Issue
Block a user