Skip to content

Commit 52bae94

Browse files
Fixed classifier i18n
1 parent 3661ecf commit 52bae94

File tree

7 files changed

+56
-29
lines changed

7 files changed

+56
-29
lines changed

Diff for: src/i18n/locales/en.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@
304304
"component_framework": "Framework",
305305
"component_library": "Library",
306306
"component_container": "Container",
307-
"component_os": "Operation system",
307+
"component_operating_system": "Operation system",
308308
"component_device": "Device",
309309
"component_firmware": "Firmware",
310310
"component_file": "File"

Diff for: src/shared/common.js

+26
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,31 @@ $common.makeAnalysisResponseLabelFormatter = (i18n) => {
190190
}
191191
};
192192

193+
/**
194+
*
195+
* @param {*} i18n - VueI18n instance with $t translate function available
196+
* @returns a specialized label for component and project classifiers (APPLICATION, LIBRARY, etc).
197+
* It must have a corresponding entry in the locales files (e.g. src/locales/en.json)
198+
* (application, library, etc.)
199+
*/
200+
$common.componentClassifierLabelFormatter = (i18n) => {
201+
return function (value) {
202+
switch (value) {
203+
case 'APPLICATION':
204+
case 'FRAMEWORK':
205+
case 'LIBRARY':
206+
case 'CONTAINER':
207+
case 'OPERATING_SYSTEM':
208+
case 'DEVICE':
209+
case 'FIRMWARE':
210+
case 'FILE':
211+
return i18n.$t(`message.component_${value.toLowerCase()}`)
212+
default:
213+
return null;
214+
}
215+
}
216+
};
217+
193218
/**
194219
* Given a UNIX timestamp, this function will return a formatted date.
195220
* i.e. 15 Jan 2017
@@ -291,6 +316,7 @@ module.exports = {
291316
formatAnalyzerLabel: $common.formatAnalyzerLabel,
292317
makeAnalysisStateLabelFormatter: $common.makeAnalysisStateLabelFormatter,
293318
makeAnalysisJustificationLabelFormatter: $common.makeAnalysisJustificationLabelFormatter,
319+
componentClassifierLabelFormatter: $common.componentClassifierLabelFormatter,
294320
formatTimestamp: $common.formatTimestamp,
295321
concatenateComponentName: $common.concatenateComponentName,
296322
valueWithDefault: $common.valueWithDefault,

Diff for: src/views/portfolio/projects/ComponentDetailsModal.vue

+8-8
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@
146146
data() {
147147
return {
148148
availableClassifiers: [
149-
{ value: 'APPLICATION', text: 'Application' },
150-
{ value: 'FRAMEWORK', text: 'Framework' },
151-
{ value: 'LIBRARY', text: 'Library' },
152-
{ value: 'CONTAINER', text: 'Container' },
153-
{ value: 'OPERATING_SYSTEM', text: 'Operating System' },
154-
{ value: 'DEVICE', text: 'Device' },
155-
{ value: 'FIRMWARE', text: 'Firmware' },
156-
{ value: 'FILE', text: 'File' }
149+
{ value: 'APPLICATION', text: this.$i18n.t('message.component_application') },
150+
{ value: 'FRAMEWORK', text: this.$i18n.t('message.component_framework') },
151+
{ value: 'LIBRARY', text: this.$i18n.t('message.component_library') },
152+
{ value: 'CONTAINER', text: this.$i18n.t('message.component_container') },
153+
{ value: 'OPERATING_SYSTEM', text: this.$i18n.t('message.component_operating_system') },
154+
{ value: 'DEVICE', text: this.$i18n.t('message.component_device') },
155+
{ value: 'FIRMWARE', text: this.$i18n.t('message.component_firmware') },
156+
{ value: 'FILE', text: this.$i18n.t('message.component_file') }
157157
],
158158
selectableLicenses: [],
159159
selectedLicense: '',

Diff for: src/views/portfolio/projects/ProjectAddComponentModal.vue

+8-8
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@
110110
data() {
111111
return {
112112
availableClassifiers: [
113-
{ value: 'APPLICATION', text: 'Application' },
114-
{ value: 'FRAMEWORK', text: 'Framework' },
115-
{ value: 'LIBRARY', text: 'Library' },
116-
{ value: 'CONTAINER', text: 'Container' },
117-
{ value: 'OPERATING_SYSTEM', text: 'Operating System' },
118-
{ value: 'DEVICE', text: 'Device' },
119-
{ value: 'FIRMWARE', text: 'Firmware' },
120-
{ value: 'FILE', text: 'File' }
113+
{ value: 'APPLICATION', text: this.$i18n.t('message.component_application') },
114+
{ value: 'FRAMEWORK', text: this.$i18n.t('message.component_framework') },
115+
{ value: 'LIBRARY', text: this.$i18n.t('message.component_library') },
116+
{ value: 'CONTAINER', text: this.$i18n.t('message.component_container') },
117+
{ value: 'OPERATING_SYSTEM', text: this.$i18n.t('message.component_operating_system') },
118+
{ value: 'DEVICE', text: this.$i18n.t('message.component_device') },
119+
{ value: 'FIRMWARE', text: this.$i18n.t('message.component_firmware') },
120+
{ value: 'FILE', text: this.$i18n.t('message.component_file') }
121121
],
122122
selectableLicenses: [],
123123
selectedLicense: '',

Diff for: src/views/portfolio/projects/ProjectCreateProjectModal.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
{ value: 'FRAMEWORK', text: this.$i18n.t('message.component_framework') },
105105
{ value: 'LIBRARY', text: this.$i18n.t('message.component_library') },
106106
{ value: 'CONTAINER', text: this.$i18n.t('message.component_container') },
107-
{ value: 'OPERATING_SYSTEM', text: this.$i18n.t('message.component_os') },
107+
{ value: 'OPERATING_SYSTEM', text: this.$i18n.t('message.component_operating_system') },
108108
{ value: 'DEVICE', text: this.$i18n.t('message.component_device') },
109109
{ value: 'FIRMWARE', text: this.$i18n.t('message.component_firmware') },
110110
{ value: 'FILE', text: this.$i18n.t('message.component_file') }
@@ -135,8 +135,8 @@
135135
sortAvailableClassifiers: function() {
136136
this.availableClassifiers.sort(function(a, b) {
137137
return a.text.localeCompare(b.text);
138-
});
139-
return this.availableClassifiers;
138+
});
139+
return this.availableClassifiers;
140140
}
141141
},
142142
methods: {

Diff for: src/views/portfolio/projects/ProjectDetailsModal.vue

+8-8
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@
106106
readOnlyProjectName: '',
107107
readOnlyProjectVersion: '',
108108
availableClassifiers: [
109-
{ value: 'APPLICATION', text: 'Application' },
110-
{ value: 'FRAMEWORK', text: 'Framework' },
111-
{ value: 'LIBRARY', text: 'Library' },
112-
{ value: 'CONTAINER', text: 'Container' },
113-
{ value: 'OPERATING_SYSTEM', text: 'Operating System' },
114-
{ value: 'DEVICE', text: 'Device' },
115-
{ value: 'FIRMWARE', text: 'Firmware' },
116-
{ value: 'FILE', text: 'File' }
109+
{ value: 'APPLICATION', text: this.$i18n.t('message.component_application') },
110+
{ value: 'FRAMEWORK', text: this.$i18n.t('message.component_framework') },
111+
{ value: 'LIBRARY', text: this.$i18n.t('message.component_library') },
112+
{ value: 'CONTAINER', text: this.$i18n.t('message.component_container') },
113+
{ value: 'OPERATING_SYSTEM', text: this.$i18n.t('message.component_operating_system') },
114+
{ value: 'DEVICE', text: this.$i18n.t('message.component_device') },
115+
{ value: 'FIRMWARE', text: this.$i18n.t('message.component_firmware') },
116+
{ value: 'FILE', text: this.$i18n.t('message.component_file') }
117117
],
118118
tag: '', // The contents of a tag as its being typed into the vue-tag-input
119119
tags: [], // An array of tags bound to the vue-tag-input

Diff for: src/views/portfolio/projects/ProjectList.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
{
9393
title: this.$t('message.classifier'),
9494
field: "classifier",
95-
sortable: true
95+
sortable: true,
96+
formatter: common.componentClassifierLabelFormatter(this),
9697
},
9798
{
9899
title: this.$t('message.last_bom_import'),

0 commit comments

Comments
 (0)