Skip to content

Commit be033c6

Browse files
feat(CSAF2.1): #366 add recommended test 6.2.46 - uss translations from oasis
1 parent 7e460e8 commit be033c6

File tree

5 files changed

+25
-285
lines changed

5 files changed

+25
-285
lines changed

csaf_2_1/recommendedTests/recommendedTest_6_2_46.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Ajv from 'ajv/dist/jtd.js'
22
import { parse } from 'license-expressions'
33
import license_information from '../../lib/license/license_information.js'
4-
import license_translations from '../../lib/license/license-translations.js'
4+
import translations from '../../lib/language_specific_translation/translations.js'
55
import bcp47 from 'bcp47'
66

77
const ajv = new Ajv()
@@ -171,17 +171,18 @@ function containsOneLegalDisclaimerWithTitle(notes, titleToFind) {
171171
* @return {string | undefined}
172172
*/
173173
export function getLicenseInDocumentLang(doc) {
174-
/** @type {Record<string, string>} */
175-
const translations = license_translations
176174
if (!doc.document.lang) {
177175
return undefined
178176
}
179177
const language = bcp47.parse(doc.document.lang)?.langtag.language.language
180-
if (!language) {
178+
179+
/** @type {Record<string, Record <string,string>>}*/
180+
const translationByLang = translations.translation
181+
if (!language || !translationByLang[language]) {
181182
return undefined
183+
} else {
184+
return translationByLang[language]['license']
182185
}
183-
184-
return translations[language]
185186
}
186187

187188
/**
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* javascript version of JSON file: csaf_2.1/language_specific_translation/translations.json
3+
*/
4+
export default {
5+
$schema:
6+
'https://raw.githubusercontent.com/oasis-tcs/csaf/master/csaf_2.1/test/language_specific_translation/translations_json_schema.json',
7+
translation_version: '2.1',
8+
translation: {
9+
de: {
10+
license: 'Lizenz',
11+
product_description: 'Produktbeschreibung',
12+
reasoning_for_supersession: 'Begründung für die Ersetzung',
13+
reasoning_for_withdrawal: 'Begründung für die Zurückziehung',
14+
superseding_document: 'Ersetzendes Dokument',
15+
},
16+
},
17+
}

lib/license/license-translations.js

Lines changed: 0 additions & 248 deletions
This file was deleted.

scripts/translateLicense.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/csaf_2_1/recommendedTest_6_2_46.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,11 @@ describe('recommendedTest_6_2_46', function () {
2020
)
2121
})
2222

23-
it('check license in document lang', function () {
23+
it('check get license in document lang', function () {
2424
expect(getLicenseInDocumentLang({ document: { lang: 'de' } })).to.eq(
2525
'Lizenz'
2626
)
27-
expect(getLicenseInDocumentLang({ document: { lang: 'en-us' } })).to.eq(
28-
'license'
29-
)
3027
expect(getLicenseInDocumentLang({ document: { lang: 'es' } })).to.eq(
31-
'licencia'
32-
)
33-
expect(getLicenseInDocumentLang({ document: { lang: 'ja' } })).to.eq(
34-
'ライセンス'
35-
)
36-
expect(getLicenseInDocumentLang({ document: { lang: '123' } })).to.eq(
3728
undefined
3829
)
3930
expect(getLicenseInDocumentLang({ document: {} })).to.eq(undefined)

0 commit comments

Comments
 (0)