@katlux/toolkit 0.1.1-alpha.93 → 0.1.1-alpha.95
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/compiled/composables/locales.mjs +554 -0
- package/dist/compiled/composables/useKatluxI18n.mjs +56 -0
- package/dist/compiled/composables/useKatluxI18n.spec.mjs +10 -0
- package/dist/module.cjs +2 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
- package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
- package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +2 -2
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +2 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +1 -1
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +6 -6
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +6 -6
- package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +3 -3
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +9 -9
- package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +9 -9
- package/dist/runtime/components/KGantt/KGantt.logic.d.ts +4 -4
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +6 -6
- package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +6 -6
- package/dist/runtime/components/KIcon/KIcon.logic.d.ts +3 -3
- package/dist/runtime/components/KLoader/KLoader.global.d.vue.ts +1 -1
- package/dist/runtime/components/KLoader/KLoader.global.vue.d.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KToast/KToast.global.d.vue.ts +1 -1
- package/dist/runtime/components/KToast/KToast.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +1 -1
- package/dist/runtime/composables/locales.d.ts +28 -0
- package/dist/runtime/composables/locales.js +554 -0
- package/dist/runtime/composables/useKatluxI18n.d.ts +15 -0
- package/dist/runtime/composables/useKatluxI18n.js +56 -0
- package/dist/runtime/presets/default/components/KAlert/KAlert.vue +2 -3
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +2 -2
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +2 -2
- package/dist/runtime/presets/default/components/KModal/KModal.vue +2 -2
- package/dist/runtime/presets/default/components/KPagination/KPagination.vue +2 -2
- package/dist/runtime/presets/default/components/KTabs/KTabs.vue +2 -2
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +2 -2
- package/dist/runtime/presets/default/components/KTree/KTree.vue +2 -2
- package/package.json +2 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const defaultKatluxTranslations: Record<string, string>;
|
|
2
|
+
/**
|
|
3
|
+
* Resilient translation composable for Katlux Toolkit components.
|
|
4
|
+
*
|
|
5
|
+
* Lookup Order:
|
|
6
|
+
* 1. nuxtApp.$t (if @nuxtjs/i18n or vue-i18n is available)
|
|
7
|
+
* 2. appConfig.katluxToolkit.translations[locale][key]
|
|
8
|
+
* 3. appConfig.katluxToolkit.translations[key]
|
|
9
|
+
* 4. Built-in LTR locale dictionary (en, es, fr, de, pt, it, nl, pl, ru, uk, zh, ja, ko, hi, bn, id, vi, th, sv, da, fi, cs, el)
|
|
10
|
+
* 5. Built-in default English dictionary
|
|
11
|
+
* 6. Raw key string
|
|
12
|
+
*/
|
|
13
|
+
export declare function useKatluxI18n(): {
|
|
14
|
+
t: (key: string, params?: Record<string, any>) => string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { en, builtInLocales } from "./locales.js";
|
|
2
|
+
export const defaultKatluxTranslations = en;
|
|
3
|
+
export function useKatluxI18n() {
|
|
4
|
+
let nuxtApp = null;
|
|
5
|
+
try {
|
|
6
|
+
if (typeof globalThis.useNuxtApp === "function") {
|
|
7
|
+
nuxtApp = globalThis.useNuxtApp();
|
|
8
|
+
}
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
11
|
+
let appConfig = null;
|
|
12
|
+
try {
|
|
13
|
+
if (typeof globalThis.useAppConfig === "function") {
|
|
14
|
+
appConfig = globalThis.useAppConfig();
|
|
15
|
+
}
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
const toolkitConfig = appConfig?.katluxToolkit || {};
|
|
19
|
+
const customTranslations = toolkitConfig.translations || {};
|
|
20
|
+
const t = (key, params) => {
|
|
21
|
+
if (nuxtApp && typeof nuxtApp.$t === "function") {
|
|
22
|
+
try {
|
|
23
|
+
const res = nuxtApp.$t(key, params);
|
|
24
|
+
if (res && res !== key) return res;
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const currentLocale = toolkitConfig.locale || nuxtApp?.i18n?.locale?.value || "en";
|
|
29
|
+
if (customTranslations[currentLocale] && typeof customTranslations[currentLocale] === "object") {
|
|
30
|
+
const langDict = customTranslations[currentLocale];
|
|
31
|
+
if (langDict[key]) {
|
|
32
|
+
return applyParams(langDict[key], params);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (typeof customTranslations[key] === "string") {
|
|
36
|
+
return applyParams(customTranslations[key], params);
|
|
37
|
+
}
|
|
38
|
+
const builtInDict = builtInLocales[currentLocale];
|
|
39
|
+
if (builtInDict && builtInDict[key]) {
|
|
40
|
+
return applyParams(builtInDict[key], params);
|
|
41
|
+
}
|
|
42
|
+
if (defaultKatluxTranslations[key]) {
|
|
43
|
+
return applyParams(defaultKatluxTranslations[key], params);
|
|
44
|
+
}
|
|
45
|
+
return applyParams(key, params);
|
|
46
|
+
};
|
|
47
|
+
return { t };
|
|
48
|
+
}
|
|
49
|
+
function applyParams(text, params) {
|
|
50
|
+
if (!params) return text;
|
|
51
|
+
let result = text;
|
|
52
|
+
for (const [pKey, pValue] of Object.entries(params)) {
|
|
53
|
+
result = result.replace(new RegExp(`\\{${pKey}\\}`, "g"), String(pValue));
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
@@ -12,14 +12,13 @@ Transition(name="k-alert-fade")
|
|
|
12
12
|
|
|
13
13
|
<script lang="ts" setup>
|
|
14
14
|
import type { KAlertProps } from '../../../../components/KAlert/KAlert.logic'
|
|
15
|
-
import {
|
|
15
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
16
16
|
|
|
17
17
|
const props = defineProps<KAlertProps>()
|
|
18
18
|
const emit = defineEmits<{ dismiss: [] }>()
|
|
19
19
|
const { visible, dismiss, icon } = useKAlertLogic(props, () => emit('dismiss'))
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
21
|
+
const { t } = useKatluxI18n()
|
|
23
22
|
</script>
|
|
24
23
|
|
|
25
24
|
<style lang="scss" scoped>
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
import { computed } from 'vue'
|
|
26
26
|
import { CFlatClientDataProvider } from '@katlux/providers'
|
|
27
27
|
import type { IKDatatableAction } from '@katlux/providers'
|
|
28
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
28
29
|
|
|
29
|
-
const
|
|
30
|
-
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
30
|
+
const { t } = useKatluxI18n()
|
|
31
31
|
|
|
32
32
|
const props = defineProps<{
|
|
33
33
|
bulkActions: IKDatatableAction[]
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
import { computed } from 'vue'
|
|
60
60
|
import { ADataProvider } from '@katlux/providers'
|
|
61
61
|
import type { IKDatatableAction } from '@katlux/providers'
|
|
62
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
62
63
|
|
|
63
|
-
const
|
|
64
|
-
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
64
|
+
const { t } = useKatluxI18n()
|
|
65
65
|
|
|
66
66
|
const props = defineProps<{
|
|
67
67
|
dataProvider: ADataProvider
|
|
@@ -11,9 +11,9 @@ dialog.k-modal(ref="dialogRef" @close="closeModal" @click="handleBackdropClick"
|
|
|
11
11
|
|
|
12
12
|
<script lang="ts" setup>
|
|
13
13
|
import { ref, watch, onMounted } from 'vue'
|
|
14
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
-
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
16
|
+
const { t } = useKatluxI18n()
|
|
17
17
|
|
|
18
18
|
const props = defineProps<{
|
|
19
19
|
modalId: string
|
|
@@ -32,9 +32,9 @@ nav.k-pagination(v-if="totalPages > 1" :aria-label="t('Pagination Navigation')")
|
|
|
32
32
|
|
|
33
33
|
<script setup lang="ts">
|
|
34
34
|
import { computed } from 'vue'
|
|
35
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
35
36
|
|
|
36
|
-
const
|
|
37
|
-
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
37
|
+
const { t } = useKatluxI18n()
|
|
38
38
|
|
|
39
39
|
const props = defineProps<{
|
|
40
40
|
dp: any
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
|
|
23
23
|
<script lang="ts" setup>
|
|
24
24
|
import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
|
25
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
25
26
|
|
|
26
|
-
const
|
|
27
|
-
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
27
|
+
const { t } = useKatluxI18n()
|
|
28
28
|
|
|
29
29
|
const props = defineProps<{
|
|
30
30
|
items: any[]
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
<script lang="ts" setup>
|
|
11
11
|
import { computed, useAttrs } from 'vue'
|
|
12
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
14
|
+
const { t } = useKatluxI18n()
|
|
15
15
|
|
|
16
16
|
defineOptions({
|
|
17
17
|
inheritAttrs: false
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
|
|
51
51
|
<script lang="ts" setup>
|
|
52
52
|
import { computed, type Ref } from 'vue'
|
|
53
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
53
54
|
|
|
54
|
-
const
|
|
55
|
-
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
55
|
+
const { t } = useKatluxI18n()
|
|
56
56
|
|
|
57
57
|
const props = defineProps<{
|
|
58
58
|
visibleRows: any[] // Rows with __treeNode attached
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@katlux/toolkit",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.95",
|
|
4
4
|
"description": "Core UI toolkit and utilities for the Katlux ecosystem",
|
|
5
5
|
"author": "Katlux",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@katlux/providers": "*",
|
|
42
42
|
"@nuxt/kit": "^3.12.0",
|
|
43
|
+
"@nuxtjs/i18n": "^10.4.0",
|
|
43
44
|
"pug": "^3.0.0",
|
|
44
45
|
"sass": "^1.80.0"
|
|
45
46
|
},
|