@glossarist/concept-browser 0.4.14 → 0.4.15
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glossarist/concept-browser",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"description": "Vue SPA for browsing Glossarist terminology datasets with cross-reference resolution, graph visualization, and multi-language support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"postcss.config.js",
|
|
79
79
|
"env.d.ts"
|
|
80
80
|
]
|
|
81
|
-
}
|
|
81
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { Concept, LocalizedConcept, Designation, Expression, ConceptSource } from 'glossarist';
|
|
3
3
|
import type { Manifest, GraphEdge } from '../adapters/types';
|
|
4
4
|
import { computed, ref, nextTick, watch } from 'vue';
|
|
5
|
-
import { langName, langLabel } from '../utils/lang';
|
|
5
|
+
import { langName, langLabel, sortLanguages } from '../utils/lang';
|
|
6
6
|
import { renderMath, cleanContent } from '../utils/math';
|
|
7
7
|
import type { RenderOptions } from '../utils/math';
|
|
8
8
|
import { escapeAttr } from '../utils/escape';
|
|
@@ -59,22 +59,7 @@ function copyUri() {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const languages = computed(() => {
|
|
62
|
-
|
|
63
|
-
const keys = props.concept.languages;
|
|
64
|
-
if (!order) {
|
|
65
|
-
return [...keys].sort((a, b) => {
|
|
66
|
-
if (a === 'eng') return -1;
|
|
67
|
-
if (a === 'eng') return 1;
|
|
68
|
-
return a.localeCompare(b);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
const orderIndex = new Map(order.map((lang, i) => [lang, i]));
|
|
72
|
-
return [...keys].sort((a, b) => {
|
|
73
|
-
const ai = orderIndex.get(a) ?? order.length;
|
|
74
|
-
const bi = orderIndex.get(b) ?? order.length;
|
|
75
|
-
if (ai !== bi) return ai - bi;
|
|
76
|
-
return a.localeCompare(b);
|
|
77
|
-
});
|
|
62
|
+
return sortLanguages(props.concept.languages, props.manifest.languageOrder);
|
|
78
63
|
});
|
|
79
64
|
|
|
80
65
|
// Collapsible language sections — expand all with content, collapse those without
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { Concept, LocalizedConcept } from 'glossarist';
|
|
3
3
|
import { computed } from 'vue';
|
|
4
|
-
import { langName, langLabel } from '../utils/lang';
|
|
4
|
+
import { langName, langLabel, sortLanguages } from '../utils/lang';
|
|
5
5
|
import { entryStatusColor } from '../utils/concept-helpers';
|
|
6
6
|
|
|
7
7
|
const props = defineProps<{
|
|
@@ -141,19 +141,7 @@ const languagesWithHistory = computed(() => {
|
|
|
141
141
|
langs.push(lang);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
if (order) {
|
|
146
|
-
const orderIndex = new Map(order.map((l, i) => [l, i]));
|
|
147
|
-
langs.sort((a, b) => {
|
|
148
|
-
const ai = orderIndex.get(a) ?? order.length;
|
|
149
|
-
const bi = orderIndex.get(b) ?? order.length;
|
|
150
|
-
if (ai !== bi) return ai - bi;
|
|
151
|
-
return a.localeCompare(b);
|
|
152
|
-
});
|
|
153
|
-
} else {
|
|
154
|
-
langs.sort();
|
|
155
|
-
}
|
|
156
|
-
return langs;
|
|
144
|
+
return sortLanguages(langs, props.languageOrder);
|
|
157
145
|
});
|
|
158
146
|
|
|
159
147
|
function formatDate(isoDate: string): string {
|
package/src/utils/lang.ts
CHANGED
|
@@ -29,4 +29,17 @@ export function langLabel(code: string): string {
|
|
|
29
29
|
return code.toUpperCase();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
const FALLBACK_LANG_ORDER = ['eng', 'fra'];
|
|
33
|
+
|
|
34
|
+
export function sortLanguages(languages: string[], order?: string[]): string[] {
|
|
35
|
+
const priority = order ?? FALLBACK_LANG_ORDER;
|
|
36
|
+
const index = new Map(priority.map((l, i) => [l, i]));
|
|
37
|
+
return [...languages].sort((a, b) => {
|
|
38
|
+
const ai = index.get(a) ?? priority.length;
|
|
39
|
+
const bi = index.get(b) ?? priority.length;
|
|
40
|
+
if (ai !== bi) return ai - bi;
|
|
41
|
+
return a.localeCompare(b);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
32
45
|
export const DEFAULT_LANG = 'eng';
|