@@ -100,7 +100,10 @@ export default defineNuxtModule<ModuleOptions>({
100100 return null
101101 }
102102 const forms = translation . toString ( ) . split ( '|' )
103- return ( count < forms . length ? forms [ count ] . trim ( ) : forms [ forms . length - 1 ] . trim ( ) ) . replace ( '{count}' , count . toString ( ) )
103+ if ( forms . length === 0 ) return null
104+ const selectedForm = count < forms . length ? forms [ count ] : forms [ forms . length - 1 ]
105+ if ( ! selectedForm ) return null
106+ return selectedForm . trim ( ) . replace ( '{count}' , count . toString ( ) )
104107 } ,
105108 customRegexMatcher : undefined ,
106109 } ,
@@ -284,7 +287,9 @@ export default defineNuxtModule<ModuleOptions>({
284287 pages . push ( fallbackRoute )
285288 }
286289 if ( ! isNoPrefixStrategy ( options . strategy ! ) ) {
287- nuxt . options . generate . routes = Array . isArray ( nuxt . options . generate . routes ) ? nuxt . options . generate . routes : [ ]
290+ // @ts -ignore - generate может не существовать в новых версиях Nuxt
291+ ; ( nuxt . options as any ) . generate = ( nuxt . options as any ) . generate || { }
292+ ; ( nuxt . options as any ) . generate . routes = Array . isArray ( ( nuxt . options as any ) . generate . routes ) ? ( nuxt . options as any ) . generate . routes : [ ]
288293
289294 if ( isCloudflarePages ) {
290295 const processPageWithChildren = ( page : NuxtPage , parentPath = '' ) => {
@@ -307,7 +312,7 @@ export default defineNuxtModule<ModuleOptions>({
307312 // Проверяем наличие динамического сегмента :locale
308313 const localeSegmentMatch = fullPath . match ( / : l o c a l e \( ( [ ^ ) ] + ) \) / )
309314
310- if ( localeSegmentMatch ) {
315+ if ( localeSegmentMatch && localeSegmentMatch [ 1 ] ) {
311316 const availableLocales = localeSegmentMatch [ 1 ] . split ( '|' ) // Достаем локали из сегмента, например "de|ru|en"
312317 localeManager . locales . forEach ( ( locale ) => {
313318 const localeCode = locale . code
@@ -347,7 +352,7 @@ export default defineNuxtModule<ModuleOptions>({
347352 }
348353
349354 // Пройдемся по страницам и добавим пути для каждого локализованного пути
350- pages . forEach ( ( page ) => {
355+ pages . forEach ( ( page : NuxtPage ) => {
351356 processPageWithChildren ( page ) // Обрабатываем каждую страницу рекурсивно
352357 } )
353358 }
@@ -427,15 +432,17 @@ export default defineNuxtModule<ModuleOptions>({
427432
428433 const routes = nitroConfig . prerender ?. routes || [ ]
429434
430- nuxt . options . generate . routes = Array . isArray ( nuxt . options . generate . routes ) ? nuxt . options . generate . routes : [ ]
431- const pages = nuxt . options . generate . routes || [ ]
435+ // @ts -ignore - generate может не существовать в новых версиях Nuxt
436+ ; ( nuxt . options as any ) . generate = ( nuxt . options as any ) . generate || { }
437+ ; ( nuxt . options as any ) . generate . routes = Array . isArray ( ( nuxt . options as any ) . generate . routes ) ? ( nuxt . options as any ) . generate . routes : [ ]
438+ const pages = ( nuxt . options as any ) . generate . routes || [ ]
432439
433440 localeManager . locales . forEach ( ( locale ) => {
434441 // Для стратегий prefix и prefix_and_default генерируем маршруты и для defaultLocale
435442 // Для стратегии prefix_except_default пропускаем defaultLocale
436443 const shouldGenerate = locale . code !== defaultLocale || withPrefixStrategy ( options . strategy ! )
437444 if ( shouldGenerate ) {
438- pages . forEach ( ( page ) => {
445+ pages . forEach ( ( page : string ) => {
439446 // Пропускаем файлоподобные пути и служебные сегменты `__*`
440447 if ( ! / \. [ a - z 0 - 9 ] + $ / i. test ( page ) && ! isInternalPath ( page ) ) {
441448 const localizedPage = `/${ locale . code } ${ page } `
0 commit comments