@vdaluz/astro-affiliate 1.1.0 → 1.1.1
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/README.md +1 -1
- package/package.json +2 -2
- package/src/lib/i18n.ts +3 -1
package/README.md
CHANGED
|
@@ -225,7 +225,7 @@ programs: {
|
|
|
225
225
|
},
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
Pass `locale` to `<AffiliateDisclosure>` to select the matching entry
|
|
228
|
+
Pass `locale` to `<AffiliateDisclosure>` to select the matching entry - a region-qualified locale like `pt-BR` matches a `pt` entry via its primary subtag if there's no exact `pt-BR` entry. It falls back to `default` when neither the exact locale nor its subtag has an entry, or when `disclosure` is a plain string:
|
|
229
229
|
|
|
230
230
|
```astro
|
|
231
231
|
<AffiliateDisclosure config={affiliate} affiliates={affiliates} locale={locale} />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vdaluz/astro-affiliate",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "FTC-compliant affiliate-link catalog resolver and disclosure components - proven in production on vdaluz.com and imperfectsystems.com.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@astrojs/check": "^0.9.10",
|
|
44
44
|
"@types/node": "^26.1.1",
|
|
45
|
-
"astro": "^7.2
|
|
45
|
+
"astro": "^7.3.2",
|
|
46
46
|
"typescript": "^6.0.3"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/lib/i18n.ts
CHANGED
|
@@ -2,5 +2,7 @@ export type Localized = string | ({ default: string } & Record<string, string>);
|
|
|
2
2
|
|
|
3
3
|
export function resolveLocalized(text: Localized, locale?: string): string {
|
|
4
4
|
if (typeof text === 'string') return text;
|
|
5
|
-
|
|
5
|
+
if (!locale) return text.default;
|
|
6
|
+
const primarySubtag = locale.split('-')[0].toLowerCase();
|
|
7
|
+
return text[locale] || text[primarySubtag] || text.default;
|
|
6
8
|
}
|