Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Added locale validation and the LocaleCode type (#14886)
Damian Legawiec6034c11340dd
diff --git a/.changeset/locale-code-type.md b/.changeset/locale-code-type.mdnew file mode 100644index 0000000000..07b92fc4cf--- /dev/null+++ b/.changeset/locale-code-type.md@@ -0,0 +1,9 @@+---+"@spree/sdk": minor+"@spree/admin-sdk": minor+"@spree/dashboard": patch+---++Added the `LocaleCode` type: the locale codes Spree accepts (every ISO 639-1 language plus regional variants such as `en-US` and `pt-BR`). Order, cart and market locales, the store's default, supported and available locales, and the matching request params now use it. The dashboard validates locale fields with the new `localeCodeSchema`.++The Store API's locale `name` is deprecated (name a locale from its `code` with `Intl.DisplayNames`) and the Admin API no longer returns it, so the admin SDK's `Locale` type drops `name` and types `code` as `LocaleCode`; the dashboard names locales in the browser.diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yamlindex 3a7e7b4eb4..7a8bb9ce0c 100644--- a/docs/api-reference/admin.yaml+++ b/docs/api-reference/admin.yaml@@ -859,7 +859,9 @@ paths:name: Afghanistancurrency: AFNlocales:- - en+ - ps+ - uz+ - tk- code: AGname: Antigua and Barbudacurrency: XCD@@ -874,12 +876,12 @@ paths:name: Albaniacurrency: ALLlocales:- - en+ - sq- code: AMname: Armeniacurrency: AMDlocales:- - en+ - hy- code: AOname: Angolacurrency: AOA@@ -890,11 +892,13 @@ paths:currency: ARSlocales:- es+ - gn- code: ASname: American Samoacurrency: USDlocales:- en+ - sm- code: ATname: Austriacurrency: EUR@@ -914,12 +918,15 @@ paths:name: Azerbaijancurrency: AZNlocales:- - en+ - az+ - hy- code: BAname: Bosnia and Herzegovinacurrency: BAMlocales:- - en+ - bs+ - hr+ - sr- code: BBname: Barbadoscurrency: BBD@@ -929,7 +936,7 @@ paths:name: Bangladeshcurrency: BDTlocales:- - en+ - bn- code: BEname: Belgiumcurrency: EUR@@ -942,6 +949,7 @@ paths:currency: XOFlocales:- fr+ - ff- code: BGname: Bulgariacurrency: EUR@@ -957,6 +965,7 @@ paths:currency: BIFlocales:- fr+ - rn- code: BJname: Benincurrency: XOF@@ -976,12 +985,14 @@ paths:name: Brunei Darussalamcurrency: BNDlocales:- - en+ - ms- code: BOname: Boliviacurrency: BOBlocales:- es+ - ay+ - qu- code: BQname: Bonaire, Sint Eustatius and Sabacurrency: USD@@ -1002,12 +1013,13 @@ paths:name: Bhutancurrency: BTNlocales:- - en+ - dz- code: BWname: Botswanacurrency: BWPlocales:- en+ - tn- code: BYname: Belaruscurrency: BYN@@ -1036,16 +1048,22 @@ paths:currency: CDFlocales:- fr+ - ln+ - kg+ - sw+ - lu- code: CFname: Central African Republiccurrency: XAFlocales:- fr+ - sg- code: CGname: Congocurrency: XAFlocales:- fr+ - ln- code: CHname: Switzerlandcurrency: CHF@@ -1053,6 +1071,7 @@ paths:- de- fr- it+ - rm- code: CIname: Côte d'Ivoirecurrency: XOF@@ -1110,12 +1129,14 @@ paths:locales:- en- zh-CN+ - ms- code: CYname: Cypruscurrency: EURlocales:- el- tr+ - hy- code: CZname: Czechiacurrency: CZK@@ -1173,6 +1194,7 @@ paths:locales:- en- ar+ - ti- code: ESname: Spaincurrency: EUR@@ -1182,7 +1204,7 @@ paths:name: Ethiopiacurrency: ETBlocales:- - en+ - am- code: FIname: Finlandcurrency: EUR@@ -1194,6 +1216,8 @@ paths:currency: FJDlocales:- en+ - fj+ - hi- code: FKname: Falkland Islands (Malvinas)currency: FKP@@ -1208,7 +1232,7 @@ paths:name: Faroe Islandscurrency: DKKlocales:- - en+ - fo- code: FRname: Francecurrency: EUR@@ -1233,7 +1257,7 @@ paths:name: Georgiacurrency: GELlocales:- - en+ - ka- code: GFname: French Guianacurrency: EUR@@ -1259,7 +1283,7 @@ paths:name: Greenlandcurrency: DKKlocales:- - en+ - kl- code: GMname: Gambiacurrency: GMD@@ -1270,6 +1294,7 @@ paths:currency: GNFlocales:- fr+ - ff- code: GPname: Guadeloupecurrency: EUR@@ -1296,6 +1321,7 @@ paths:currency: USDlocales:- en+ - ch- es- code: GWname: Guinea-Bissau@@ -1322,12 +1348,13 @@ paths:name: Croatiacurrency: EURlocales:- - en+ - hr- code: HTname: Haiticurrency: HTGlocales:- fr+ - ht- code: HUname: Hungarycurrency: HUF@@ -1343,20 +1370,24 @@ paths:currency: EURlocales:- en+ - ga- code: ILname: Israelcurrency: ILSlocales:+ - he- ar- code: IMname: Isle of Mancurrency: GBPlocales:- en+ - gv- code: INname: Indiacurrency: INRlocales:+ - hi- en- code: IQname: Iraq@@ -1372,7 +1403,7 @@ paths:name: Icelandcurrency: ISKlocales:- - en+ - is- code: ITname: Italycurrency: EUR@@ -1404,10 +1435,12 @@ paths:currency: KESlocales:- en+ - sw- code: KGname: Kyrgyzstancurrency: KGSlocales:+ - ky- ru- code: KHname: Cambodia@@ -1454,12 +1487,13 @@ paths:name: Kazakhstancurrency: KZTlocales:+ - kk- ru- code: LAname: Lao People's Democratic Republiccurrency: LAKlocales:- - en+ - lo- code: LBname: Lebanoncurrency: LBP@@ -1480,7 +1514,8 @@ paths:name: Sri Lankacurrency: LKRlocales:- - en+ - si+ - ta- code: LRname: Liberiacurrency: LRD@@ -1491,6 +1526,7 @@ paths:currency: LSLlocales:- en+ - st- code: LTname: Lithuaniacurrency: EUR@@ -1502,6 +1538,7 @@ paths:locales:- fr- de+ - lb- code: LVname: Latviacurrency: EUR@@ -1531,7 +1568,10 @@ paths:name: Montenegrocurrency: EURlocales:- - en+ - sr+ - bs+ - sq+ - hr- code: MFname: Saint Martin (French part)currency: EUR@@ -1544,16 +1584,18 @@ paths:currency: MGAlocales:- fr+ - mg- code: MHname: Marshall Islandscurrency: USDlocales:- en+ - mh- code: MKname: North Macedoniacurrency: MKDlocales:- - en+ - mk- code: MLname: Malicurrency: XOF@@ -1563,12 +1605,12 @@ paths:name: Myanmarcurrency: MMKlocales:- - en+ - my- code: MNname: Mongoliacurrency: MNTlocales:- - en+ - mn- code: MOname: Macaocurrency: MOP@@ -1580,6 +1622,7 @@ paths:currency: USDlocales:- en+ - ch- code: MQname: Martiniquecurrency: EUR@@ -1600,6 +1643,7 @@ paths:name: Maltacurrency: EURlocales:+ - mt- en- code: MUname: Mauritius@@ -1610,12 +1654,13 @@ paths:name: Maldivescurrency: MVRlocales:- - en+ - dv- code: MWname: Malawicurrency: MWKlocales:- en+ - ny- code: MXname: Mexicocurrency: MXN@@ -1625,6 +1670,7 @@ paths:name: Malaysiacurrency: MYRlocales:+ - ms- en- code: MZname: Mozambique@@ -1636,6 +1682,7 @@ paths:currency: NADlocales:- en+ - af- code: NCname: New Caledoniacurrency: XPF@@ -1671,6 +1718,7 @@ paths:currency: NOKlocales:- nb+ - nn- code: NPname: Nepalcurrency: NPR@@ -1681,6 +1729,7 @@ paths:currency: AUDlocales:- en+ - na- code: NUname: Niuecurrency: NZD@@ -1720,12 +1769,14 @@ paths:name: Philippinescurrency: PHPlocales:+ - tl- en- code: PKname: Pakistancurrency: PKRlocales:- en+ - ur- code: PLname: Polandcurrency: PLN@@ -1752,6 +1803,7 @@ paths:currency: ILSlocales:- ar+ - he- en- code: PTname: Portugal@@ -1768,6 +1820,7 @@ paths:currency: PYGlocales:- es+ - gn- code: QAname: Qatarcurrency: QAR@@ -1787,7 +1840,7 @@ paths:name: Serbiacurrency: RSDlocales:- - en+ - sr- code: RUname: Russian Federationcurrency: RUB@@ -1797,6 +1850,7 @@ paths:name: Rwandacurrency: RWFlocales:+ - rw- en- fr- code: SA@@ -1831,6 +1885,8 @@ paths:currency: SGDlocales:- en+ - ms+ - ta- code: SHname: Saint Helena, Ascension and Tristan da Cunhacurrency: SHP@@ -1840,12 +1896,12 @@ paths:name: Sloveniacurrency: EURlocales:- - sl-SI+ - sl- code: SJname: Svalbard and Jan Mayencurrency: NOKlocales:- - en+ - 'no'- code: SKname: Slovakiacurrency: EUR@@ -1870,6 +1926,7 @@ paths:name: Somaliacurrency: SOSlocales:+ - so- ar- code: SRname: Suriname@@ -1908,6 +1965,7 @@ paths:currency: SZLlocales:- en+ - ss- code: TCname: Turks and Caicos Islandscurrency: USD@@ -1933,6 +1991,7 @@ paths:name: Tajikistancurrency: TJSlocales:+ - tg- ru- code: TKname: Tokelau@@ -1948,7 +2007,7 @@ paths:name: Turkmenistancurrency: TMTlocales:- - en+ - tk- code: TNname: Tunisiacurrency: TND@@ -1960,6 +2019,7 @@ paths:currency: TOPlocales:- en+ - to- code: TRname: Türkiyecurrency: TRY@@ -1984,6 +2044,7 @@ paths:name: Tanzaniacurrency: TZSlocales:+ - sw- en- code: UAname: Ukraine@@ -1995,6 +2056,7 @@ paths:currency: UGXlocales:- en+ - sw- code: USname: United Statescurrency: USD@@ -2009,12 +2071,13 @@ paths:name: Uzbekistancurrency: UZSlocales:- - en+ - uz- code: VAname: Holy See (Vatican City State)currency: EURlocales:- it+ - la- code: VCname: Saint Vincent and the Grenadinescurrency: XCD@@ -2044,6 +2107,7 @@ paths:name: Vanuatucurrency: VUVlocales:+ - bi- en- fr- code: WF@@ -2055,6 +2119,7 @@ paths:name: Samoacurrency: WSTlocales:+ - sm- en- code: YEname: Yemen@@ -2070,7 +2135,16 @@ paths:name: South Africacurrency: ZARlocales:+ - af- en+ - nr+ - st+ - ss+ - tn+ - ts+ - ve+ - xh+ - zu- code: ZMname: Zambiacurrency: ZMW@@ -2081,6 +2155,8 @@ paths:currency: USDlocales:- en+ - sn+ - nd"/api/v3/admin/allowed_origins":get:summary: List allowed origins@@ -28001,15 +28077,12 @@ paths:example:data:- code: de- name: Deutschdefault: falsertl: false- code: en- name: Englishdefault: truertl: false- code: fr- name: Françaisdefault: falsertl: false"/api/v3/admin/store":@@ -28183,9 +28256,12 @@ paths:- en-GB- en-IN- en-NZ+ - en-US- eo- es- es-419+ - es-CL+ - es-EC- es-MX- et- eu@@ -28295,6 +28371,7 @@ paths:- si- sk- sl+ - sl-SI- sm- sn- so@@ -28522,9 +28599,12 @@ paths:- en-GB- en-IN- en-NZ+ - en-US- eo- es- es-419+ - es-CL+ - es-EC- es-MX- et- eu@@ -28634,6 +28714,7 @@ paths:- si- sk- sl+ - sl-SI- sm- sn- so@@ -52627,6 +52708,209 @@ components:locale:type: stringnullable: true+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zutotal_quantity:type: numberwarnings:@@ -57958,6 +58242,223 @@ components:- cost_price- tax_category_idx-typelizer: true+ Locale:+ type: object+ properties:+ code:+ type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zu+ default:+ type: boolean+ rtl:+ type: boolean+ required:+ - code+ - default+ - rtl+ x-typelizer: trueMarket:type: objectproperties:@@ -58148,6 +58649,209 @@ components:- ZWRdefault_locale:type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zutax_inclusive:type: booleandefault:@@ -58401,6 +59105,209 @@ components:type: arrayitems:type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zucountries:type: arrayitems:@@ -59306,6 +60213,209 @@ components:locale:type: stringnullable: true+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zutotal_quantity:type: numbercoupon_code:@@ -65233,6 +66343,209 @@ components:- ZWRdefault_locale:type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zudefault_country_code:type: stringnullable: true@@ -65592,10 +66905,416 @@ components:type: arrayitems:type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zuavailable_locales:type: arrayitems:type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zulogo_url:type: stringnullable: true@@ -69144,6 +70863,211 @@ components:- ZA- ZM- ZW+ LocaleCode:+ type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zuAddressInputParams:type: objectproperties:@@ -71996,7 +73920,8 @@ components:description: ISO 4217 currency code.example: EURdefault_locale:- type: string+ allOf:+ - "$ref": "#/components/schemas/LocaleCode"description: Locale used as the market default. Always part of `supported_locales`.example: detax_inclusive:@@ -72017,7 +73942,7 @@ components:supported_locales:type: arrayitems:- type: string+ "$ref": "#/components/schemas/LocaleCode"description: Locales available in this market. The default locale is alwaysincluded.example:@@ -72050,7 +73975,8 @@ components:description: ISO 4217 currency code.example: EURdefault_locale:- type: string+ allOf:+ - "$ref": "#/components/schemas/LocaleCode"description: Locale used as the market default. Always part of `supported_locales`.example: detax_inclusive:@@ -72071,7 +73997,7 @@ components:supported_locales:type: arrayitems:- type: string+ "$ref": "#/components/schemas/LocaleCode"description: Locales available in this market. The default locale is alwaysincluded.example:@@ -72468,7 +74394,8 @@ components:type: stringdescription: Defaults to the store primary channel when omitted.locale:- type: string+ allOf:+ - "$ref": "#/components/schemas/LocaleCode"example: en-UScustomer_note:type: string@@ -72601,7 +74528,8 @@ components:type: stringdescription: Defaults to the store primary channel when omitted.locale:- type: string+ allOf:+ - "$ref": "#/components/schemas/LocaleCode"example: en-UScustomer_note:type: string@@ -74974,7 +76902,8 @@ components:the default market, the warehouse, the delivery zones and the currency.example: USlocale:- type: string+ allOf:+ - "$ref": "#/components/schemas/LocaleCode"description: Storefront locale. Defaults to the country's own language.example: encurrency:diff --git a/docs/api-reference/store.yaml b/docs/api-reference/store.yamlindex dc7d6ff780..2a5ac8d909 100644--- a/docs/api-reference/store.yaml+++ b/docs/api-reference/store.yaml@@ -14067,6 +14067,209 @@ components:locale:type: stringnullable: true+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zutotal_quantity:type: numberwarnings:@@ -17368,8 +17571,212 @@ components:properties:code:type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zuname:type: string+ deprecated: truedefault:type: booleanrtl:@@ -17570,6 +17977,209 @@ components:- ZWRdefault_locale:type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zutax_inclusive:type: booleandefault:@@ -17828,6 +18438,209 @@ components:type: arrayitems:type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zucountries:type: arrayitems:@@ -18689,6 +19502,209 @@ components:locale:type: stringnullable: true+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zutotal_quantity:type: numbercoupon_code:@@ -22111,6 +23127,211 @@ components:- ZWL- ZWN- ZWR+ LocaleCode:+ type: string+ enum:+ - aa+ - ab+ - ae+ - af+ - ak+ - am+ - an+ - ar+ - as+ - av+ - ay+ - az+ - ba+ - be+ - bg+ - bh+ - bi+ - bm+ - bn+ - bo+ - br+ - bs+ - ca+ - ce+ - ch+ - co+ - cr+ - cs+ - cu+ - cv+ - cy+ - da+ - de+ - de-AT+ - de-CH+ - dv+ - dz+ - ee+ - el+ - en+ - en-AU+ - en-CA+ - en-GB+ - en-IN+ - en-NZ+ - en-US+ - eo+ - es+ - es-419+ - es-CL+ - es-EC+ - es-MX+ - et+ - eu+ - fa+ - ff+ - fi+ - fj+ - fo+ - fr+ - fr-CA+ - fy+ - ga+ - gd+ - gl+ - gn+ - gu+ - gv+ - ha+ - he+ - hi+ - ho+ - hr+ - ht+ - hu+ - hy+ - hz+ - ia+ - id+ - ie+ - ig+ - ii+ - ik+ - io+ - is+ - it+ - iu+ - ja+ - jv+ - ka+ - kg+ - ki+ - kj+ - kk+ - kl+ - km+ - kn+ - ko+ - kr+ - ks+ - ku+ - kv+ - kw+ - ky+ - la+ - lb+ - lg+ - li+ - ln+ - lo+ - lt+ - lu+ - lv+ - mg+ - mh+ - mi+ - mk+ - ml+ - mn+ - mr+ - ms+ - mt+ - my+ - na+ - nb+ - nd+ - ne+ - ng+ - nl+ - nn+ - 'no'+ - nr+ - nv+ - ny+ - oc+ - oj+ - om+ - or+ - os+ - pa+ - pi+ - pl+ - ps+ - pt+ - pt-BR+ - pt-PT+ - qu+ - rm+ - rn+ - ro+ - ru+ - rw+ - sa+ - sc+ - sd+ - se+ - sg+ - si+ - sk+ - sl+ - sl-SI+ - sm+ - sn+ - so+ - sq+ - sr+ - ss+ - st+ - su+ - sv+ - sw+ - ta+ - te+ - tg+ - th+ - ti+ - tk+ - tl+ - tn+ - to+ - tr+ - ts+ - tt+ - tw+ - ty+ - ug+ - uk+ - ur+ - uz+ - ve+ - vi+ - vo+ - wa+ - wo+ - xh+ - yi+ - yo+ - za+ - zh-CN+ - zh-HK+ - zh-TW+ - zuAcceptCompanyInvitationParams:type: objectproperties:@@ -22459,7 +23680,7 @@ components:currency:"$ref": "#/components/schemas/CurrencyCode"locale:- type: string+ "$ref": "#/components/schemas/LocaleCode"shipping_address_id:type: stringdescription: An existing address to ship to.@@ -22813,7 +24034,7 @@ components:currency:"$ref": "#/components/schemas/CurrencyCode"locale:- type: string+ "$ref": "#/components/schemas/LocaleCode"shipping_address_id:type: stringdescription: An existing address to ship to.diff --git a/docs/developer/upgrades/5.6-to-6.0.mdx b/docs/developer/upgrades/5.6-to-6.0.mdxindex f94f2663ed..fbc539b187 100644--- a/docs/developer/upgrades/5.6-to-6.0.mdx+++ b/docs/developer/upgrades/5.6-to-6.0.mdx@@ -933,6 +933,16 @@ bundle exec rake spree:money:audit_capture_events</CodeGroup>+## Locale codes come from a fixed list++A market's `default_locale` and `supported_locales`, and the store's own `default_locale` and `supported_locales`, accept only the codes in `Spree::Locales::ALL`: every ISO 639-1 language (`en`, `de`) plus the regional variants commerce needs (`en-US`, `en-GB`, `pt-BR`, `zh-CN`). The match is exact, so `pt-br` is refused in favour of `pt-BR`. Any other value is answered with `422` naming the codes Spree does not support. Since an order's or cart's `locale` must be one its store supports, it comes from the list too once the store's locales do. Store setup, seeds and the markets migration move a code Spree does not list to its listed language (`en-IE` becomes `en`, `zh` becomes `zh-CN`).++Values saved before the upgrade keep working until they are changed. If a market uses a code outside the list, change it to the listed spelling when you next edit it. The Store and Admin APIs publish the list as the `LocaleCode` type in the API reference and the SDK types.++A store's locales are content locales, independent of the languages anything ships translation files for: every listed code is accepted for content (product names, descriptions and other translated fields), while messages in a language Spree has no translations for fall back to English. An app that sets `config.i18n.available_locales` keeps that list as the limit. Store setup no longer limits the languages it offers to the ones Spree translates, and refuses a `locale` it cannot place with `422`.++Locale names move to the client. The `name` of a locale from `GET /locales` is deprecated in the Store API and removed in 6.1, and the Admin API no longer returns it: name a locale in the reader's language with `new Intl.DisplayNames([language], { type: 'language' }).of(code)`.+## Translations ship with SpreeSpree's translations for emails, API messages and validation messages are now part of Spree itself, in 43 languages besides English. Regional English (`en-GB` and the like) now falls back to `en`. A key a language does not translate yet falls back to English, unless your app configured its own `config.i18n.fallbacks`. See [Translations](/developer/core-concepts/translations#translating-the-interface).diff --git a/packages/admin-sdk/src/types/generated/Cart.ts b/packages/admin-sdk/src/types/generated/Cart.tsindex c23697e214..833139b577 100644--- a/packages/admin-sdk/src/types/generated/Cart.ts+++ b/packages/admin-sdk/src/types/generated/Cart.ts@@ -1,7 +1,7 @@-// Typelizer digest 4deba7885d7549b2d8f1f505d4ced15c+// Typelizer digest c223767d116e578016a40fca511df796//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {FreightSummary, LineItem, Address, Market, AppliedPromotion, CurrencyCode} from '@/types'+import type {FreightSummary, LineItem, Address, Market, AppliedPromotion, CurrencyCode, LocaleCode} from '@/types'interface Cart {id: string;@@ -18,7 +18,7 @@ interface Cart {customer_note: string | null;po_number: string | null;currency: CurrencyCode;- locale: string | null;+ locale: LocaleCode | null;total_quantity: number;warnings: Array<{code: string, message: string, line_item_id?: string, variant_id?: string, item_index?: number}>;coupon_code: string | null;diff --git a/packages/admin-sdk/src/types/generated/Enums.ts b/packages/admin-sdk/src/types/generated/Enums.tsindex c8b9b94f48..c18fbff817 100644--- a/packages/admin-sdk/src/types/generated/Enums.ts+++ b/packages/admin-sdk/src/types/generated/Enums.ts@@ -1,4 +1,4 @@-// Typelizer digest fbbf3b4bb49d44bb14fbac0c38bfaebb+// Typelizer digest f93fd87d8929666b964bb21d334b5990//// DO NOT MODIFY: This file was automatically generated by Typelizer.export type ActorKind = 'admin_user' | 'api_key' | (string & {});@@ -14,6 +14,7 @@ export type GiftCardStatus = 'active' | 'partially_redeemed' | 'redeemed' | 'canexport type ImportRowStatus = 'pending' | 'processing' | 'completed' | 'failed' | (string & {});export type ImportStatus = 'pending' | 'mapping' | 'completed_mapping' | 'processing' | 'completed' | 'failed' | (string & {});export type InvitationStatus = 'pending' | 'accepted' | (string & {});+export type LocaleCode = 'aa' | 'ab' | 'ae' | 'af' | 'ak' | 'am' | 'an' | 'ar' | 'as' | 'av' | 'ay' | 'az' | 'ba' | 'be' | 'bg' | 'bh' | 'bi' | 'bm' | 'bn' | 'bo' | 'br' | 'bs' | 'ca' | 'ce' | 'ch' | 'co' | 'cr' | 'cs' | 'cu' | 'cv' | 'cy' | 'da' | 'de' | 'de-AT' | 'de-CH' | 'dv' | 'dz' | 'ee' | 'el' | 'en' | 'en-AU' | 'en-CA' | 'en-GB' | 'en-IN' | 'en-NZ' | 'en-US' | 'eo' | 'es' | 'es-419' | 'es-CL' | 'es-EC' | 'es-MX' | 'et' | 'eu' | 'fa' | 'ff' | 'fi' | 'fj' | 'fo' | 'fr' | 'fr-CA' | 'fy' | 'ga' | 'gd' | 'gl' | 'gn' | 'gu' | 'gv' | 'ha' | 'he' | 'hi' | 'ho' | 'hr' | 'ht' | 'hu' | 'hy' | 'hz' | 'ia' | 'id' | 'ie' | 'ig' | 'ii' | 'ik' | 'io' | 'is' | 'it' | 'iu' | 'ja' | 'jv' | 'ka' | 'kg' | 'ki' | 'kj' | 'kk' | 'kl' | 'km' | 'kn' | 'ko' | 'kr' | 'ks' | 'ku' | 'kv' | 'kw' | 'ky' | 'la' | 'lb' | 'lg' | 'li' | 'ln' | 'lo' | 'lt' | 'lu' | 'lv' | 'mg' | 'mh' | 'mi' | 'mk' | 'ml' | 'mn' | 'mr' | 'ms' | 'mt' | 'my' | 'na' | 'nb' | 'nd' | 'ne' | 'ng' | 'nl' | 'nn' | 'no' | 'nr' | 'nv' | 'ny' | 'oc' | 'oj' | 'om' | 'or' | 'os' | 'pa' | 'pi' | 'pl' | 'ps' | 'pt' | 'pt-BR' | 'pt-PT' | 'qu' | 'rm' | 'rn' | 'ro' | 'ru' | 'rw' | 'sa' | 'sc' | 'sd' | 'se' | 'sg' | 'si' | 'sk' | 'sl' | 'sl-SI' | 'sm' | 'sn' | 'so' | 'sq' | 'sr' | 'ss' | 'st' | 'su' | 'sv' | 'sw' | 'ta' | 'te' | 'tg' | 'th' | 'ti' | 'tk' | 'tl' | 'tn' | 'to' | 'tr' | 'ts' | 'tt' | 'tw' | 'ty' | 'ug' | 'uk' | 'ur' | 'uz' | 've' | 'vi' | 'vo' | 'wa' | 'wo' | 'xh' | 'yi' | 'yo' | 'za' | 'zh-CN' | 'zh-HK' | 'zh-TW' | 'zu';export type PaymentStatus = 'checkout' | 'processing' | 'pending' | 'completed' | 'failed' | 'void' | 'invalid' | (string & {});export type PriceListStatus = 'draft' | 'active' | 'inactive' | 'scheduled' | (string & {});export type ProductStatus = 'draft' | 'active' | 'archived' | 'proposed' | 'rejected' | (string & {});diff --git a/packages/admin-sdk/src/types/generated/Locale.ts b/packages/admin-sdk/src/types/generated/Locale.tsnew file mode 100644index 0000000000..509ea11567--- /dev/null+++ b/packages/admin-sdk/src/types/generated/Locale.ts@@ -0,0 +1,12 @@+// Typelizer digest 5e4fc3ed376d16aa263939171e99866b+//+// DO NOT MODIFY: This file was automatically generated by Typelizer.+import type {LocaleCode} from '@/types'++interface Locale {+ code: LocaleCode;+ default: boolean;+ rtl: boolean;+}++export default Locale;diff --git a/packages/admin-sdk/src/types/generated/Market.ts b/packages/admin-sdk/src/types/generated/Market.tsindex e4cc9ff08e..af5846a727 100644--- a/packages/admin-sdk/src/types/generated/Market.ts+++ b/packages/admin-sdk/src/types/generated/Market.ts@@ -1,17 +1,17 @@-// Typelizer digest 0482e3e0902c22a0c0016c2196805bc7+// Typelizer digest 98e16f1d068d20fc439bf69a4b918f97//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {Country, CurrencyCode, CountryCode} from '@/types'+import type {Country, CurrencyCode, LocaleCode, CountryCode} from '@/types'interface Market {id: string;name: string;currency: CurrencyCode;- default_locale: string;+ default_locale: LocaleCode;tax_inclusive: boolean;default: boolean;country_codes: Array<CountryCode>;- supported_locales: Array<string>;+ supported_locales: Array<LocaleCode>;countries?: Array<Country>;created_at: string;updated_at: string;diff --git a/packages/admin-sdk/src/types/generated/Order.ts b/packages/admin-sdk/src/types/generated/Order.tsindex 404231ed59..c5dce0bf5e 100644--- a/packages/admin-sdk/src/types/generated/Order.ts+++ b/packages/admin-sdk/src/types/generated/Order.ts@@ -1,7 +1,7 @@-// Typelizer digest 2387609bdf23f7610c38d10587e00c0d+// Typelizer digest 04c3618a99d083a543edf7c710a05e51//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {FreightSummary, Payment, LineItem, Fulfillment, Address, GiftCard, Market, Seller, Actor, AppliedPromotion, PaymentSplit, Cart, Channel, StockLocation, PaymentMethod, Customer, OrderCancellationReason, Return, Exchange, Claim, CurrencyCode, ActorKind} from '@/types'+import type {FreightSummary, Payment, LineItem, Fulfillment, Address, GiftCard, Market, Seller, Actor, AppliedPromotion, PaymentSplit, Cart, Channel, StockLocation, PaymentMethod, Customer, OrderCancellationReason, Return, Exchange, Claim, CurrencyCode, LocaleCode, ActorKind} from '@/types'interface Order {id: string;@@ -19,7 +19,7 @@ interface Order {customer_note: string | null;po_number: string | null;currency: CurrencyCode;- locale: string | null;+ locale: LocaleCode | null;total_quantity: number;coupon_code: string | null;fulfillment_status: 'backorder' | 'canceled' | 'partial' | 'unfulfilled' | 'fulfilled' | 'delivered' | 'pending' | 'ready' | 'shipped' | null;diff --git a/packages/admin-sdk/src/types/generated/Store.ts b/packages/admin-sdk/src/types/generated/Store.tsindex cbf9e8dba5..39a9ce0d6b 100644--- a/packages/admin-sdk/src/types/generated/Store.ts+++ b/packages/admin-sdk/src/types/generated/Store.ts@@ -1,7 +1,7 @@-// Typelizer digest ceb55fed4c0acf8c45548f43904f8b22+// Typelizer digest 80d1d8ab46e16a5d14d50775a7196030//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {SetupTask, CurrencyCode} from '@/types'+import type {SetupTask, CurrencyCode, LocaleCode} from '@/types'interface Store {id: string;@@ -9,7 +9,7 @@ interface Store {name: string;code: string;default_currency: CurrencyCode;- default_locale: string;+ default_locale: LocaleCode;default_country_code: string | null;mail_from_address: string | null;customer_support_email: string | null;@@ -69,8 +69,8 @@ interface Store {api_url: string;setup_tasks: Array<SetupTask>;supported_currencies: Array<CurrencyCode>;- supported_locales: Array<string>;- available_locales: Array<string>;+ supported_locales: Array<LocaleCode>;+ available_locales: Array<LocaleCode>;logo_url: string | null;mailer_logo_url: string | null;}diff --git a/packages/admin-sdk/src/types/generated/emails/EmailMarket.ts b/packages/admin-sdk/src/types/generated/emails/EmailMarket.tsindex 4579da518f..5304afac43 100644--- a/packages/admin-sdk/src/types/generated/emails/EmailMarket.ts+++ b/packages/admin-sdk/src/types/generated/emails/EmailMarket.ts@@ -1,19 +1,19 @@-// Typelizer digest f0094d480a752f1db1a37d4d0c8c2dd9+// Typelizer digest a10b9d1c5ecd661e1d1fa0d050136647//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {CurrencyCode, CountryCode} from '.'+import type {CurrencyCode, LocaleCode, CountryCode} from '.'interface EmailMarket {id: string;name: string;currency: CurrencyCode;- default_locale: string;+ default_locale: LocaleCode;tax_inclusive: boolean;default: boolean;country_codes: Array<CountryCode>;/** @deprecated Use `country_codes`. Removed in 6.1. */country_isos: Array<string>;- supported_locales: Array<string>;+ supported_locales: Array<LocaleCode>;}export default EmailMarket;diff --git a/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts b/packages/admin-sdk/src/types/generated/emails/EmailOrder.tsindex 55119ef800..ce0564bc78 100644--- a/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts+++ b/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts@@ -1,7 +1,7 @@-// Typelizer digest f0337bcb7d0ecd69798be9baef6ab90c+// Typelizer digest 9f5e3587b0bee519b2d747845b95291e//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {EmailPayment, EmailAppliedPromotion, EmailFee, EmailLineItem, EmailFulfillment, EmailAddress, EmailGiftCard, EmailMarket, EmailAmountLine, CurrencyCode} from '.'+import type {EmailPayment, EmailAppliedPromotion, EmailFee, EmailLineItem, EmailFulfillment, EmailAddress, EmailGiftCard, EmailMarket, EmailAmountLine, CurrencyCode, LocaleCode} from '.'interface EmailOrder {id: string;@@ -19,7 +19,7 @@ interface EmailOrder {customer_note: string | null;po_number: string | null;currency: CurrencyCode;- locale: string | null;+ locale: LocaleCode | null;total_quantity: number;coupon_code: string | null;fulfillment_status: 'backorder' | 'canceled' | 'partial' | 'unfulfilled' | 'fulfilled' | 'delivered' | 'pending' | 'ready' | 'shipped' | null;diff --git a/packages/admin-sdk/src/types/generated/emails/Enums.ts b/packages/admin-sdk/src/types/generated/emails/Enums.tsindex 282ed76c9e..b67766fe59 100644--- a/packages/admin-sdk/src/types/generated/emails/Enums.ts+++ b/packages/admin-sdk/src/types/generated/emails/Enums.ts@@ -1,4 +1,4 @@-// Typelizer digest df636e9b498440f4e9359baa2b93d981+// Typelizer digest 773c139dee8340801536055ad1522650//// DO NOT MODIFY: This file was automatically generated by Typelizer.export type CountryCode = 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AO' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TC' | 'TD' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW';@@ -6,5 +6,6 @@ export type CurrencyCode = 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS'export type FeeKind = 'surcharge' | 'handling' | 'gift_wrap' | 'cod' | 'payment' | 'duty' | 'exchange' | (string & {});export type FulfillmentStatus = 'unfulfilled' | 'fulfilled' | 'delivered' | 'canceled' | (string & {});export type GiftCardStatus = 'active' | 'partially_redeemed' | 'redeemed' | 'canceled' | 'expired' | (string & {});+export type LocaleCode = 'aa' | 'ab' | 'ae' | 'af' | 'ak' | 'am' | 'an' | 'ar' | 'as' | 'av' | 'ay' | 'az' | 'ba' | 'be' | 'bg' | 'bh' | 'bi' | 'bm' | 'bn' | 'bo' | 'br' | 'bs' | 'ca' | 'ce' | 'ch' | 'co' | 'cr' | 'cs' | 'cu' | 'cv' | 'cy' | 'da' | 'de' | 'de-AT' | 'de-CH' | 'dv' | 'dz' | 'ee' | 'el' | 'en' | 'en-AU' | 'en-CA' | 'en-GB' | 'en-IN' | 'en-NZ' | 'en-US' | 'eo' | 'es' | 'es-419' | 'es-CL' | 'es-EC' | 'es-MX' | 'et' | 'eu' | 'fa' | 'ff' | 'fi' | 'fj' | 'fo' | 'fr' | 'fr-CA' | 'fy' | 'ga' | 'gd' | 'gl' | 'gn' | 'gu' | 'gv' | 'ha' | 'he' | 'hi' | 'ho' | 'hr' | 'ht' | 'hu' | 'hy' | 'hz' | 'ia' | 'id' | 'ie' | 'ig' | 'ii' | 'ik' | 'io' | 'is' | 'it' | 'iu' | 'ja' | 'jv' | 'ka' | 'kg' | 'ki' | 'kj' | 'kk' | 'kl' | 'km' | 'kn' | 'ko' | 'kr' | 'ks' | 'ku' | 'kv' | 'kw' | 'ky' | 'la' | 'lb' | 'lg' | 'li' | 'ln' | 'lo' | 'lt' | 'lu' | 'lv' | 'mg' | 'mh' | 'mi' | 'mk' | 'ml' | 'mn' | 'mr' | 'ms' | 'mt' | 'my' | 'na' | 'nb' | 'nd' | 'ne' | 'ng' | 'nl' | 'nn' | 'no' | 'nr' | 'nv' | 'ny' | 'oc' | 'oj' | 'om' | 'or' | 'os' | 'pa' | 'pi' | 'pl' | 'ps' | 'pt' | 'pt-BR' | 'pt-PT' | 'qu' | 'rm' | 'rn' | 'ro' | 'ru' | 'rw' | 'sa' | 'sc' | 'sd' | 'se' | 'sg' | 'si' | 'sk' | 'sl' | 'sl-SI' | 'sm' | 'sn' | 'so' | 'sq' | 'sr' | 'ss' | 'st' | 'su' | 'sv' | 'sw' | 'ta' | 'te' | 'tg' | 'th' | 'ti' | 'tk' | 'tl' | 'tn' | 'to' | 'tr' | 'ts' | 'tt' | 'tw' | 'ty' | 'ug' | 'uk' | 'ur' | 'uz' | 've' | 'vi' | 'vo' | 'wa' | 'wo' | 'xh' | 'yi' | 'yo' | 'za' | 'zh-CN' | 'zh-HK' | 'zh-TW' | 'zu';export type PaymentStatus = 'checkout' | 'processing' | 'pending' | 'completed' | 'failed' | 'void' | 'invalid' | (string & {});export type ReturnStatus = 'requested' | 'approved' | 'received' | 'refunded' | 'canceled' | (string & {});diff --git a/packages/admin-sdk/src/types/generated/emails/index.ts b/packages/admin-sdk/src/types/generated/emails/index.tsindex 4735676f37..d5926d8eb7 100644--- a/packages/admin-sdk/src/types/generated/emails/index.ts+++ b/packages/admin-sdk/src/types/generated/emails/index.ts@@ -1,7 +1,7 @@-// Typelizer digest c433592c8f03b732b455cae3f5c21359+// Typelizer digest a61e52614828f8917eddc10afd0e93a9//// DO NOT MODIFY: This file was automatically generated by Typelizer.-export type { CountryCode, CurrencyCode, FeeKind, FulfillmentStatus, GiftCardStatus, PaymentStatus, ReturnStatus } from './Enums'+export type { CountryCode, CurrencyCode, FeeKind, FulfillmentStatus, GiftCardStatus, LocaleCode, PaymentStatus, ReturnStatus } from './Enums'export type { default as EmailAddress } from './EmailAddress'export type { default as EmailAmountLine } from './EmailAmountLine'export type { default as EmailAppliedPromotion } from './EmailAppliedPromotion'diff --git a/packages/admin-sdk/src/types/generated/index.ts b/packages/admin-sdk/src/types/generated/index.tsindex 181528e27c..d34d3900c4 100644--- a/packages/admin-sdk/src/types/generated/index.ts+++ b/packages/admin-sdk/src/types/generated/index.ts@@ -1,7 +1,7 @@-// Typelizer digest cb61ebedcdc83664249ac0373ccd583e+// Typelizer digest 68c268fa4531bf238b43969cb511355a//// DO NOT MODIFY: This file was automatically generated by Typelizer.-export type { ActorKind, ClaimStatus, CountryCode, CurrencyCode, DataRequestStatus, ExchangeStatus, FeeKind, FulfillmentItemStatus, FulfillmentStatus, GiftCardStatus, ImportRowStatus, ImportStatus, InvitationStatus, PaymentStatus, PriceListStatus, ProductStatus, ProductSubmissionStatus, ReturnStatus, SellerPayoutStatus, SellerRequirementSubmissionStatus, SellerStatus, SellerTransferStatus, ShippingLabelStatus, StockLocationKind, TaxExemptionCertificateStatus } from './Enums'+export type { ActorKind, ClaimStatus, CountryCode, CurrencyCode, DataRequestStatus, ExchangeStatus, FeeKind, FulfillmentItemStatus, FulfillmentStatus, GiftCardStatus, ImportRowStatus, ImportStatus, InvitationStatus, LocaleCode, PaymentStatus, PriceListStatus, ProductStatus, ProductSubmissionStatus, ReturnStatus, SellerPayoutStatus, SellerRequirementSubmissionStatus, SellerStatus, SellerTransferStatus, ShippingLabelStatus, StockLocationKind, TaxExemptionCertificateStatus } from './Enums'export type { default as Actor } from './Actor'export type { default as Address } from './Address'export type { default as AdminUser } from './AdminUser'@@ -76,6 +76,7 @@ export type { default as Integration } from './Integration'export type { default as InvitationAcceptanceLink } from './InvitationAcceptanceLink'export type { default as Invitation } from './Invitation'export type { default as LineItem } from './LineItem'+export type { default as Locale } from './Locale'export type { default as Market } from './Market'export type { default as Media } from './Media'export type { default as MembershipProduct } from './MembershipProduct'diff --git a/packages/admin-sdk/src/types/index.ts b/packages/admin-sdk/src/types/index.tsindex 1c865d2bbd..9f671cd4c7 100644--- a/packages/admin-sdk/src/types/index.ts+++ b/packages/admin-sdk/src/types/index.ts@@ -126,6 +126,7 @@ export type { default as Integration } from './generated/Integration'export type { default as Invitation } from './generated/Invitation'export type { default as InvitationAcceptanceLink } from './generated/InvitationAcceptanceLink'export type { default as LineItem } from './generated/LineItem'+export type { default as Locale } from './generated/Locale'export type { default as Market } from './generated/Market'export type { default as Media } from './generated/Media'export type { default as OptionType } from './generated/OptionType'@@ -198,7 +199,6 @@ export type { default as WebhookEvent } from './generated/WebhookEvent'export type * from './preferences'// Hand-written translation-management types (controller-shaped, not generated)export type {- Locale,LocaleTranslations,ResourceTranslations,ResourceTranslationsNode,diff --git a/packages/admin-sdk/src/types/params/MarketCreateParams.ts b/packages/admin-sdk/src/types/params/MarketCreateParams.tsindex fdb37ac2f6..d26afe8696 100644--- a/packages/admin-sdk/src/types/params/MarketCreateParams.ts+++ b/packages/admin-sdk/src/types/params/MarketCreateParams.ts@@ -2,6 +2,7 @@import type { CountryCode } from '../generated'import type { CurrencyCode } from '../generated'+import type { LocaleCode } from '../generated'export type MarketCreateParams = {/** Display name, unique within the store. */@@ -9,7 +10,7 @@ export type MarketCreateParams = {/** ISO 4217 currency code. */currency: CurrencyCode/** Locale used as the market default. Always part of `supported_locales`. */- default_locale: string+ default_locale: LocaleCode/** Display prices with tax included. */tax_inclusive?: boolean/**@@ -22,7 +23,7 @@ export type MarketCreateParams = {/** Sort order within the store; lower comes first. */position?: number/** Locales available in this market. The default locale is always included. */- supported_locales?: string[]+ supported_locales?: LocaleCode[]/** ISO 3166-1 alpha-2 codes of the countries in this market. At least one is required. */country_codes: CountryCode[]}diff --git a/packages/admin-sdk/src/types/params/MarketUpdateParams.ts b/packages/admin-sdk/src/types/params/MarketUpdateParams.tsindex 51acb21446..c433443e20 100644--- a/packages/admin-sdk/src/types/params/MarketUpdateParams.ts+++ b/packages/admin-sdk/src/types/params/MarketUpdateParams.ts@@ -2,6 +2,7 @@import type { CountryCode } from '../generated'import type { CurrencyCode } from '../generated'+import type { LocaleCode } from '../generated'export type MarketUpdateParams = {/** Display name, unique within the store. */@@ -9,7 +10,7 @@ export type MarketUpdateParams = {/** ISO 4217 currency code. */currency?: CurrencyCode/** Locale used as the market default. Always part of `supported_locales`. */- default_locale?: string+ default_locale?: LocaleCode/** Display prices with tax included. */tax_inclusive?: boolean/**@@ -22,7 +23,7 @@ export type MarketUpdateParams = {/** Sort order within the store; lower comes first. */position?: number/** Locales available in this market. The default locale is always included. */- supported_locales?: string[]+ supported_locales?: LocaleCode[]/** ISO 3166-1 alpha-2 codes of the countries in this market. At least one is required. */country_codes?: CountryCode[]}diff --git a/packages/admin-sdk/src/types/params/OrderCreateParams.ts b/packages/admin-sdk/src/types/params/OrderCreateParams.tsindex bd9fec807a..d492a1f328 100644--- a/packages/admin-sdk/src/types/params/OrderCreateParams.ts+++ b/packages/admin-sdk/src/types/params/OrderCreateParams.ts@@ -2,6 +2,7 @@import type { AddressInputParams } from './AddressInputParams'import type { CurrencyCode } from '../generated'+import type { LocaleCode } from '../generated'export type OrderCreateParams = {/**@@ -21,7 +22,7 @@ export type OrderCreateParams = {market_id?: string/** Defaults to the store primary channel when omitted. */channel_id?: string- locale?: string+ locale?: LocaleCode/** Public, customer-visible note. */customer_note?: string/** Staff-only note. Rich text HTML; reads come back as this plus `internal_note_html`. */diff --git a/packages/admin-sdk/src/types/params/OrderUpdateParams.ts b/packages/admin-sdk/src/types/params/OrderUpdateParams.tsindex c6c0263883..27316ed7ad 100644--- a/packages/admin-sdk/src/types/params/OrderUpdateParams.ts+++ b/packages/admin-sdk/src/types/params/OrderUpdateParams.ts@@ -2,6 +2,7 @@import type { AddressInputParams } from './AddressInputParams'import type { CurrencyCode } from '../generated'+import type { LocaleCode } from '../generated'export type OrderUpdateParams = {/**@@ -17,7 +18,7 @@ export type OrderUpdateParams = {market_id?: string/** Defaults to the store primary channel when omitted. */channel_id?: string- locale?: string+ locale?: LocaleCode/** Public, customer-visible note. */customer_note?: string/** Staff-only note. Rich text HTML; reads come back as this plus `internal_note_html`. */diff --git a/packages/admin-sdk/src/types/params/SetupParams.ts b/packages/admin-sdk/src/types/params/SetupParams.tsindex 3ed4e4c40c..5f817d7b11 100644--- a/packages/admin-sdk/src/types/params/SetupParams.ts+++ b/packages/admin-sdk/src/types/params/SetupParams.ts@@ -2,6 +2,7 @@import type { CountryCode } from '../generated'import type { CurrencyCode } from '../generated'+import type { LocaleCode } from '../generated'export type SetupParams = {/** The one-time token from the install output. */@@ -18,7 +19,7 @@ export type SetupParams = {*/country_code: CountryCode/** Storefront locale. Defaults to the country's own language. */- locale?: string+ locale?: LocaleCode/*** ISO 4217 currency. Defaults to the country's own currency: pass one only when the store prices* in something else.diff --git a/packages/admin-sdk/src/types/translations.ts b/packages/admin-sdk/src/types/translations.tsindex cc97c01eaf..fd2bc9613f 100644--- a/packages/admin-sdk/src/types/translations.ts+++ b/packages/admin-sdk/src/types/translations.ts@@ -58,14 +58,6 @@ export interface TranslationBatchEntry {values: TranslationsUpsertParams}-/** A supported locale as returned by `GET /admin/locales`. */-export interface Locale {- code: string- name: string- default: boolean- rtl: boolean-}-/** A translatable resource entry from `GET /admin/translatable_resources`. */export interface TranslatableResource {resource_type: stringdiff --git a/packages/admin-sdk/src/zod/generated/Locale.ts b/packages/admin-sdk/src/zod/generated/Locale.tsnew file mode 100644index 0000000000..81b156d367--- /dev/null+++ b/packages/admin-sdk/src/zod/generated/Locale.ts@@ -0,0 +1,10 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const LocaleSchema = z.object({+ code: z.string(),+ default: z.boolean(),+ rtl: z.boolean(),+});++export type Locale = z.infer<typeof LocaleSchema>;diff --git a/packages/admin-sdk/src/zod/generated/index.ts b/packages/admin-sdk/src/zod/generated/index.tsindex 1c351b04e8..993017e69e 100644--- a/packages/admin-sdk/src/zod/generated/index.ts+++ b/packages/admin-sdk/src/zod/generated/index.ts@@ -73,6 +73,7 @@ export { IntegrationSchema, type Integration } from './Integration';export { InvitationSchema, type Invitation } from './Invitation';export { InvitationAcceptanceLinkSchema, type InvitationAcceptanceLink } from './InvitationAcceptanceLink';export { LineItemSchema, type LineItem } from './LineItem';+export { LocaleSchema, type Locale } from './Locale';export { MarketSchema, type Market } from './Market';export { MediaSchema, type Media } from './Media';export { MembershipProductSchema, type MembershipProduct } from './MembershipProduct';diff --git a/packages/dashboard-core/src/hooks/use-display-name.ts b/packages/dashboard-core/src/hooks/use-display-name.tsindex 916634187c..e79132efa2 100644--- a/packages/dashboard-core/src/hooks/use-display-name.ts+++ b/packages/dashboard-core/src/hooks/use-display-name.ts@@ -37,6 +37,14 @@ export function useDisplayName(type: Intl.DisplayNamesType) {} catch {formatter = undefined}- return (code: string) => formatter?.of(code)+ // `of` throws a RangeError for a malformed code (a legacy `english`), so+ // such a code reads as unnamed rather than breaking the page.+ return (code: string) => {+ try {+ return formatter?.of(code)+ } catch {+ return undefined+ }+ }}, [locale, type])}diff --git a/packages/dashboard-core/src/lib/iso-codes.ts b/packages/dashboard-core/src/lib/iso-codes.tsindex 274bee49c5..42b43365e4 100644--- a/packages/dashboard-core/src/lib/iso-codes.ts+++ b/packages/dashboard-core/src/lib/iso-codes.ts@@ -1,4 +1,4 @@-import type { CountryCode, CurrencyCode } from '@spree/admin-sdk'+import type { CountryCode, CurrencyCode, LocaleCode } from '@spree/admin-sdk'import i18n from 'i18next'import { z } from 'zod/v4'@@ -18,6 +18,14 @@ export function isCurrencyCode(value: unknown): value is CurrencyCode {return typeof value === 'string' && /^[A-Z]{3}$/.test(value)}+/**+ * Whether a value has the shape of a locale code: an ISO 639-1 language,+ * optionally with a region (`en`, `pt-BR`, `es-419`). See `isCountryCode`.+ */+export function isLocaleCode(value: unknown): value is LocaleCode {+ return typeof value === 'string' && /^[a-z]{2,3}(-[A-Z0-9]{2,3})?$/.test(value)+}+/*** A required country field. A form that allows leaving it blank widens it* with `.or(z.literal(''))` and sends `value || null` (or `|| undefined`).@@ -30,3 +38,8 @@ export const countryCodeSchema = z.custom<CountryCode>(isCountryCode, {export const currencyCodeSchema = z.custom<CurrencyCode>(isCurrencyCode, {error: () => i18n.t('admin.validation.currency_required'),})++/** A required locale field. See `countryCodeSchema`. */+export const localeCodeSchema = z.custom<LocaleCode>(isLocaleCode, {+ error: () => i18n.t('admin.validation.locale_required'),+})diff --git a/packages/dashboard-core/src/locales/ar.json b/packages/dashboard-core/src/locales/ar.jsonindex a483398f23..dfd6f19c7b 100644--- a/packages/dashboard-core/src/locales/ar.json+++ b/packages/dashboard-core/src/locales/ar.json@@ -1469,6 +1469,7 @@},"country_required": "البلد مطلوب","currency_required": "العملة مطلوبة",+ "locale_required": "اللغة مطلوبة","first_name_required": "الاسم الأول مطلوب","invalid_email": "أدخل بريدًا إلكترونيًا صالحًا","invalid_email_or_password": "بريد إلكتروني أو كلمة مرور غير صالحة",diff --git a/packages/dashboard-core/src/locales/de.json b/packages/dashboard-core/src/locales/de.jsonindex 883218c903..2386e58ba5 100644--- a/packages/dashboard-core/src/locales/de.json+++ b/packages/dashboard-core/src/locales/de.json@@ -1469,6 +1469,7 @@},"country_required": "Land ist erforderlich","currency_required": "Währung ist erforderlich",+ "locale_required": "Sprache ist erforderlich","first_name_required": "Vorname ist erforderlich","invalid_email": "Geben Sie eine gültige E-Mail-Adresse ein","invalid_email_or_password": "Ungültige E-Mail-Adresse oder ungültiges Passwort",diff --git a/packages/dashboard-core/src/locales/en.json b/packages/dashboard-core/src/locales/en.jsonindex c1e4f56de1..2de547a3b0 100644--- a/packages/dashboard-core/src/locales/en.json+++ b/packages/dashboard-core/src/locales/en.json@@ -1471,6 +1471,7 @@},"country_required": "Country is required","currency_required": "Currency is required",+ "locale_required": "Language is required","first_name_required": "First name is required","invalid_email": "Enter a valid email","invalid_email_or_password": "Invalid email or password",diff --git a/packages/dashboard-core/src/locales/es.json b/packages/dashboard-core/src/locales/es.jsonindex 2a8c1c3956..2e219d877b 100644--- a/packages/dashboard-core/src/locales/es.json+++ b/packages/dashboard-core/src/locales/es.json@@ -1614,6 +1614,7 @@},"country_required": "El país es obligatorio","currency_required": "La moneda es obligatoria",+ "locale_required": "El idioma es obligatorio","first_name_required": "El nombre es obligatorio","invalid_email": "Ingresá un email válido","invalid_email_or_password": "Email o contraseña inválidos",diff --git a/packages/dashboard-core/src/locales/fr.json b/packages/dashboard-core/src/locales/fr.jsonindex 900f4371e9..edef9ad1ac 100644--- a/packages/dashboard-core/src/locales/fr.json+++ b/packages/dashboard-core/src/locales/fr.json@@ -1469,6 +1469,7 @@},"country_required": "Le pays est requis","currency_required": "La devise est requise",+ "locale_required": "La langue est requise","first_name_required": "Le prénom est obligatoire","invalid_email": "Saisissez une adresse e-mail valide","invalid_email_or_password": "E-mail ou mot de passe invalide",diff --git a/packages/dashboard-core/src/locales/pl.json b/packages/dashboard-core/src/locales/pl.jsonindex 053686b433..1563475bf1 100644--- a/packages/dashboard-core/src/locales/pl.json+++ b/packages/dashboard-core/src/locales/pl.json@@ -1486,6 +1486,7 @@},"country_required": "Kraj jest wymagany","currency_required": "Waluta jest wymagana",+ "locale_required": "Język jest wymagany","first_name_required": "Imię jest wymagane","invalid_email": "Wprowadź prawidłowy adres e-mail","invalid_email_or_password": "Nieprawidłowy adres e-mail lub hasło",diff --git a/packages/dashboard-core/src/locales/zh-CN.json b/packages/dashboard-core/src/locales/zh-CN.jsonindex 10aafcb204..0c48b311dd 100644--- a/packages/dashboard-core/src/locales/zh-CN.json+++ b/packages/dashboard-core/src/locales/zh-CN.json@@ -1469,6 +1469,7 @@},"country_required": "请选择国家/地区","currency_required": "请选择货币",+ "locale_required": "请选择语言","first_name_required": "名字为必填项","invalid_email": "请输入有效的邮箱地址","invalid_email_or_password": "邮箱或密码无效",diff --git a/packages/dashboard-core/src/providers/store-provider.tsx b/packages/dashboard-core/src/providers/store-provider.tsxindex de10e6f45c..3145dd3c27 100644--- a/packages/dashboard-core/src/providers/store-provider.tsx+++ b/packages/dashboard-core/src/providers/store-provider.tsx@@ -1,4 +1,4 @@-import type { CurrencyCode, Store } from '@spree/admin-sdk'+import type { CurrencyCode, LocaleCode, Store } from '@spree/admin-sdk'import { useQuery } from '@tanstack/react-query'import { createContext, type ReactNode, useContext, useEffect, useRef } from 'react'import { adminClient } from '../client'@@ -21,13 +21,13 @@ interface StoreContextValue {isLoading: booleancurrencies: CurrencyCode[]/** Locales this store is configured to translate content into. */- locales: string[]+ locales: LocaleCode[]/** Every locale a merchant may translate content into — the full canonical* set, independent of which locales the store currently uses. Drives locale* pickers so a new locale can always be added. */- availableLocales: string[]+ availableLocales: LocaleCode[]defaultCurrency: CurrencyCode- defaultLocale: string+ defaultLocale: LocaleCode/** ISO country the store sells from — used to pre-fill new address forms. */defaultCountry: string/** IANA timezone for the store (e.g. `Europe/Berlin`). Falls back to thediff --git a/packages/dashboard/src/hooks/use-translations.ts b/packages/dashboard/src/hooks/use-translations.tsindex bdd8fc186c..5d4f9da512 100644--- a/packages/dashboard/src/hooks/use-translations.ts+++ b/packages/dashboard/src/hooks/use-translations.ts@@ -1,32 +1,25 @@import type {- Locale,ResourceTranslations,TranslatableResource,TranslationCoverage,} from '@spree/admin-sdk'-import { adminClient, useResourceKey, useResourceKeyBuilder } from '@spree/dashboard-core'+import {+ adminClient,+ useDisplayName,+ useResourceKey,+ useResourceKeyBuilder,+} from '@spree/dashboard-core'import { useQuery, useQueryClient } from '@tanstack/react-query'import { useCallback } from 'react'-/** The locales a merchant can translate content into (for nice display names). */-export function useLocales() {- return useQuery<Locale[]>({- queryKey: useResourceKey('locales'),- queryFn: () => adminClient.locales.list(),- })-}-/**- * Resolves a locale code to the display name the server reports for it,- * falling back to the bare code while the locale list is still loading.+ * Names a locale code in the admin's own language (`pt-BR` reads "Brazilian+ * Portuguese"), falling back to the bare code where the browser has no name.*/export function useLocaleName() {- const { data: locales } = useLocales()+ const displayName = useDisplayName('language')- return useCallback(- (code: string) => locales?.find((locale) => locale.code === code)?.name ?? code,- [locales],- )+ return useCallback((code: string) => displayName(code) ?? code, [displayName])}/**diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/$templateId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/$templateId.tsxindex a3fe086ae9..2fcf4f8405 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/$templateId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/$templateId.tsx@@ -80,7 +80,8 @@ function EmailTemplateEditorPage() {const { permissions } = usePermissions()const canRead = permissions.can('read', Subject.EmailTemplate)const { defaultLocale } = useStore()- const [language, setLanguage] = useState(defaultLocale)+ // Plain text, not a locale code: a version can also cover every language.+ const [language, setLanguage] = useState<string>(defaultLocale)const [reloads, setReloads] = useState(0)const {data: template,diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/markets.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/markets.tsxindex 3cf8f649ed..f1070cd145 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/markets.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/markets.tsx@@ -400,6 +400,7 @@ function MarketFormFields({ form }: { form: UseFormReturn<MarketFormValues> }) {<span className="text-xs text-muted-foreground">{t('admin.fields.market.supported_locales.help')}</span>+ <FieldError errors={[errors.supported_locales]} /></Field><Field>diff --git a/packages/dashboard/src/schemas/auth.ts b/packages/dashboard/src/schemas/auth.tsindex 9a958e4f5d..e2018383e4 100644--- a/packages/dashboard/src/schemas/auth.ts+++ b/packages/dashboard/src/schemas/auth.ts@@ -1,4 +1,9 @@-import { countryCodeSchema, currencyCodeSchema, i18n } from '@spree/dashboard-core'+import {+ countryCodeSchema,+ currencyCodeSchema,+ i18n,+ localeCodeSchema,+} from '@spree/dashboard-core'import { z } from 'zod/v4'// Lazy message factories — Zod v4 accepts `{ error: () => string }` as an@@ -70,7 +75,7 @@ export const setupFormSchema = zpassword_confirmation: z.string(),store_name: z.string().min(1, { error: () => i18n.t('admin.validation.store_name_required') }),country_code: countryCodeSchema,- locale: z.string().min(1),+ locale: localeCodeSchema,currency: currencyCodeSchema,sample_data: z.boolean(),})diff --git a/packages/dashboard/src/schemas/market.ts b/packages/dashboard/src/schemas/market.tsindex 51eb64ee7a..5d2fb53ee7 100644--- a/packages/dashboard/src/schemas/market.ts+++ b/packages/dashboard/src/schemas/market.ts@@ -1,4 +1,4 @@-import type { MarketCreateParams, MarketUpdateParams } from '@spree/admin-sdk'+import type { LocaleCode, MarketCreateParams, MarketUpdateParams } from '@spree/admin-sdk'import { countryCodeSchema, currencyCodeSchema } from '@spree/dashboard-core'import { requiredMessage } from '@spree/dashboard-ui'import type { DefaultValues } from 'react-hook-form'@@ -7,6 +7,9 @@ import { z } from 'zod/v4'export const marketFormSchema = z.object({name: z.string().min(1, { error: requiredMessage('name') }),currency: currencyCodeSchema,+ // Only required here, not checked against the locale list: a market saved+ // before the list was enforced keeps its locale until someone changes it,+ // and the server names any changed code it does not list.default_locale: z.string().min(1, { error: requiredMessage('market.default_locale') }),supported_locales: z.array(z.string()),tax_inclusive: z.boolean(),@@ -23,7 +26,6 @@ export type MarketFormValues = z.infer<typeof marketFormSchema>// No currency: a new market takes the store's, and an edited one its own.export const MARKET_DEFAULTS: DefaultValues<MarketFormValues> = {name: '',- default_locale: '',supported_locales: [],tax_inclusive: false,default: false,@@ -35,10 +37,10 @@ export function marketValuesToParams(v: MarketFormValues): MarketCreateParams &return {name: v.name,currency: v.currency,- default_locale: v.default_locale,+ default_locale: v.default_locale as LocaleCode,// The default locale is always implicitly included server-side; strip// duplicates here so the request stays compact.- supported_locales: v.supported_locales.filter((l) => l !== v.default_locale),+ supported_locales: v.supported_locales.filter((l) => l !== v.default_locale) as LocaleCode[],tax_inclusive: v.tax_inclusive,default: v.default,country_codes: v.country_codes,diff --git a/packages/sdk-core/src/params-types.ts b/packages/sdk-core/src/params-types.tsindex 96acecea8f..87b250fa92 100644--- a/packages/sdk-core/src/params-types.ts+++ b/packages/sdk-core/src/params-types.ts@@ -28,10 +28,11 @@ export interface ParamsSpec {const isRequestSchema = (name: string) => name.endsWith('Params')-// ISO code lists the request schemas reference by name. The response types-// generated beside these files declare the same named types, so a request-// imports them from there rather than repeating them.-const SHARED_CODE_LISTS = new Set(['CountryCode', 'CurrencyCode'])+// Code lists the request schemas reference by name: ISO countries and+// currencies, and Spree's locales. The response types generated beside these+// files declare the same named types, so a request imports them from there+// rather than repeating them.+const SHARED_CODE_LISTS = new Set(['CountryCode', 'CurrencyCode', 'LocaleCode'])function refName(ref: string): string {const name = ref.replace('#/components/schemas/', '')diff --git a/packages/sdk/src/types/generated/Cart.ts b/packages/sdk/src/types/generated/Cart.tsindex abad4aced1..d20c06c23e 100644--- a/packages/sdk/src/types/generated/Cart.ts+++ b/packages/sdk/src/types/generated/Cart.ts@@ -1,7 +1,7 @@-// Typelizer digest 936d2dad44ce54fc5a6454c7069c6151+// Typelizer digest ecde6347a019a741b11b4f54bf98ea40//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {FreightSummary, Payment, AppliedPromotion, Fee, LineItem, Fulfillment, Address, PaymentMethod, GiftCard, Market, CurrencyCode} from '@/types'+import type {FreightSummary, Payment, AppliedPromotion, Fee, LineItem, Fulfillment, Address, PaymentMethod, GiftCard, Market, CurrencyCode, LocaleCode} from '@/types'interface Cart {id: string;@@ -20,7 +20,7 @@ interface Cart {customer_note: string | null;po_number: string | null;currency: CurrencyCode;- locale: string | null;+ locale: LocaleCode | null;total_quantity: number;warnings: Array<{code: string, message: string, line_item_id?: string, variant_id?: string, item_index?: number}>;coupon_code: string | null;diff --git a/packages/sdk/src/types/generated/Enums.ts b/packages/sdk/src/types/generated/Enums.tsindex 26b584922e..c82d664142 100644--- a/packages/sdk/src/types/generated/Enums.ts+++ b/packages/sdk/src/types/generated/Enums.ts@@ -1,4 +1,4 @@-// Typelizer digest 916cafe3405c6aeb2ef2db2e82e2247e+// Typelizer digest c268461d65135f794dd411ba95c04214//// DO NOT MODIFY: This file was automatically generated by Typelizer.export type ClaimStatus = 'open' | 'approved' | 'resolved' | 'denied' | 'canceled' | (string & {});@@ -12,6 +12,7 @@ export type GiftCardStatus = 'active' | 'partially_redeemed' | 'redeemed' | 'canexport type ImportRowStatus = 'pending' | 'processing' | 'completed' | 'failed' | (string & {});export type ImportStatus = 'pending' | 'mapping' | 'completed_mapping' | 'processing' | 'completed' | 'failed' | (string & {});export type InvitationStatus = 'pending' | 'accepted' | (string & {});+export type LocaleCode = 'aa' | 'ab' | 'ae' | 'af' | 'ak' | 'am' | 'an' | 'ar' | 'as' | 'av' | 'ay' | 'az' | 'ba' | 'be' | 'bg' | 'bh' | 'bi' | 'bm' | 'bn' | 'bo' | 'br' | 'bs' | 'ca' | 'ce' | 'ch' | 'co' | 'cr' | 'cs' | 'cu' | 'cv' | 'cy' | 'da' | 'de' | 'de-AT' | 'de-CH' | 'dv' | 'dz' | 'ee' | 'el' | 'en' | 'en-AU' | 'en-CA' | 'en-GB' | 'en-IN' | 'en-NZ' | 'en-US' | 'eo' | 'es' | 'es-419' | 'es-CL' | 'es-EC' | 'es-MX' | 'et' | 'eu' | 'fa' | 'ff' | 'fi' | 'fj' | 'fo' | 'fr' | 'fr-CA' | 'fy' | 'ga' | 'gd' | 'gl' | 'gn' | 'gu' | 'gv' | 'ha' | 'he' | 'hi' | 'ho' | 'hr' | 'ht' | 'hu' | 'hy' | 'hz' | 'ia' | 'id' | 'ie' | 'ig' | 'ii' | 'ik' | 'io' | 'is' | 'it' | 'iu' | 'ja' | 'jv' | 'ka' | 'kg' | 'ki' | 'kj' | 'kk' | 'kl' | 'km' | 'kn' | 'ko' | 'kr' | 'ks' | 'ku' | 'kv' | 'kw' | 'ky' | 'la' | 'lb' | 'lg' | 'li' | 'ln' | 'lo' | 'lt' | 'lu' | 'lv' | 'mg' | 'mh' | 'mi' | 'mk' | 'ml' | 'mn' | 'mr' | 'ms' | 'mt' | 'my' | 'na' | 'nb' | 'nd' | 'ne' | 'ng' | 'nl' | 'nn' | 'no' | 'nr' | 'nv' | 'ny' | 'oc' | 'oj' | 'om' | 'or' | 'os' | 'pa' | 'pi' | 'pl' | 'ps' | 'pt' | 'pt-BR' | 'pt-PT' | 'qu' | 'rm' | 'rn' | 'ro' | 'ru' | 'rw' | 'sa' | 'sc' | 'sd' | 'se' | 'sg' | 'si' | 'sk' | 'sl' | 'sl-SI' | 'sm' | 'sn' | 'so' | 'sq' | 'sr' | 'ss' | 'st' | 'su' | 'sv' | 'sw' | 'ta' | 'te' | 'tg' | 'th' | 'ti' | 'tk' | 'tl' | 'tn' | 'to' | 'tr' | 'ts' | 'tt' | 'tw' | 'ty' | 'ug' | 'uk' | 'ur' | 'uz' | 've' | 'vi' | 'vo' | 'wa' | 'wo' | 'xh' | 'yi' | 'yo' | 'za' | 'zh-CN' | 'zh-HK' | 'zh-TW' | 'zu';export type PaymentSessionStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'canceled' | 'expired' | (string & {});export type PaymentSetupSessionStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'canceled' | 'expired' | (string & {});export type PaymentStatus = 'checkout' | 'processing' | 'pending' | 'completed' | 'failed' | 'void' | 'invalid' | (string & {});diff --git a/packages/sdk/src/types/generated/Locale.ts b/packages/sdk/src/types/generated/Locale.tsindex d2458e6761..92f7ff1ae9 100644--- a/packages/sdk/src/types/generated/Locale.ts+++ b/packages/sdk/src/types/generated/Locale.ts@@ -1,9 +1,11 @@-// Typelizer digest ea08de9001e7af2870da3f0636d77859+// Typelizer digest 32e15beb166628a43c35ef3778ba762b//// DO NOT MODIFY: This file was automatically generated by Typelizer.+import type {LocaleCode} from '@/types'interface Locale {- code: string;+ code: LocaleCode;+ /** @deprecated Name the locale from `code` with `Intl.DisplayNames`. Removed in 6.1. */name: string;default: boolean;rtl: boolean;diff --git a/packages/sdk/src/types/generated/Market.ts b/packages/sdk/src/types/generated/Market.tsindex 137eba425a..f0b01b37f1 100644--- a/packages/sdk/src/types/generated/Market.ts+++ b/packages/sdk/src/types/generated/Market.ts@@ -1,19 +1,19 @@-// Typelizer digest f589778921b953a313a64e7e7fcfc11d+// Typelizer digest 6d599a68329d00a9d3c7100eb77dcac9//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {Country, CurrencyCode, CountryCode} from '@/types'+import type {Country, CurrencyCode, LocaleCode, CountryCode} from '@/types'interface Market {id: string;name: string;currency: CurrencyCode;- default_locale: string;+ default_locale: LocaleCode;tax_inclusive: boolean;default: boolean;country_codes: Array<CountryCode>;/** @deprecated Use `country_codes`. Removed in 6.1. */country_isos: Array<string>;- supported_locales: Array<string>;+ supported_locales: Array<LocaleCode>;countries?: Array<Country>;}diff --git a/packages/sdk/src/types/generated/Order.ts b/packages/sdk/src/types/generated/Order.tsindex 3a30e8fc44..d2da7873d1 100644--- a/packages/sdk/src/types/generated/Order.ts+++ b/packages/sdk/src/types/generated/Order.ts@@ -1,7 +1,7 @@-// Typelizer digest 117f1e5d5d744c0d6b8b03ccaa0a8da5+// Typelizer digest c855131d9bf6c80d8c66f4e6191d77a6//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {Payment, AppliedPromotion, Fee, LineItem, Fulfillment, Address, GiftCard, Market, CurrencyCode} from '@/types'+import type {Payment, AppliedPromotion, Fee, LineItem, Fulfillment, Address, GiftCard, Market, CurrencyCode, LocaleCode} from '@/types'interface Order {id: string;@@ -19,7 +19,7 @@ interface Order {customer_note: string | null;po_number: string | null;currency: CurrencyCode;- locale: string | null;+ locale: LocaleCode | null;total_quantity: number;coupon_code: string | null;fulfillment_status: 'backorder' | 'canceled' | 'partial' | 'unfulfilled' | 'fulfilled' | 'delivered' | 'pending' | 'ready' | 'shipped' | null;diff --git a/packages/sdk/src/types/generated/index.ts b/packages/sdk/src/types/generated/index.tsindex 1e948d06e1..6bab01e480 100644--- a/packages/sdk/src/types/generated/index.ts+++ b/packages/sdk/src/types/generated/index.ts@@ -1,7 +1,7 @@-// Typelizer digest af9d744ea87c9a3aa35bc58722115738+// Typelizer digest ae942ced59c0aa34ba85a81e7fe50929//// DO NOT MODIFY: This file was automatically generated by Typelizer.-export type { ClaimStatus, CountryCode, CurrencyCode, DataRequestStatus, ExchangeStatus, FeeKind, FulfillmentStatus, GiftCardStatus, ImportRowStatus, ImportStatus, InvitationStatus, PaymentSessionStatus, PaymentSetupSessionStatus, PaymentStatus, ProductSubmissionStatus, ReturnStatus, ShippingLabelStatus } from './Enums'+export type { ClaimStatus, CountryCode, CurrencyCode, DataRequestStatus, ExchangeStatus, FeeKind, FulfillmentStatus, GiftCardStatus, ImportRowStatus, ImportStatus, InvitationStatus, LocaleCode, PaymentSessionStatus, PaymentSetupSessionStatus, PaymentStatus, ProductSubmissionStatus, ReturnStatus, ShippingLabelStatus } from './Enums'export type { default as Address } from './Address'export type { default as AppliedPromotion } from './AppliedPromotion'export type { default as Base } from './Base'diff --git a/packages/sdk/src/types/params/CreateCartParams.ts b/packages/sdk/src/types/params/CreateCartParams.tsindex 4b5a1e9149..b2fef1b3ee 100644--- a/packages/sdk/src/types/params/CreateCartParams.ts+++ b/packages/sdk/src/types/params/CreateCartParams.ts@@ -3,13 +3,14 @@import type { CartAddressParams } from './CartAddressParams'import type { CurrencyCode } from '../generated'import type { LineItemInputParams } from './LineItemInputParams'+import type { LocaleCode } from '../generated'export type CreateCartParams = {email?: stringcustomer_note?: stringmarket_id?: stringcurrency?: CurrencyCode- locale?: string+ locale?: LocaleCode/** An existing address to ship to. */shipping_address_id?: string/** An existing address to bill. */diff --git a/packages/sdk/src/types/params/UpdateCartParams.ts b/packages/sdk/src/types/params/UpdateCartParams.tsindex b852330755..8e79001b3a 100644--- a/packages/sdk/src/types/params/UpdateCartParams.ts+++ b/packages/sdk/src/types/params/UpdateCartParams.ts@@ -3,13 +3,14 @@import type { CartAddressParams } from './CartAddressParams'import type { CurrencyCode } from '../generated'import type { LineItemInputParams } from './LineItemInputParams'+import type { LocaleCode } from '../generated'export type UpdateCartParams = {email?: stringcustomer_note?: stringmarket_id?: stringcurrency?: CurrencyCode- locale?: string+ locale?: LocaleCode/** An existing address to ship to. */shipping_address_id?: string/** An existing address to bill. */diff --git a/spree/api/app/controllers/spree/api/v3/admin/locales_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/locales_controller.rbindex dce6963f28..dde46f0330 100644--- a/spree/api/app/controllers/spree/api/v3/admin/locales_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/admin/locales_controller.rb@@ -14,7 +14,7 @@ module Spreedef indexrender json: {data: current_store.supported_locales.map do |locale|- Spree.api.locale_serializer.new(locale).to_h+ Spree.api.admin_locale_serializer.new(locale).to_hend}enddiff --git a/spree/api/app/controllers/spree/api/v3/admin/markets_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/markets_controller.rbindex 21211e31e1..c013a79941 100644--- a/spree/api/app/controllers/spree/api/v3/admin/markets_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/admin/markets_controller.rb@@ -22,7 +22,7 @@ module Spreerequired: true, on: :create,example: 'EUR',description: 'ISO 4217 currency code.'- body.attribute :default_locale, :string,+ body.attribute :default_locale, :locale,required: true, on: :create,example: 'de',description: 'Locale used as the market default. Always part of `supported_locales`.'@@ -34,7 +34,7 @@ module Spreebody.attribute :default, :boolean,description: 'Setting true demotes the previous default market of the store.'body.attribute :position, :integer, description: 'Sort order within the store; lower comes first.'- body.attribute :supported_locales, :array, of: :string,+ body.attribute :supported_locales, :array, of: :locale,example: %w[de en],description: 'Locales available in this market. The default locale is always included.'body.attribute :country_codes, :array, of: :country,diff --git a/spree/api/app/controllers/spree/api/v3/admin/orders_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/orders_controller.rbindex 5a074d48b8..b30b10d66e 100644--- a/spree/api/app/controllers/spree/api/v3/admin/orders_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/admin/orders_controller.rb@@ -24,7 +24,7 @@ module Spreebody.attribute :currency, :currency, example: 'USD'body.attribute :market_id, :idbody.attribute :channel_id, :id, description: 'Defaults to the store primary channel when omitted.'- body.attribute :locale, :string, example: 'en-US'+ body.attribute :locale, :locale, example: 'en-US'body.attribute :customer_note, :string, description: 'Public, customer-visible note.'body.attribute :internal_note, :string,description: 'Staff-only note. Rich text HTML; reads come back as this plus `internal_note_html`.'diff --git a/spree/api/app/controllers/spree/api/v3/admin/setup_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/setup_controller.rbindex c59553fdaa..fb7635c0f0 100644--- a/spree/api/app/controllers/spree/api/v3/admin/setup_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/admin/setup_controller.rb@@ -30,7 +30,7 @@ module Spreepermit: false,example: 'US',description: 'ISO 3166-1 alpha-2 country the store sells from. It determines the default market, the warehouse, the delivery zones and the currency.'- body.attribute :locale, :string,+ body.attribute :locale, :locale,permit: false,example: 'en',description: "Storefront locale. Defaults to the country's own language."@@ -78,6 +78,7 @@ module Spreereturn render_setup_unavailable unless setup_token_usable?return render_missing_country if country.nil?return render_unknown_currency if unknown_currency?+ return render_unknown_locale if unknown_locale?user = nilstore = Spree::Store.default@@ -161,6 +162,24 @@ module Spree)end+ # Blank means "use the country's own language"; another spelling or a+ # region Spree does not list moves to the listed locale, but a code+ # Spree cannot place at all is refused before the token is spent.+ def unknown_locale?+ params[:locale].present? && Spree::Locales.listed(params[:locale]).nil?+ end++ def render_unknown_locale+ message = "Unknown locale #{params[:locale]}"++ render_error(+ code: ERROR_CODES[:validation_error],+ message: message,+ status: :unprocessable_content,+ details: { locale: [message] }+ )+ end+def country_payload(country){code: country.iso,@@ -170,17 +189,12 @@ module Spree}end- # A country's official languages, minus any Spree has no translations- # for — Switzerland speaks Romansh and Spree does not, so offering it- # would point a storefront at a language with nothing behind it.- # English closes the gap for countries whose languages all fall- # through, and is always offered alongside.+ # A country's official languages, as the locales Spree lists for them+ # (Switzerland gives de, fr, it and rm) — content locales, whether+ # or not Spree ships translations, since the storefront and dashboard+ # carry their own. English stands in for a country with none listed.def offerable_locales(country)- country.official_locales.filter_map { |language| Spree.locale_for_language(language, available_locales) }.presence || ['en']- end-- def available_locales- @available_locales ||= Spree.available_locales+ country.official_locales.filter_map { |language| Spree::Locales.for_language(language) }.uniq.presence || ['en']end# Token mismatch, spent token, and already-set-up all render thediff --git a/spree/api/app/controllers/spree/api/v3/store/carts_controller.rb b/spree/api/app/controllers/spree/api/v3/store/carts_controller.rbindex 9e19e93ed2..0abac10b98 100644--- a/spree/api/app/controllers/spree/api/v3/store/carts_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/store/carts_controller.rb@@ -25,7 +25,7 @@ module Spreeschema.attribute :customer_note, :string, example: 'Leave at door'schema.attribute :market_id, :idschema.attribute :currency, :currency- schema.attribute :locale, :string+ schema.attribute :locale, :localeschema.attribute :shipping_address_id, :id,description: 'An existing address to ship to.',example: 'addr_abc123'diff --git a/spree/api/app/serializers/spree/api/v3/admin/locale_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/locale_serializer.rbnew file mode 100644index 0000000000..36b2c127ed--- /dev/null+++ b/spree/api/app/serializers/spree/api/v3/admin/locale_serializer.rb@@ -0,0 +1,13 @@+module Spree+ module Api+ module V3+ module Admin+ # The dashboard names locales with Intl.DisplayNames in the admin's+ # own language, so the Admin API sends the code alone.+ class LocaleSerializer < V3::LocaleSerializer+ _attributes.delete(:name)+ end+ end+ end+ end+enddiff --git a/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rbindex 5912eca23d..d38adf0ec1 100644--- a/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb@@ -4,11 +4,11 @@ module Spreemodule Adminclass StoreSerializer < V3::BaseSerializertypelize name: :string, url: :string, code: :string, api_url: :string,- default_currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'], default_locale: :string,+ default_currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'], default_locale: [:string, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],default_country_code: [:string, nullable: true],supported_currencies: [:string, multi: true, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],- supported_locales: [:string, multi: true],- available_locales: [:string, multi: true],+ supported_locales: [:string, multi: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],+ available_locales: [:string, multi: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],logo_url: [:string, nullable: true],mailer_logo_url: [:string, nullable: true],mail_from_address: [:string, nullable: true],diff --git a/spree/api/app/serializers/spree/api/v3/cart_serializer.rb b/spree/api/app/serializers/spree/api/v3/cart_serializer.rbindex 2c8366fcd2..11176d3a9d 100644--- a/spree/api/app/serializers/spree/api/v3/cart_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/cart_serializer.rb@@ -7,7 +7,7 @@ module Spreetypelize number: [:string, deprecated: 'Use `id`; a cart has no order number. Removed in 6.1.'], current_step: :string, completed_steps: 'string[]', token: :string,email: [:string, nullable: true], customer_note: [:string, nullable: true],market_id: [:string, nullable: true], channel_id: [:string, nullable: true], currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],- locale: [:string, nullable: true], total_quantity: :number, coupon_code: [:string, nullable: true],+ locale: [:string, nullable: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'], total_quantity: :number, coupon_code: [:string, nullable: true],preferred_stock_location_id: [:string, nullable: true], company_id: [:string, nullable: true],company_name: [:string, nullable: true], po_number: [:string, nullable: true],po_number_required: :boolean, po_document_filename: [:string, nullable: true],diff --git a/spree/api/app/serializers/spree/api/v3/locale_serializer.rb b/spree/api/app/serializers/spree/api/v3/locale_serializer.rbindex 3fcaf442cf..6b731dc62b 100644--- a/spree/api/app/serializers/spree/api/v3/locale_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/locale_serializer.rb@@ -7,7 +7,9 @@ module Spreeinclude Alba::Resourceinclude Typelizer::DSL- typelize code: :string, name: :string, default: :boolean, rtl: :boolean+ typelize code: [:string, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],+ name: [:string, deprecated: 'Name the locale from `code` with `Intl.DisplayNames`. Removed in 6.1.'],+ default: :boolean, rtl: :booleanattributes :code, :namediff --git a/spree/api/app/serializers/spree/api/v3/market_serializer.rb b/spree/api/app/serializers/spree/api/v3/market_serializer.rbindex ed7f432063..10dfef5941 100644--- a/spree/api/app/serializers/spree/api/v3/market_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/market_serializer.rb@@ -3,8 +3,8 @@ module Spreemodule V3class MarketSerializer < BaseSerializertypelize name: :string, currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],- default_locale: :string,- supported_locales: [:string, multi: true],+ default_locale: [:string, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],+ supported_locales: [:string, multi: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],country_codes: [:string, multi: true, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],country_isos: [:string, multi: true, deprecated: 'Use `country_codes`. Removed in 6.1.'],tax_inclusive: :boolean,diff --git a/spree/api/app/serializers/spree/api/v3/order_serializer.rb b/spree/api/app/serializers/spree/api/v3/order_serializer.rbindex db221a0bfc..97fcc9e152 100644--- a/spree/api/app/serializers/spree/api/v3/order_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/order_serializer.rb@@ -9,7 +9,7 @@ module Spreechannel_id: [:string, nullable: true], company_id: [:string, nullable: true],company_name: [:string, nullable: true], po_number: [:string, nullable: true],po_document_filename: [:string, nullable: true], po_document_byte_size: ['number | null'],- currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'], locale: [:string, nullable: true], total_quantity: :number,+ currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'], locale: [:string, nullable: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'], total_quantity: :number,coupon_code: [:string, nullable: true],fulfillment_status: [:string, nullable: true, enum: Spree::Order::FULFILLMENT_STATUSES],payment_status: [:string, nullable: true, enum: Spree::Order::PAYMENT_STATUSES],diff --git a/spree/api/app/services/spree/api/v3/request_schema.rb b/spree/api/app/services/spree/api/v3/request_schema.rbindex b59d35f84a..86b7b00b81 100644--- a/spree/api/app/services/spree/api/v3/request_schema.rb+++ b/spree/api/app/services/spree/api/v3/request_schema.rb@@ -42,7 +42,8 @@ module Spreeany: {},# ISO codes, from the closed lists below.country: { type: :string },- currency: { type: :string }+ currency: { type: :string },+ locale: { type: :string }}.freeze# The ISO lists a `country` or `currency` field takes, published once@@ -51,7 +52,8 @@ module Spree# a response is the type a request takes.CODE_LISTS = {country: ['CountryCode', -> { Spree::IsoData.country_codes }],- currency: ['CurrencyCode', -> { Spree::Money::Rounding::CURRENCY_CODES }]+ currency: ['CurrencyCode', -> { Spree::Money::Rounding::CURRENCY_CODES }],+ locale: ['LocaleCode', -> { Spree::Locales::ALL }]}.freezeACTIONS = %i[create update].freezediff --git a/spree/api/lib/spree/api/dependencies.rb b/spree/api/lib/spree/api/dependencies.rbindex 7f9e6375b5..649e9ba89c 100644--- a/spree/api/lib/spree/api/dependencies.rb+++ b/spree/api/lib/spree/api/dependencies.rb@@ -21,7 +21,7 @@ module Spreestock_transfer company company_membership company_invitation seller file_upload file_upload_target].freezeADMIN_SERIALIZERS =- %i[country state applied_promotion discount tax_line cart delivery_zone delivery_profile+ %i[country state locale applied_promotion discount tax_line cart delivery_zone delivery_profiledelivery_origin_group integration delivery_method_rule delivery_zone_member fee consent_record customerdata_request newsletter_subscriber order order_group product product_typeproduct_type_custom_field_definition variant price price_history custom_field custom_field_definitiondiff --git a/spree/api/lib/typelizer/open_enums.rb b/spree/api/lib/typelizer/open_enums.rbindex a58b6155c0..d90d410da9 100644--- a/spree/api/lib/typelizer/open_enums.rb+++ b/spree/api/lib/typelizer/open_enums.rb@@ -10,9 +10,10 @@ module Typelizer## ISO lists are the exception: a named type several serializers and the# request types share, but closed, since nothing outside the standard can- # add a country or a currency.+ # add a country or a currency, and markets only accept the locales+ # `Spree::Locales::ALL` lists.module OpenEnums- CLOSED_TYPE_NAMES = %w[CountryCode CurrencyCode].freeze+ CLOSED_TYPE_NAMES = %w[CountryCode CurrencyCode LocaleCode].freezemodule Propertydef enum_definition(...)diff --git a/spree/api/spec/controllers/spree/api/v3/admin/setup_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/setup_controller_spec.rbindex 0a6c33f543..93bdb9e87d 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/setup_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/setup_controller_spec.rb@@ -46,29 +46,15 @@ RSpec.describe Spree::Api::V3::Admin::SetupController, type: :controller doexpect(china['locales']).to eq(['zh-CN'])end- context "when only some of a country's languages are translated" do- before do- allow(Spree).to receive(:available_locales).and_return(%i[en de fr it pl])- end-- # Offering a language Spree has no translations for would point a- # storefront at nothing — Switzerland speaks Romansh, Spree does not.- it 'drops languages that have no translations' do- get :countries, as: :json-- switzerland = json_response['countries'].find { |country| country['code'] == 'CH' }-- expect(switzerland['locales']).to contain_exactly('de', 'fr', 'it')- end-- it "falls back to English when none of a country's languages ship" do- get :countries, as: :json+ # A store's locale is a content locale: the storefront and dashboard ship+ # their own translations, so a language Spree has no strings for is+ # still offered. Switzerland speaks Romansh, which Spree does not translate.+ it "offers every official language, whether or not Spree translates it" do+ get :countries, as: :json- # Eritrea speaks Tigrinya, which Spree does not translate.- eritrea = json_response['countries'].find { |country| country['code'] == 'ER' }+ switzerland = json_response['countries'].find { |country| country['code'] == 'CH' }- expect(eritrea['locales']).to eq(['en'])- end+ expect(switzerland['locales']).to contain_exactly('de', 'fr', 'it', 'rm')end# Same posture as the rest of the flow: it exists only while the@@ -192,6 +178,14 @@ RSpec.describe Spree::Api::V3::Admin::SetupController, type: :controller doexpect(Spree.admin_user_class.count).to eq(0)end+ it 'refuses a locale Spree cannot place and leaves the token usable' do+ post :create, params: valid_params.merge(locale: 'english'), as: :json++ expect(response).to have_http_status(:unprocessable_content)+ expect(json_response.dig('error', 'details', 'locale')).to be_present+ expect(@default_store.reload.setup_token).to be_present+ end+it "defaults the currency to the country's own when none is given" dopost :create, params: valid_params.merge(country_code: 'DE'), as: :jsondiff --git a/spree/core/app/mailers/spree/base_mailer.rb b/spree/core/app/mailers/spree/base_mailer.rbindex 54916dbbdf..150a053986 100644--- a/spree/core/app/mailers/spree/base_mailer.rb+++ b/spree/core/app/mailers/spree/base_mailer.rb@@ -72,10 +72,11 @@ module Spree# Locale for an email to a staff member or seller: their own dashboard# language, then the store's admin locale, then nil — which lets- # with_store_locale fall back to the store's default. Blank or unavailable- # values fall through.+ # with_store_locale fall back to the store's default. Blank values, and+ # languages Spree ships no translations for, fall through.def staff_locale(user, store)- [user.try(:selected_locale), store&.preferred_admin_locale].find { |locale| I18n.locale_available?(locale) }+ shipped = Spree.available_locales.map(&:to_s)+ [user.try(:selected_locale), store&.preferred_admin_locale].find { |locale| shipped.include?(locale.to_s) }end# Renders the current action's email from its Liquid template and buildsdiff --git a/spree/core/app/models/concerns/spree/stores/markets.rb b/spree/core/app/models/concerns/spree/stores/markets.rbindex 5b3af1944e..01964579b9 100644--- a/spree/core/app/models/concerns/spree/stores/markets.rb+++ b/spree/core/app/models/concerns/spree/stores/markets.rb@@ -7,6 +7,9 @@ module Spreehas_many :markets, class_name: 'Spree::Market', dependent: :destroyhas_one :default_market, -> { default }, class_name: 'Spree::Market'+ normalizes :default_locale, with: ->(value) { value.to_s.strip.presence }+ validates_with Spree::LocaleCodesValidator, attributes: %i[default_locale supported_locales]+after_create :ensure_default_marketafter_update :sync_default_market_settingsend@@ -145,7 +148,7 @@ module Spreemarkets.create!(name: country.name,currency: read_attribute(:default_currency) || iso_country&.currency_code || 'USD',- default_locale: read_attribute(:default_locale) || iso_country&.languages_official&.first || 'en',+ default_locale: read_attribute(:default_locale) || Spree::Locales.listed(iso_country&.languages_official&.first) || 'en',supported_locales: read_attribute(:supported_locales),default: true,bootstrap_default: true,@@ -190,7 +193,7 @@ module Spreeenddef legacy_supported_locales_list- (read_attribute(:supported_locales).to_s.split(',') << default_locale).compact.uniq.sort+ (read_attribute(:supported_locales).to_s.split(',').map(&:strip) << default_locale).compact_blank.uniq.sortendendenddiff --git a/spree/core/app/models/spree/market.rb b/spree/core/app/models/spree/market.rbindex bc0e90884a..1650f3e889 100644--- a/spree/core/app/models/spree/market.rb+++ b/spree/core/app/models/spree/market.rb@@ -77,7 +77,9 @@ module Spreeinclusion: { in: ->(_market) { Spree.tax_providers.map(&:to_s) } },allow_blank: truevalidates :currency, presence: true+ normalizes :default_locale, with: ->(value) { value.to_s.strip.presence }validates :default_locale, presence: true+ validates_with Spree::LocaleCodesValidator, attributes: %i[default_locale supported_locales]validates :countries, presence: true#@@ -145,7 +147,7 @@ module Spree## @return [Array<String>]def supported_locales_list- @supported_locales_list ||= (supported_locales.to_s.split(',').map(&:strip) << default_locale).compact.uniq.sort+ @supported_locales_list ||= (supported_locales.to_s.split(',').map(&:strip) << default_locale).compact_blank.uniq.sortend# Accepts an Array of locale codes and persists them as a comma-separated@@ -156,7 +158,7 @@ module Spree# @param value [Array<String>, String, nil]def supported_locales=(value)@supported_locales_list = nil- normalized = value.is_a?(Array) ? value.compact.uniq.reject(&:blank?).join(',') : value+ normalized = value.is_a?(Array) ? value.map { |code| code.to_s.strip }.reject(&:empty?).uniq.join(',') : valuesuper(normalized)enddiff --git a/spree/core/app/services/spree/locales.rb b/spree/core/app/services/spree/locales.rbindex a4b0bb2655..a4c1b94448 100644--- a/spree/core/app/services/spree/locales.rb+++ b/spree/core/app/services/spree/locales.rb@@ -16,15 +16,15 @@ module Spree# English, Brazilian vs. European Portuguese, Simplified vs. Traditional# Chinese, etc.).#- # The underlying translation tables accept any locale string, so this list- # governs only what the locale pickers offer — it is not a hard storage- # constraint.+ # Markets and stores only accept codes from this list when their locales+ # change, so an order's or cart's locale (which must be one its store+ # supports) is one too, unless the store kept a value saved before that.ALL = %w[aa ab ae af ak am an ar as av ay azba be bg bh bi bm bn bo br bsca ce ch co cr cs cu cv cyda de de-AT de-CH dv dz- ee el en en-AU en-CA en-GB en-IN en-NZ eo es es-419 es-MX et eu+ ee el en en-AU en-CA en-GB en-IN en-NZ en-US eo es es-419 es-CL es-EC es-MX et eufa ff fi fj fo fr fr-CA fyga gd gl gn gu gvha he hi ho hr ht hu hy hz@@ -38,7 +38,7 @@ module Spreepa pi pl ps pt pt-BR pt-PTqurm rn ro ru rw- sa sc sd se sg si sk sl sm sn so sq sr ss st su sv sw+ sa sc sd se sg si sk sl sl-SI sm sn so sq sr ss st su sv swta te tg th ti tk tl tn to tr ts tt tw tyug uk ur uzve vi vo@@ -47,5 +47,39 @@ module Spreeyi yoza zh-CN zh-HK zh-TW zu].freeze++ # The codes in a comma-separated list that are not listed, for a+ # validation to name.+ #+ # @param codes [String, nil] e.g. "en,pt-BR"+ # @return [Array<String>]+ def self.unlisted(codes)+ codes.to_s.split(',').map(&:strip).reject(&:empty?) - ALL+ end++ # A listed locale for a code from elsewhere (a host app's I18n config, a+ # country's official language, a legacy column): the listed spelling of+ # the code itself (`en_US` and `pt-br` give `en-US` and `pt-BR`),+ # otherwise the listed one for its language (`en-IE` gives `en`, `zh`+ # gives `zh-CN`), or nil when Spree knows neither.+ #+ # @param code [String, Symbol, nil]+ # @return [String, nil]+ def self.listed(code)+ code = code.to_s.strip.tr('_', '-')+ return if code.empty?++ ALL.find { |listed| listed.casecmp?(code) } || for_language(code.split('-').first)+ end++ # The listed locale for an ISO 639-1 language: the language itself, or+ # its first regional variant when only those are listed (`zh` gives+ # `zh-CN`).+ #+ # @param language [String]+ # @return [String, nil]+ def self.for_language(language)+ Spree.locale_for_language(language.to_s.downcase, ALL)+ endendenddiff --git a/spree/core/app/services/spree/seeds/stores.rb b/spree/core/app/services/spree/seeds/stores.rbindex e59e4ae760..d956d8881e 100644--- a/spree/core/app/services/spree/seeds/stores.rb+++ b/spree/core/app/services/spree/seeds/stores.rb@@ -14,7 +14,7 @@ module Sprees.customer_support_email = '[email protected]'s.default_currency = 'USD's.default_country_code = 'US'- s.default_locale = I18n.locale+ s.default_locale = Spree::Locales.listed(I18n.locale) || 'en'end.save!endenddiff --git a/spree/core/app/services/spree/stores/provision_defaults.rb b/spree/core/app/services/spree/stores/provision_defaults.rbindex 14a0fe2775..851500163c 100644--- a/spree/core/app/services/spree/stores/provision_defaults.rb+++ b/spree/core/app/services/spree/stores/provision_defaults.rb@@ -18,8 +18,9 @@ module Spree# @param store [Spree::Store] the store to provision, already persisted# @param country [Spree::Country] where the shop ships from- # @param locale [String, nil] storefront locale; defaults to the- # country's own language when Spree translates it, then English+ # @param locale [String, nil] storefront locale, a code from+ # `Spree::Locales::ALL` (another spelling or region moves to the listed+ # one); defaults to the country's own language, then English# @param currency [String, nil] ISO 4217 code; defaults to the country's# own currency. Merchants who ship from one country and price in# another currency pass it explicitly.@@ -55,21 +56,17 @@ module Spreefound&.iso_code || country.default_currency.presence || 'USD'end- # An explicit locale is honored as given — a host app may ship its own- # translations. Only the *derived* default is filtered: falling back to- # a country's official language that Spree has no strings for would set- # a storefront to a language with nothing behind it, and it is not one- # the setup screen ever offers.+ # A store's locale is a content locale, so it comes from+ # `Spree::Locales::ALL` whether or not Spree ships translations for it:+ # the storefront and dashboard carry their own. An explicit locale is+ # kept when it is listed, or moved to its listed language (`en-IE`+ # becomes `en`); one Spree cannot place, or none, gives the country's+ # first official language Spree lists.def resolve_locale(requested, country)- return requested if requested.present?+ listed = Spree::Locales.listed(requested)+ return listed if listed- derived = country.default_locale.presence- return 'en' if derived.blank?-- locales = Spree.available_locales- Spree.locale_for_language(derived, locales) ||- country.official_locales.lazy.filter_map { |language| Spree.locale_for_language(language, locales) }.first ||- 'en'+ [country.default_locale, *country.official_locales].lazy.filter_map { |language| Spree::Locales.for_language(language) }.first || 'en'end# The store's own country/currency/locale columns are not the source ofdiff --git a/spree/core/app/validators/spree/locale_codes_validator.rb b/spree/core/app/validators/spree/locale_codes_validator.rbnew file mode 100644index 0000000000..35cacdc183--- /dev/null+++ b/spree/core/app/validators/spree/locale_codes_validator.rb@@ -0,0 +1,22 @@+module Spree+ # Rejects locale codes `Spree::Locales::ALL` does not list, in a single code+ # or a comma-separated list, naming the ones it refuses. Reads the stored+ # column, since a store answers `default_locale` from its default market,+ # and checks only an attribute that is changing, so a record saved before+ # the list was enforced can still be edited.+ #+ # @example+ # validates_with Spree::LocaleCodesValidator, attributes: %i[default_locale supported_locales]+ class LocaleCodesValidator < ActiveModel::Validator+ def validate(record)+ Array(options[:attributes]).each do |attribute|+ next unless record.will_save_change_to_attribute?(attribute)++ unlisted = Spree::Locales.unlisted(record.read_attribute(attribute))+ next if unlisted.empty?++ record.errors.add(attribute, I18n.t('spree.locales_not_listed', codes: unlisted.join(', ')))+ end+ end+ end+enddiff --git a/spree/core/config/locales/content_locales.rb b/spree/core/config/locales/content_locales.rbnew file mode 100644index 0000000000..9c6a45e69e--- /dev/null+++ b/spree/core/config/locales/content_locales.rb@@ -0,0 +1,9 @@+# A store's content locales are the codes Spree::Locales::ALL lists,+# independent of the languages anything has translation files for. An API+# request sets I18n.locale (and so Mobility's) to its content locale, and both+# refuse a locale I18n does not know, so this registers every listed code:+# content can be stored and read in, say, Yoruba, while messages in it fall+# back along the i18n fallback chain. The backend ignores a locale with no+# keys at all, hence the one marker key. An app that limits+# `config.i18n.available_locales` keeps its own list.+Spree::Locales::ALL.to_h { |code| [code.to_sym, { spree_content_locale: true }] }diff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.ymlindex 85a53370a8..2dd06e6541 100644--- a/spree/core/config/locales/en.yml+++ b/spree/core/config/locales/en.yml@@ -1005,6 +1005,7 @@ en:link: Linklocale: Localelocale_not_supported_by_store: is not supported by this store+ locales_not_listed: 'includes locales Spree does not support: %{codes}'manual: Manualmarket: Marketme_no_current_user: No admin user authenticated this requestdiff --git a/spree/core/lib/spree/core/preferences/json_conversion.rb b/spree/core/lib/spree/core/preferences/json_conversion.rbindex a344a20575..5474d63f4d 100644--- a/spree/core/lib/spree/core/preferences/json_conversion.rb+++ b/spree/core/lib/spree/core/preferences/json_conversion.rb@@ -60,8 +60,12 @@ module Spree# @return [Array<String>]def preference_tablesRails.application.eager_load! if defined?(Rails.application) && Rails.application+ # An anonymous class (a spec's throwaway model) has no name to derive a+ # table from, and asking raises, so it is skipped.owned = ActiveRecord::Base.descendants.filter_map do |model|- model.table_name if !model.abstract_class? && model.include?(Spree::Preferences::Preferable) && model.table_name+ next if model.name.nil? || model.abstract_class? || !model.include?(Spree::Preferences::Preferable)++ model.table_nameendconnection.tables.select { |table| owned.include?(table) && connection.column_exists?(table, :preferences) }.sortdiff --git a/spree/core/lib/tasks/markets.rake b/spree/core/lib/tasks/markets.rakeindex ab1b4006aa..076f129a89 100644--- a/spree/core/lib/tasks/markets.rake+++ b/spree/core/lib/tasks/markets.rake@@ -31,7 +31,8 @@ namespace :spree domarket = store.markets.create!(name: primary_country&.name || 'Default',currency: iso_country&.currency_code || store.read_attribute(:default_currency) || 'USD',- default_locale: iso_country&.languages_official&.first || store.read_attribute(:default_locale) || 'en',+ default_locale: Spree::Locales.listed(iso_country&.languages_official&.first) ||+ Spree::Locales.listed(store.read_attribute(:default_locale)) || 'en',default: true,countries: countries)diff --git a/spree/core/spec/lib/tasks/preferences_json_spec.rb b/spree/core/spec/lib/tasks/preferences_json_spec.rbindex d1f1b8b148..010152512c 100644--- a/spree/core/spec/lib/tasks/preferences_json_spec.rb+++ b/spree/core/spec/lib/tasks/preferences_json_spec.rb@@ -106,6 +106,12 @@ describe 'preferences stored as JSON' doexpect(conversion.preference_tables).not_to include(table_name)end+ it 'skips an anonymous model, which has no table to name' do+ Class.new(Spree.base_class)++ expect(conversion.preference_tables).to include('spree_payment_methods')+ end+it 'stops on a row it cannot read, naming the table and row' doid = insert_row("--- !ruby/hash-with-ivars:ActionController::Parameters\nelements: {}\n")diff --git a/spree/core/spec/models/spree/market_spec.rb b/spree/core/spec/models/spree/market_spec.rbindex ff873f392b..6f8ee1bdf2 100644--- a/spree/core/spec/models/spree/market_spec.rb+++ b/spree/core/spec/models/spree/market_spec.rb@@ -51,6 +51,11 @@ RSpec.describe Spree::Market, type: :model doenddescribe '#supported_locales_list' do+ it 'ignores blank entries in a comma-separated value' do+ market = build(:market, default_locale: 'en', supported_locales: ' , fr, ')+ expect(market.supported_locales_list).to eq(%w[en fr])+ end+it 'returns default_locale when supported_locales is blank' domarket = build(:market, default_locale: 'en', supported_locales: nil)expect(market.supported_locales_list).to eq(['en'])@@ -100,6 +105,45 @@ RSpec.describe Spree::Market, type: :model doendend+ describe 'locale validation' do+ let(:market) { build(:market, store: store) }++ it 'accepts listed locales' do+ market.default_locale = 'pt-BR'+ market.supported_locales = %w[en-US zh-TW]++ expect(market).to be_valid+ end++ it 'strips spaces from the default locale and each supported locale' do+ market.default_locale = ' de '+ market.supported_locales = [' fr', 'en ']++ expect([market.default_locale, market.read_attribute(:supported_locales)]).to eq(%w[de fr,en])+ end++ it 'rejects a default locale that is not listed, including one listed in another case' do+ market.default_locale = 'pt-br'++ expect(market).not_to be_valid+ expect(market.errors[:default_locale]).to be_present+ end++ it 'rejects supported locales that are not listed, naming them' do+ market.supported_locales = %w[fr xx yy]++ expect(market).not_to be_valid+ expect(market.errors.full_messages.join).to include('xx, yy')+ end++ it 'still saves a market whose stored locale predates the list when the locale does not change' do+ market.save!+ market.update_columns(default_locale: 'legacy', supported_locales: 'legacy')++ expect(market.reload.update(name: 'Renamed')).to be(true)+ end+ end+describe '#country_codes' doit 'returns the sorted ISO codes for assigned countries' dode = create(:country, iso: 'DE', name: 'Germany')diff --git a/spree/core/spec/models/spree/store_spec.rb b/spree/core/spec/models/spree/store_spec.rbindex 349e45fced..ac37b50f11 100644--- a/spree/core/spec/models/spree/store_spec.rb+++ b/spree/core/spec/models/spree/store_spec.rb@@ -583,6 +583,19 @@ describe Spree::Store, type: :model, without_global_store: true doendend+ describe 'locale validation' do+ it 'accepts listed locales' do+ expect(build(:store, default_locale: 'en-US', supported_locales: 'pt-BR,de')).to be_valid+ end++ it 'rejects locales that are not listed' do+ store = build(:store, default_locale: 'english', supported_locales: 'fr,xx')++ expect(store).not_to be_valid+ expect(store.errors.attribute_names).to include(:default_locale, :supported_locales)+ end+ end+describe '#supported_locales_list' docontext 'with markets' dolet!(:store) { create(:store, default_locale: 'en') }diff --git a/spree/core/spec/services/spree/locales_spec.rb b/spree/core/spec/services/spree/locales_spec.rbindex d6a0164d57..1e8fc61174 100644--- a/spree/core/spec/services/spree/locales_spec.rb+++ b/spree/core/spec/services/spree/locales_spec.rb@@ -18,5 +18,45 @@ RSpec.describe Spree::Locales doit 'has no duplicate codes' doexpect(subject).to eq(subject.uniq)end++ it 'is accepted by I18n and Mobility even without translation files, falling back to English for messages' do+ I18n.with_locale(:yo) do+ Mobility.with_locale(:yo) { expect(I18n.t('spree.locale')).to eq('Locale') }+ end+ end++ it "includes every locale Spree ships translations for, so the setup wizard's suggestions are valid" do+ expect(Spree::SHIPPED_LOCALES.map(&:to_s) - subject).to eq([])+ end+ end++ describe '.unlisted' do+ it 'names the codes of a comma-separated list that are not listed, matching case exactly' do+ expect([described_class.unlisted('en,pt-br,xx'), described_class.unlisted(nil)]).to eq([%w[pt-br xx], []])+ end++ it 'ignores spaces and empty entries' do+ expect(described_class.unlisted('en, de,,fr ')).to eq([])+ end+ end++ describe '.listed' do+ it 'keeps a listed code and moves another to its listed language' do+ expect(%w[pt-BR en-IE zh].map { |code| described_class.listed(code) }).to eq(%w[pt-BR en zh-CN])+ end++ it 'finds a listed code written with an underscore or in another case' do+ expect(%w[en_US pt-br PT_BR].map { |code| described_class.listed(code) }).to eq(%w[en-US pt-BR pt-BR])+ end++ it 'gives nothing for a language Spree does not know, or a blank code' do+ expect([described_class.listed('xx-YY'), described_class.listed(nil)]).to eq([nil, nil])+ end+ end++ describe '.for_language' do+ it 'picks the language, or its first regional variant when only those are listed' do+ expect([described_class.for_language('de'), described_class.for_language('zh'), described_class.for_language('xx')]).to eq(['de', 'zh-CN', nil])+ endendenddiff --git a/spree/core/spec/services/spree/stores/provision_defaults_spec.rb b/spree/core/spec/services/spree/stores/provision_defaults_spec.rbindex 7fdb1d031f..ff6359f64e 100644--- a/spree/core/spec/services/spree/stores/provision_defaults_spec.rb+++ b/spree/core/spec/services/spree/stores/provision_defaults_spec.rb@@ -196,6 +196,26 @@ RSpec.describe Spree::Stores::ProvisionDefaults doendend+ context 'when the given locale is not one Spree lists' do+ let(:locale) { 'de-LU' }++ it 'uses its listed language, since a market accepts nothing else' do+ subject++ expect(store.reload.default_market.default_locale).to eq('de')+ end+ end++ context 'when the given locale is one Spree cannot place' do+ let(:locale) { 'xx' }++ it "uses the country's own language" do+ subject++ expect(store.reload.default_market.default_locale).to eq('de')+ end+ end+# Shipping from one country and pricing in another currency is ordinary —# a Polish merchant selling to the eurozone, say.context 'when a currency is given explicitly' do@@ -215,19 +235,16 @@ RSpec.describe Spree::Stores::ProvisionDefaults doendend- # The setup screen only ever offers languages Spree translates, so a- # derived default must land in the same set — otherwise an API client- # omitting `locale` gets a storefront language with no strings behind it.- context "when the country's own language has no translations" do+ # A store's locale is a content locale, so Spree's own translation files+ # do not limit it: the storefront and dashboard carry their own.+ context "when Spree ships no translations for the country's language" dolet(:locale) { nil }let(:country) { Spree::Country.by_iso('AL') } # Albania → Albanian- before { allow(Spree).to receive(:available_locales).and_return(%i[en de fr]) }-- it 'falls back to English rather than the untranslated language' do+ it 'still uses that language' dosubject- expect(store.reload.default_market.default_locale).to eq('en')+ expect(store.reload.default_market.default_locale).to eq('sq')endit 'still honors a locale the caller asked for outright' do