@@ -13,11 +13,11 @@ import type {
13
13
import { MatomoEventOptions , trackCustomEvent } from "@/lib/utils/matomo"
14
14
import { languages } from "@/lib/utils/translations"
15
15
16
- import progressData from "@/data/translationProgress.json"
16
+ import progressDataJson from "@/data/translationProgress.json"
17
17
18
18
import { DEFAULT_LOCALE } from "@/lib/constants"
19
19
20
- const data = progressData as ProjectProgressData [ ]
20
+ const progressData = progressDataJson satisfies ProjectProgressData [ ]
21
21
22
22
export const useLanguagePicker = (
23
23
handleClose ?: ( ) => void ,
@@ -88,20 +88,24 @@ export const useLanguagePicker = (
88
88
}
89
89
90
90
// English will not have a dataItem
91
- const dataItem = data . find (
91
+ const dataItem = progressData . find (
92
92
( { languageId } ) =>
93
93
i18nItem . crowdinCode . toLowerCase ( ) === languageId . toLowerCase ( )
94
94
)
95
95
96
96
const approvalProgress =
97
- localeOption === DEFAULT_LOCALE ? 100 : dataItem ?. approvalProgress || 0
97
+ localeOption === DEFAULT_LOCALE
98
+ ? 100
99
+ : Math . floor (
100
+ ( dataItem ! . words . approved / dataItem ! . words . total ) * 100
101
+ ) || 0
98
102
99
- if ( data . length === 0 )
103
+ if ( progressData . length === 0 )
100
104
throw new Error (
101
105
"Missing translation progress data; check GitHub action"
102
106
)
103
107
104
- const totalWords = data [ 0 ] . words . total
108
+ const totalWords = progressData [ 0 ] . words . total
105
109
106
110
const wordsApproved =
107
111
localeOption === DEFAULT_LOCALE
0 commit comments