holie-vkit 1.1.5 → 1.1.6
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.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/i18n.d.ts +1 -0
- package/dist/utils/i18n.js +11 -0
- package/dist/utils/shared.d.ts +7 -0
- package/dist/utils/shared.js +68 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/utils/i18n.d.ts
CHANGED
package/dist/utils/i18n.js
CHANGED
|
@@ -3,3 +3,14 @@ export function translate(key, lang) {
|
|
|
3
3
|
// TODO: Implement translation logic
|
|
4
4
|
return key;
|
|
5
5
|
}
|
|
6
|
+
export const LOCALE_MAP = {
|
|
7
|
+
nl: 'nl-BE',
|
|
8
|
+
en: 'en-GB',
|
|
9
|
+
fr: 'fr-FR',
|
|
10
|
+
de: 'de-DE',
|
|
11
|
+
es: 'es-ES',
|
|
12
|
+
pt: 'pt-BR',
|
|
13
|
+
ar: 'ar-SA',
|
|
14
|
+
pl: 'pl-PL',
|
|
15
|
+
ja: 'ja-JP',
|
|
16
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function formatDate(dateString: string, language: string, options?: Intl.DateTimeFormatOptions): string;
|
|
2
|
+
export declare function formatArticleDate(dateString: string, language: string): string;
|
|
3
|
+
export declare function getCategoryTranslation(category: string, translations: any, fallback?: string): string;
|
|
4
|
+
export declare function getLocalizedTitle(title: Record<string, string> | undefined, language: string, fallback?: string): string;
|
|
5
|
+
export declare function getLocalizedContent(content: Record<string, string> | undefined, language: string, fallback?: string): string;
|
|
6
|
+
export declare function getEmptyStateMessage(language: string): string;
|
|
7
|
+
export declare function getArticleCountLabel(language: string): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Shared utility functions for all holie websites
|
|
2
|
+
import { LOCALE_MAP } from './i18n';
|
|
3
|
+
export function formatDate(dateString, language, options) {
|
|
4
|
+
try {
|
|
5
|
+
const date = new Date(dateString);
|
|
6
|
+
if (isNaN(date.getTime()))
|
|
7
|
+
return dateString;
|
|
8
|
+
const defaultOptions = {
|
|
9
|
+
day: 'numeric',
|
|
10
|
+
month: 'short',
|
|
11
|
+
year: 'numeric',
|
|
12
|
+
};
|
|
13
|
+
return date.toLocaleDateString(LOCALE_MAP[language] || language, { ...defaultOptions, ...options });
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return dateString;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function formatArticleDate(dateString, language) {
|
|
20
|
+
return formatDate(dateString, language, {
|
|
21
|
+
day: 'numeric',
|
|
22
|
+
month: 'long',
|
|
23
|
+
year: 'numeric',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function getCategoryTranslation(category, translations, fallback = category) {
|
|
27
|
+
return translations[category] || fallback;
|
|
28
|
+
}
|
|
29
|
+
export function getLocalizedTitle(title, language, fallback = 'Untitled') {
|
|
30
|
+
if (!title)
|
|
31
|
+
return fallback;
|
|
32
|
+
return title[language] || title.en || fallback;
|
|
33
|
+
}
|
|
34
|
+
export function getLocalizedContent(content, language, fallback = '') {
|
|
35
|
+
if (!content)
|
|
36
|
+
return fallback;
|
|
37
|
+
return content[language] || content.en || fallback;
|
|
38
|
+
}
|
|
39
|
+
export function getEmptyStateMessage(language) {
|
|
40
|
+
const messages = {
|
|
41
|
+
nl: 'Nog geen artikelen in deze categorie.',
|
|
42
|
+
en: 'No articles in this category yet.',
|
|
43
|
+
fr: 'Pas encore d\'articles dans cette catégorie.',
|
|
44
|
+
de: 'Noch keine Artikel in dieser Kategorie.',
|
|
45
|
+
es: 'Aún no hay artículos en esta categoría.',
|
|
46
|
+
pt: 'Ainda não há artigos nesta categoria.',
|
|
47
|
+
ar: 'لا توجد مقالات في هذه الفئة بعد.',
|
|
48
|
+
pl: 'Jeszcze brak artykułów w tej kategorii.',
|
|
49
|
+
ja: 'このカテゴリーにはまだ記事がありません。',
|
|
50
|
+
tr: 'Bu kategoride henüz makale yok.',
|
|
51
|
+
};
|
|
52
|
+
return messages[language] || messages.en;
|
|
53
|
+
}
|
|
54
|
+
export function getArticleCountLabel(language) {
|
|
55
|
+
const labels = {
|
|
56
|
+
nl: 'artikelen',
|
|
57
|
+
en: 'articles',
|
|
58
|
+
fr: 'articles',
|
|
59
|
+
de: 'Artikel',
|
|
60
|
+
es: 'artículos',
|
|
61
|
+
pt: 'artigos',
|
|
62
|
+
ar: 'مقالات',
|
|
63
|
+
pl: 'artykuły',
|
|
64
|
+
ja: '記事',
|
|
65
|
+
tr: 'makale',
|
|
66
|
+
};
|
|
67
|
+
return labels[language] || labels.en;
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "holie-vkit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"build": "tsc"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"holie-vkit": "^1.1.5",
|
|
14
15
|
"react": "^18.0.0"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|