@fy-/fws-vue 2.3.40 → 2.3.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composables/templating.ts +31 -25
- package/package.json +1 -1
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
import { getLocale } from '@fy-/fws-js'
|
|
2
2
|
import { format as formatDateTimeago, register } from 'timeago.js'
|
|
3
|
-
import
|
|
3
|
+
import de from 'timeago.js/esm/lang/de'
|
|
4
|
+
import es from 'timeago.js/esm/lang/es'
|
|
5
|
+
// Import common locales individually to avoid CommonJS issues
|
|
6
|
+
import fr from 'timeago.js/esm/lang/fr'
|
|
7
|
+
import it from 'timeago.js/esm/lang/it'
|
|
8
|
+
import ja from 'timeago.js/esm/lang/ja'
|
|
9
|
+
import nl from 'timeago.js/esm/lang/nl'
|
|
10
|
+
import ru from 'timeago.js/esm/lang/ru'
|
|
11
|
+
import zh_CN from 'timeago.js/esm/lang/zh_CN'
|
|
4
12
|
import { useTranslation } from './translations'
|
|
5
13
|
|
|
6
|
-
// Register
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
// Register common locales
|
|
15
|
+
register('fr', fr)
|
|
16
|
+
register('fr_FR', fr)
|
|
17
|
+
register('es', es)
|
|
18
|
+
register('es_ES', es)
|
|
19
|
+
register('de', de)
|
|
20
|
+
register('de_DE', de)
|
|
21
|
+
register('it', it)
|
|
22
|
+
register('it_IT', it)
|
|
23
|
+
register('nl', nl)
|
|
24
|
+
register('nl_NL', nl)
|
|
25
|
+
register('ru', ru)
|
|
26
|
+
register('ru_RU', ru)
|
|
27
|
+
register('ja', ja)
|
|
28
|
+
register('ja_JP', ja)
|
|
29
|
+
register('zh_CN', zh_CN)
|
|
18
30
|
|
|
19
31
|
// Cache common constants and patterns
|
|
20
32
|
const k = 1024
|
|
@@ -123,23 +135,17 @@ function formatDatetime(dt: Date | string | number) {
|
|
|
123
135
|
|
|
124
136
|
function formatTimeago(dt: Date | string | number) {
|
|
125
137
|
const timestamp = parseDateInput(dt)
|
|
126
|
-
|
|
138
|
+
const dateObj = new Date(timestamp)
|
|
139
|
+
|
|
140
|
+
// Get browser locale and format it for timeago.js
|
|
127
141
|
const fullLocale = getLocale()
|
|
128
142
|
|
|
129
|
-
//
|
|
143
|
+
// Convert locale format (e.g., fr-FR to fr_FR)
|
|
130
144
|
const localeWithUnderscore = fullLocale.replace('-', '_')
|
|
131
145
|
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// Try the formats in order of preference
|
|
136
|
-
// This avoids try/catch which can trigger linting issues
|
|
137
|
-
const dateObj = new Date(timestamp)
|
|
138
|
-
|
|
139
|
-
// No try/catch needed - if locale doesn't exist, timeago falls back to en_US
|
|
146
|
+
// Use the locale directly - the registration above ensures support
|
|
147
|
+
// timeago.js will fall back to en_US if no matching locale is found
|
|
140
148
|
return formatDateTimeago(dateObj, localeWithUnderscore)
|
|
141
|
-
|| formatDateTimeago(dateObj, langOnly)
|
|
142
|
-
|| formatDateTimeago(dateObj, 'en_US')
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
export {
|