@bagelink/vue 0.0.1296 → 0.0.1298

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/dist/index.cjs CHANGED
@@ -37167,16 +37167,16 @@ const translations = {
37167
37167
  second: "seconde",
37168
37168
  ago: "il y a",
37169
37169
  in: "dans",
37170
- justNow: "À linstant"
37170
+ justNow: "À l'instant"
37171
37171
  },
37172
37172
  he: {
37173
- year: "שנה",
37174
- month: "חודש",
37175
- week: "שבוע",
37176
- day: "יום",
37177
- hour: "שעה",
37178
- minute: "דקה",
37179
- second: "שנייה",
37173
+ year: { singular: "שנה", plural: "שנים" },
37174
+ month: { singular: "חודש", plural: "חודשים" },
37175
+ week: { singular: "שבוע", plural: "שבועות" },
37176
+ day: { singular: "יום", plural: "ימים" },
37177
+ hour: { singular: "שעה", plural: "שעות" },
37178
+ minute: { singular: "דקה", plural: "דקות" },
37179
+ second: { singular: "שנייה", plural: "שניות" },
37180
37180
  ago: "לפני",
37181
37181
  in: "בעוד",
37182
37182
  justNow: "זה עתה"
@@ -37203,7 +37203,19 @@ function timeAgo(date2, lang = "en") {
37203
37203
  const count2 = Math.floor(Math.abs(seconds) / interval.seconds);
37204
37204
  if (count2 >= 1) {
37205
37205
  const suffix = seconds < 0 ? ` ${selectedLang.ago}` : "";
37206
- const prefix = "";
37206
+ const prefix = seconds > 0 && selectedLang.in !== "in" ? `${selectedLang.in} ` : "";
37207
+ if (lang === "he") {
37208
+ const timeUnit = selectedLang[interval.label];
37209
+ const form = count2 === 1 ? timeUnit.singular : timeUnit.plural;
37210
+ const hebrewPrefix = seconds < 0 ? `${selectedLang.ago} ` : seconds > 0 ? `${selectedLang.in} ` : "";
37211
+ if (interval.label === "day" && seconds > 0) {
37212
+ const hours = Math.floor(Math.abs(seconds) % 86400 / 3600);
37213
+ const hourUnit = selectedLang.hour;
37214
+ const hourForm = hours === 1 ? hourUnit.singular : hourUnit.plural;
37215
+ return `${hebrewPrefix}${count2} ${form}${hours > 0 ? ` ${hours} ${hourForm}` : ""}`;
37216
+ }
37217
+ return `${hebrewPrefix}${count2} ${form}`;
37218
+ }
37207
37219
  if (interval.label === "day" && seconds > 0) {
37208
37220
  const hours = Math.floor(Math.abs(seconds) % 86400 / 3600);
37209
37221
  const hourLabel = hours > 1 ? `${selectedLang.hour}s` : selectedLang.hour;
package/dist/index.mjs CHANGED
@@ -37165,16 +37165,16 @@ const translations = {
37165
37165
  second: "seconde",
37166
37166
  ago: "il y a",
37167
37167
  in: "dans",
37168
- justNow: "À linstant"
37168
+ justNow: "À l'instant"
37169
37169
  },
37170
37170
  he: {
37171
- year: "שנה",
37172
- month: "חודש",
37173
- week: "שבוע",
37174
- day: "יום",
37175
- hour: "שעה",
37176
- minute: "דקה",
37177
- second: "שנייה",
37171
+ year: { singular: "שנה", plural: "שנים" },
37172
+ month: { singular: "חודש", plural: "חודשים" },
37173
+ week: { singular: "שבוע", plural: "שבועות" },
37174
+ day: { singular: "יום", plural: "ימים" },
37175
+ hour: { singular: "שעה", plural: "שעות" },
37176
+ minute: { singular: "דקה", plural: "דקות" },
37177
+ second: { singular: "שנייה", plural: "שניות" },
37178
37178
  ago: "לפני",
37179
37179
  in: "בעוד",
37180
37180
  justNow: "זה עתה"
@@ -37201,7 +37201,19 @@ function timeAgo(date2, lang = "en") {
37201
37201
  const count2 = Math.floor(Math.abs(seconds) / interval.seconds);
37202
37202
  if (count2 >= 1) {
37203
37203
  const suffix = seconds < 0 ? ` ${selectedLang.ago}` : "";
37204
- const prefix = "";
37204
+ const prefix = seconds > 0 && selectedLang.in !== "in" ? `${selectedLang.in} ` : "";
37205
+ if (lang === "he") {
37206
+ const timeUnit = selectedLang[interval.label];
37207
+ const form = count2 === 1 ? timeUnit.singular : timeUnit.plural;
37208
+ const hebrewPrefix = seconds < 0 ? `${selectedLang.ago} ` : seconds > 0 ? `${selectedLang.in} ` : "";
37209
+ if (interval.label === "day" && seconds > 0) {
37210
+ const hours = Math.floor(Math.abs(seconds) % 86400 / 3600);
37211
+ const hourUnit = selectedLang.hour;
37212
+ const hourForm = hours === 1 ? hourUnit.singular : hourUnit.plural;
37213
+ return `${hebrewPrefix}${count2} ${form}${hours > 0 ? ` ${hours} ${hourForm}` : ""}`;
37214
+ }
37215
+ return `${hebrewPrefix}${count2} ${form}`;
37216
+ }
37205
37217
  if (interval.label === "day" && seconds > 0) {
37206
37218
  const hours = Math.floor(Math.abs(seconds) % 86400 / 3600);
37207
37219
  const hourLabel = hours > 1 ? `${selectedLang.hour}s` : selectedLang.hour;
@@ -1 +1 @@
1
- {"version":3,"file":"timeAgo.d.ts","sourceRoot":"","sources":["../../src/utils/timeAgo.ts"],"names":[],"mappings":"AAAA,KAAK,sBAAsB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAsDvD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,GAAE,sBAA6B,UAmC/E"}
1
+ {"version":3,"file":"timeAgo.d.ts","sourceRoot":"","sources":["../../src/utils/timeAgo.ts"],"names":[],"mappings":"AAWA,KAAK,sBAAsB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAqDvD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,GAAE,sBAA6B,UAsD/E"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "0.0.1296",
4
+ "version": "0.0.1298",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -1,7 +1,16 @@
1
- type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he'
1
+ interface TimeUnit {
2
+ singular: string
3
+ plural: string
4
+ }
5
+
6
+ type TranslationValue = string | TimeUnit
7
+
2
8
  interface LanguageTranslations {
3
- [key: string]: string
9
+ [key: string]: TranslationValue
4
10
  }
11
+
12
+ type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he'
13
+
5
14
  const translations: Record<AvailableTimeLanguages, LanguageTranslations> = {
6
15
  en: {
7
16
  year: 'year',
@@ -37,21 +46,22 @@ const translations: Record<AvailableTimeLanguages, LanguageTranslations> = {
37
46
  second: 'seconde',
38
47
  ago: 'il y a',
39
48
  in: 'dans',
40
- justNow: 'À linstant'
49
+ justNow: 'À l\'instant'
41
50
  },
42
51
  he: {
43
- year: 'שנה',
44
- month: 'חודש',
45
- week: 'שבוע',
46
- day: 'יום',
47
- hour: 'שעה',
48
- minute: 'דקה',
49
- second: 'שנייה',
52
+ year: { singular: 'שנה', plural: 'שנים' },
53
+ month: { singular: 'חודש', plural: 'חודשים' },
54
+ week: { singular: 'שבוע', plural: 'שבועות' },
55
+ day: { singular: 'יום', plural: 'ימים' },
56
+ hour: { singular: 'שעה', plural: 'שעות' },
57
+ minute: { singular: 'דקה', plural: 'דקות' },
58
+ second: { singular: 'שנייה', plural: 'שניות' },
50
59
  ago: 'לפני',
51
60
  in: 'בעוד',
52
61
  justNow: 'זה עתה'
53
62
  }
54
63
  }
64
+
55
65
  export function timeAgo(date: string | Date, lang: AvailableTimeLanguages = 'en') {
56
66
  if (!date) return ''
57
67
  if (typeof date === 'string') date = new Date(date)
@@ -76,7 +86,26 @@ export function timeAgo(date: string | Date, lang: AvailableTimeLanguages = 'en'
76
86
  const count = Math.floor(Math.abs(seconds) / interval.seconds)
77
87
  if (count >= 1) {
78
88
  const suffix = seconds < 0 ? ` ${selectedLang.ago}` : ''
79
- const prefix = ''
89
+ const prefix = seconds > 0 && selectedLang.in !== 'in' ? `${selectedLang.in} ` : ''
90
+
91
+ // Handle Hebrew plural forms
92
+ if (lang === 'he') {
93
+ const timeUnit = selectedLang[interval.label] as TimeUnit
94
+ const form = count === 1 ? timeUnit.singular : timeUnit.plural
95
+
96
+ // For Hebrew, we place the prefix/suffix before the number
97
+ const hebrewPrefix = seconds < 0 ? `${selectedLang.ago} ` : (seconds > 0 ? `${selectedLang.in} ` : '')
98
+
99
+ if (interval.label === 'day' && seconds > 0) {
100
+ const hours = Math.floor((Math.abs(seconds) % 86400) / 3600)
101
+ const hourUnit = selectedLang.hour as TimeUnit
102
+ const hourForm = hours === 1 ? hourUnit.singular : hourUnit.plural
103
+ return `${hebrewPrefix}${count} ${form}${hours > 0 ? ` ${hours} ${hourForm}` : ''}`
104
+ }
105
+ return `${hebrewPrefix}${count} ${form}`
106
+ }
107
+
108
+ // Handle other languages
80
109
  if (interval.label === 'day' && seconds > 0) {
81
110
  const hours = Math.floor((Math.abs(seconds) % 86400) / 3600)
82
111
  const hourLabel = hours > 1 ? `${selectedLang.hour}s` : selectedLang.hour
@@ -86,5 +115,5 @@ export function timeAgo(date: string | Date, lang: AvailableTimeLanguages = 'en'
86
115
  }
87
116
  }
88
117
 
89
- return selectedLang.justNow
118
+ return selectedLang.justNow as string
90
119
  }