@autobusal/providers 1.29.1 → 1.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,50 +1,18 @@
1
1
  # Changelog
2
2
 
3
- ## 1.29.1
4
3
 
5
- ### Fixed
6
-
7
- - **The domain's language outranks the stored preference only on a ccTLD**,
8
- not on the brand's primary. Every primary declares a locale (the backfill
9
- gave it one), so 1.29.0 applied the override everywhere — quietly ending
10
- the deliberate, already-shipped behaviour where a returning visitor who
11
- last read the site in Albanian types `busmagus.com` and gets Albanian. That
12
- would have changed every brand on the platform, none of which has a second
13
- domain yet: a change nobody asked for, arriving with a feature nobody has
14
- switched on. Caught by testing a returning visitor rather than a clean
15
- browser.
16
-
17
-
18
- ## 1.29.0
19
-
20
- ### Changed
21
-
22
- - **`getLanguage` takes the language the ORIGIN is about, and it outranks the
23
- stored preference** — the only thing that does. The stored preference
24
- exists so a returning visitor who last read the site in Albanian gets
25
- Albanian at `busmagus.com/`, where the URL expresses no preference of its
26
- own. On `busmagus.ro` the URL expresses nothing *but* a preference: the
27
- domain is the request, and honouring a two-month-old `localStorage` entry
28
- over it would render Albanian at a Romanian URL whose own canonical says it
29
- is Romanian — reintroduced one returning visitor at a time, and invisible
30
- to anybody testing in a clean browser.
31
-
32
- It defaults to whatever `languages()` was told, so the two call sites that
33
- ask outside of setup (the 500-error text in `apiClient`, the error page in
34
- `Errors/Message`) answer in the language actually being read rather than
35
- showing English error copy on a Romanian page.
4
+ ## 1.29.2
36
5
 
37
- Undefined — a single-domain brand, or an alias claiming no language —
38
- leaves the ordering exactly as it was.
6
+ ### Removed
39
7
 
40
- ### Added
8
+ - **Everything 1.29.0/1.29.1 added for multi-TLD** — `getLanguage`'s
9
+ `domainLocale` argument and the module-level origin it defaulted to, the
10
+ argument `Setup` passed it, and `SettingsData.domain` / `.domains` /
11
+ `.locale`. The stored language preference is once again the only thing that
12
+ outranks the brand default on an unprefixed URL.
41
13
 
42
- - **`SettingsData.domain` / `.domains` / `.locale`** which origin answered,
43
- every origin the brand answers on, and the language this one is about.
44
- `domains` is what turns hreflang from locale-to-path-prefix into
45
- locale-to-**domain** (see `@autobusal/common`'s `localeHref`); its first
46
- entry is the primary. All three optional, so an older API cannot break a
47
- newer build.
14
+ See `@autobusal/common@1.27.1` for why. Published forward rather than
15
+ downgraded, for the same reason.
48
16
 
49
17
  ## 1.28.1
50
18
 
package/Setup/Setup.tsx CHANGED
@@ -15,28 +15,7 @@ const Setup = ({ type, children }: Props): JSX.Element => {
15
15
  useGetMenu();
16
16
  useUserBootstrap();
17
17
 
18
- // Edited: Ferjolt Ozuni - Date: 2026-08-06
19
- // The language this origin is about, but ONLY when it is a ccTLD - a
20
- // domain that exists in order to be that language. It outranks the stored
21
- // preference there; see getLanguage.
22
- //
23
- // Not on the PRIMARY, even though it declares a locale too (every brand's
24
- // primary does - the backfill gave it one). The primary is the brand's
25
- // address before it is a language, and the stored preference winning at
26
- // its unprefixed URLs is deliberate and already shipped: a returning
27
- // visitor who last read the site in Albanian types busmagus.com and gets
28
- // Albanian. Passing the primary's locale here would have quietly ended
29
- // that for every brand on the platform, none of which has a second domain
30
- // yet - a change nobody asked for, arriving with a feature nobody has
31
- // switched on.
32
- const origin = data.domains?.find(item => item.domain === data.domain);
33
-
34
- languages(
35
- type,
36
- data.preferences.languages.default,
37
- data.preferences.languages.available,
38
- origin && !origin.primary ? origin.locale : null
39
- );
18
+ languages(type, data.preferences.languages.default, data.preferences.languages.available);
40
19
 
41
20
  // Edited: Ferjolt Ozuni - Date: 2026-08-01
42
21
  // The brand's GTM container, from labels_settings via the admin GUI.
@@ -2,13 +2,6 @@ import i18next from 'i18next';
2
2
  import Backend from 'i18next-http-backend';
3
3
  import { initReactI18next } from 'react-i18next';
4
4
 
5
- /**
6
- * The language this ORIGIN is about, remembered from the one place that is
7
- * told it (`languages()`, from the settings payload) so the call sites that
8
- * ask outside of setup do not each have to be handed it. See getLanguage.
9
- */
10
- let originLocale: string | null | undefined;
11
-
12
5
  /**
13
6
  * The language to start in.
14
7
  *
@@ -23,42 +16,14 @@ let originLocale: string | null | undefined;
23
16
  * `available` is passed in rather than read from anywhere global so this
24
17
  * stays a pure function of its inputs, and so an unrecognised first segment
25
18
  * (/city/tirana) is never mistaken for a language.
26
- *
27
- * Edited: Ferjolt Ozuni - Date: 2026-08-06
28
- * `domainLocale` - the language THIS origin is about, when it is about one
29
- * (obtapi's settings payload, `locale`). It outranks the stored preference,
30
- * which nothing else does.
31
- *
32
- * The stored preference exists so a returning visitor who last read the site
33
- * in Albanian gets Albanian at busmagus.com/, where the URL expresses no
34
- * preference of its own. On busmagus.ro the URL expresses nothing BUT a
35
- * preference: the domain is the request, and honouring a two-month-old
36
- * localStorage entry over it would render Albanian at a Romanian URL whose
37
- * own canonical says it is Romanian - the mismatch localised URLs exist to
38
- * remove, reintroduced one returning visitor at a time and invisible to
39
- * anybody testing in a clean browser.
40
- *
41
- * Undefined (a single-domain brand, or an alias claiming no language) leaves
42
- * the ordering exactly as it was.
43
- *
44
- * It DEFAULTS to whatever `languages()` was told, so the two call sites that
45
- * ask this question outside of setup - the 500-error text in apiClient and
46
- * the error page in Errors/Message, both of which pass only 'en' - answer in
47
- * the language the visitor is actually reading rather than dropping back to
48
- * a stale localStorage entry and showing English error copy on a Romanian
49
- * page.
50
19
  */
51
- export const getLanguage = (defaultLanguage: string, available: string[] = [], domainLocale: string | null | undefined = originLocale): string => {
20
+ export const getLanguage = (defaultLanguage: string, available: string[] = []): string => {
52
21
  const [ , first ] = window.location.pathname.split('/');
53
22
 
54
23
  if (first && available.includes(first)) {
55
24
  return first;
56
25
  }
57
26
 
58
- if (domainLocale && (available.length === 0 || available.includes(domainLocale))) {
59
- return domainLocale;
60
- }
61
-
62
27
  const stored = localStorage.getItem('language');
63
28
 
64
29
  return (stored && (available.length === 0 || available.includes(stored)))
@@ -78,12 +43,7 @@ export const getLanguage = (defaultLanguage: string, available: string[] = [], d
78
43
  // consumer that hasn't set VITE_BUILD_ID yet (no worse than before).
79
44
  const buildId = import.meta.env.VITE_BUILD_ID ?? 'dev';
80
45
 
81
- const languages = (type: string, defaultLanguage: string, available: string[] = [], domainLocale?: string | null): void => {
82
- // Before the early return, not after: the guard is about not initialising
83
- // i18next twice, and getLanguage's callers need this on every render of
84
- // the app's life, not only the first one.
85
- originLocale = domainLocale;
86
-
46
+ const languages = (type: string, defaultLanguage: string, available: string[] = []): void => {
87
47
  if (i18next.isInitialized) {
88
48
  return;
89
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/providers",
3
- "version": "1.29.1",
3
+ "version": "1.29.2",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"
package/types/settings.ts CHANGED
@@ -7,26 +7,6 @@ export interface SettingsData {
7
7
 
8
8
  url: string
9
9
 
10
- /**
11
- * Edited: Ferjolt Ozuni - Date: 2026-08-06
12
- * Multi-TLD: which origin answered this request, every origin this brand
13
- * answers on, and the language this one is about.
14
- *
15
- * `domains` is what turns hreflang from locale-to-path-prefix into
16
- * locale-to-DOMAIN (see @autobusal/common's localeHref). Its first entry
17
- * is the primary - the origin registered with the payment gateways, and
18
- * the one that hosts any language without a domain of its own under a
19
- * /{locale}/ prefix.
20
- *
21
- * `locale` is null for a single-domain brand and for an alias that claims
22
- * no language; everything derived from these then resolves to exactly the
23
- * previous single-origin behaviour. All three are optional so an older API
24
- * cannot break a newer build.
25
- */
26
- domain?: string | null
27
- domains?: { domain: string, locale?: string | null, primary?: boolean }[]
28
- locale?: string | null
29
-
30
10
  // Edited: Ferjolt Ozuni - Date: 2026-08-01
31
11
  // Present ONLY while the brand is under construction - obtapi omits it
32
12
  // entirely on a live site, so its presence is the switch itself and there