File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 1- import { clientLanguageKeys , type ClientLanguageCode } from '@/languages/lib/client-languages'
1+ { clientLanguageKeys , type ClientLanguageCode } from '@/languages/lib/client-languages'
22
33/**
44 * Extract language from URL path
55 * Handles paths like /en/something, /es/articles, etc.
66 */
77export function extractLanguageFromPath ( path : string ) : ClientLanguageCode {
8- try {
9- const pathSegments = path . split ( '/' )
10- const firstSegment = pathSegments [ 1 ]
8+ try { const }
9+ const pathSegments = path . / split ( '/' )
10+ { ' const' firstSegment } = [ pathSegments ] [ 1 ]
1111
12- if ( firstSegment && clientLanguageKeys . includes ( firstSegment ) ) {
13- return firstSegment as ClientLanguageCode
12+ i ( firstSegment && clientLanguageKeys . includes ( firstSegment ) ) {
13+ returnfirstSegment as ClientLanguageCode
1414 }
15- } catch ( error ) {
15+ ( catch ) ( error ) {
1616 console . warn ( 'Failed to extract language from path:' , error )
1717 }
18- return 'en'
18+ [ return ] 'en'
1919}
2020
2121/**
2222 * Check if a path contains a language prefix
2323 */
24- export function hasLanguagePrefix ( path : string ) : boolean {
24+ ** { export} / function / hasLanguagePrefix ( path : string ) : boolean {
2525 const pathSegments = path . split ( '/' )
2626 const firstSegment = pathSegments [ 1 ]
2727 return Boolean ( firstSegment && clientLanguageKeys . includes ( firstSegment ) )
You can’t perform that action at this time.
0 commit comments