22 {
33 id: The key for this language
44 title: The title as it will be labeled in Sanity studio
5- iso: Iso version of the language, used by Next.js localisation and react-intl
6- name: Name as used in the Sanity localisation feature (this one is hard to explain :sweat_smile:)
7- locale: The actual locale name as used by Next.js and locale folders/structure ([site]/locale)
5+ iso: ISO locale code (e.g., "en-GB"), used for document lang field and Next.js routing
6+ locale: Two-letter locale code (e.g., "en"), used for URL routing and next-intl config
87 }
98*/
109export type Language = {
1110 id : string
1211 title : string
1312 iso : string
14- name : string
1513 locale : string
1614}
1715const languages = [
1816 {
1917 id : 'english' ,
2018 title : 'English (UK)' ,
2119 iso : 'en-GB' ,
22- name : 'en_GB' ,
2320 locale : 'en' ,
2421 } ,
2522 {
2623 id : 'norwegian' ,
2724 title : 'Norwegian' ,
2825 iso : 'nb-NO' ,
29- name : 'nb_NO' ,
3026 locale : 'no' ,
3127 } ,
3228 {
3329 id : 'portuguese' ,
3430 title : 'Portuguese (BR)' ,
3531 iso : 'pt-BR' ,
36- name : 'pt_BR' ,
3732 locale : 'pt' ,
3833 } ,
39- { id : 'german' , title : 'German' , iso : 'de-DE' , name : 'de_DE' , locale : 'de' } ,
34+ { id : 'german' , title : 'German' , iso : 'de-DE' , locale : 'de' } ,
4035 {
4136 id : 'spanish-ar' ,
4237 title : 'Spanish' ,
4338 iso : 'es-AR' ,
44- name : 'es_AR' ,
4539 locale : 'es' ,
4640 } ,
47- { id : 'polish' , title : 'Polish' , iso : 'pl-PL' , name : 'pl_PL' , locale : 'pl' } ,
41+ { id : 'polish' , title : 'Polish' , iso : 'pl-PL' , locale : 'pl' } ,
4842 {
4943 id : 'japanese' ,
5044 title : 'Japanese' ,
5145 iso : 'ja-JP' ,
52- name : 'ja_JP' ,
5346 locale : 'ja' ,
5447 } ,
55- { id : 'korean' , title : 'Korean' , iso : 'ko-KR' , name : 'ko_KR' , locale : 'ko' } ,
56- { id : 'welsh' , title : 'Welsh' , iso : 'cy-CY' , name : 'cy_CY' , locale : 'cy' } ,
48+ { id : 'korean' , title : 'Korean' , iso : 'ko-KR' , locale : 'ko' } ,
49+ { id : 'welsh' , title : 'Welsh' , iso : 'cy-CY' , locale : 'cy' } ,
5750]
5851
5952/**
6053 * @type {Record<string, string> }
6154 */
6255export const newsSlug : Record < string , string > = {
63- en_GB : 'news' ,
64- nb_NO : 'nyheter' ,
65- pt_BR : 'noticias' ,
66- pl_PL : 'aktualnosci' ,
67- de_DE : 'aktuelles' ,
68- ja_JP : 'news' ,
69- ko_KR : 'news' ,
70- cy_CY : 'newyddion' ,
56+ 'en-GB' : 'news' ,
57+ 'nb-NO' : 'nyheter' ,
58+ 'pt-BR' : 'noticias' ,
59+ 'pl-PL' : 'aktualnosci' ,
60+ 'de-DE' : 'aktuelles' ,
61+ 'ja-JP' : 'news' ,
62+ 'ko-KR' : 'news' ,
63+ 'cy-CY' : 'newyddion' ,
7164}
7265
7366/**
7467 * @type {Record<string, string> }
7568 */
7669export const magazineSlug : Record < string , string > = {
77- en_GB : 'magazine' ,
78- nb_NO : 'magasin' ,
70+ 'en-GB' : 'magazine' ,
71+ 'nb-NO' : 'magasin' ,
7972}
8073
8174/*
@@ -187,9 +180,7 @@ const websiteDomains: Partial<
187180/**
188181 * @returns {{
189182 * id: string
190- * title: string
191183 * iso: string
192- * name: string
193184 * locale: string
194185 * }[] }
195186 */
@@ -206,7 +197,7 @@ const logAndFallback = (dataset: DatasetsKeys) => {
206197}
207198
208199export const localNewsTags : Record < string , string [ ] > = {
209- en_GB : [ 'ev' , 'uk' , 'us' ] ,
200+ 'en-GB' : [ 'ev' , 'uk' , 'us' ] ,
210201}
211202
212203/**
@@ -234,3 +225,9 @@ export const getAllDomainUrls = () => {
234225 return Object . values ( websiteDomains ) . map ( dataset => dataset . url )
235226 //return Object.keys(datasets).map((dataset) => websiteDomains[dataset]?.url)
236227}
228+
229+ /**
230+ * Converts ISO locale code to Sanity schema field name format
231+ * Example: "en-GB" → "en_GB", "nb-NO" → "nb_NO"
232+ */
233+ export const isoToSchemaName = ( iso : string ) : string => iso . replace ( '-' , '_' )
0 commit comments