Skip to content

Commit 6b2913c

Browse files
author
m88833020-star
authored
Correct language extraction function syntax
Fix syntax errors and improve language extraction logic.
1 parent 56eb33f commit 6b2913c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/app/lib/language-utils.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
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
*/
77
export 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))

0 commit comments

Comments
 (0)