File tree Expand file tree Collapse file tree 4 files changed +11
-3
lines changed
teleport-project-generator-next/src/internationalization
teleport-uidl-validator/src/decoders Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -120,14 +120,18 @@ export class NextProjectPlugini18nConfig implements ProjectPlugin {
120
120
async runAfter ( structure : ProjectPluginStructure ) {
121
121
const { uidl, files, template } = structure
122
122
123
- const { languages = { en : 'English' } , main = { locale : 'en' , name : 'English' } } =
124
- uidl . internationalization || { }
123
+ const {
124
+ languages = { en : 'English' } ,
125
+ main = { locale : 'en' , name : 'English' } ,
126
+ ignoreBrowserLanguage = false ,
127
+ } = uidl . internationalization || { }
128
+
125
129
if ( languages !== undefined && Object . keys ( languages ) . length > 0 ) {
126
130
const languageKeys = Object . keys ( languages )
127
131
const nextConfig = `module.exports = {
128
132
i18n: {
129
133
locales: [${ languageKeys . map ( ( key ) => `'${ key } '` ) . join ( ', ' ) } ],
130
- defaultLocale: "${ main . locale } ",
134
+ defaultLocale: "${ main . locale } ",${ ignoreBrowserLanguage ? '\n localeDetection: false,' : '' }
131
135
}
132
136
}`
133
137
const existingNextConfig =
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ export interface ProjectUIDL {
96
96
}
97
97
languages : Record < string , string >
98
98
translations : Record < string , Record < string , UIDLElementNode | UIDLStaticValue > >
99
+ ignoreBrowserLanguage ?: boolean
99
100
}
100
101
}
101
102
Original file line number Diff line number Diff line change @@ -269,6 +269,7 @@ export type VProjectUIDL = Modify<
269
269
name : string
270
270
locale : string
271
271
}
272
+ ignoreBrowserLanguage ?: boolean
272
273
languages : Record < string , string >
273
274
translations : Record < string , Record < string , VUIDLElementNode | UIDLStaticValue > >
274
275
}
Original file line number Diff line number Diff line change 9
9
withDefault ,
10
10
number ,
11
11
union ,
12
+ boolean ,
12
13
} from '@mojotech/json-type-validation'
13
14
import {
14
15
VUIDLGlobalProjectValues ,
@@ -88,6 +89,7 @@ export const projectUIDLDecoder: Decoder<VProjectUIDL> = object({
88
89
name : string ( ) ,
89
90
locale : string ( ) ,
90
91
} ) ,
92
+ ignoreBrowserLanguage : optional ( boolean ( ) ) ,
91
93
languages : dict ( string ( ) ) ,
92
94
translations : dict ( dict ( union ( elementNodeDecoder , staticValueDecoder ) ) ) ,
93
95
} )
You can’t perform that action at this time.
0 commit comments