diff --git a/cli.js b/cli.js index 0ecbe224..3016b85a 100755 --- a/cli.js +++ b/cli.js @@ -21,6 +21,7 @@ const { iter, pipe, filter, map, obj, } = require('ferrum'); const npath = require('path'); +const { i18nConfig } = require('es2015-i18n-tag'); const traverse = require('./lib/traverseSchema'); const build = require('./lib/markdownBuilder'); const { writereadme, writemarkdown } = require('./lib/writeMarkdown'); @@ -81,10 +82,15 @@ const { argv } = yargs .describe('link-*', 'Add this file as a link the explain the * attribute, e.g. --link-abstract=abstract.md') .alias('i', 'i18n') - .describe('i', 'path to a locales folder with an en.json file in it. This file will be used for all text parts in all templates') + .describe('i', 'path to a locales folder with JSON files') .default('i', nodepath.resolve(__dirname, 'lib', 'locales')) .coerce('i', i => nodepath.resolve(i)) + .alias('l', 'language') + .describe('l', 'the selected language') + .choices('l', ['en_US', 'de_DE']) + .default('l', 'en_US') + .alias('p', 'properties') .array('p') .describe('p', 'name of a custom property which should be also in the description of an element (may be used multiple times)') @@ -103,6 +109,9 @@ const docs = pipe( const schemaPath = argv.d; const schemaExtension = argv.e; +// eslint-disable-next-line import/no-dynamic-require +i18nConfig(require(nodepath.resolve(argv.i, `${argv.l}.json`))); + const schemaloader = loader(); // list all schema files in the specified directory diff --git a/lib/locales/de_DE.json b/lib/locales/de_DE.json new file mode 100644 index 00000000..9fc5d2ad --- /dev/null +++ b/lib/locales/de_DE.json @@ -0,0 +1,6 @@ +{ + "locales": "de_DE", + "translations": { + "${0} Schema": "${0} Schema" + } +} \ No newline at end of file diff --git a/lib/locales/en.json b/lib/locales/en.json deleted file mode 100644 index 28301154..00000000 --- a/lib/locales/en.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "header.titel": "Schema", - "header.hierarchy": "Schema Hierarchy", - "header.tabel.abstract": "Abstract", - "header.tabel.abstractYes": "Can be instantiated", - "header.tabel.abstractNo": "Cannot be instantiated", - "header.tabel.extensible": "Extensible", - "header.tabel.extensibleYes": "Yes", - "header.tabel.extensibleNo": "No", - "header.tabel.status": "Status", - "header.tabel.statusExperimental": "Experimental", - "header.tabel.identifiable": "Identifiable", - "header.tabel.customProperties": "Custom Properties", - "header.tabel.customPropertiesYes": "Allowed", - "header.tabel.customPropertiesNo": "Forbidden", - "header.tabel.additionalProperties": "Additional Properties", - "header.tabel.additionalPropertiesYes": "Permitted", - "header.tabel.additionalPropertiesNo": "Forbidden", - "header.tabel.definedIn": "Defined In", - "examples.example": "Example", - "examples.examples": "Examples", - "definitions.definitions": "Definitions", - "definitions.tabel.property": "Property", - "definitions.tabel.type": "Type", - "definitions.tabel.group": "Group", - "propertyIs": "is", - "propertyRequired": "**required**", - "propertyOptional": "optional", - "propertyType": "type:", - "propertyNestedArray": "(nested array)", - "propertyBetween": "between", - "propertyBetweenAnd": "and", - "propertyBetweenItems": "items in the array", - "propertyBetweenMaxItemsPrefix": "no more than", - "propertyBetweenMaxItemsSuffix": "items in the array", - "propertyBetweenMinItemsPrefix": "at least", - "propertyBetweenMinItemsSuffix": "items in the array", - "propertySchemaDefault": "default", - "propertySchemaDefinedIn": "defined in", - "propertySchemaDefinedSelf": "this schema", - "propertySchemaConst": "The value of this property **must** be equal to:", - "propertySchemaEnum": "The value of this property **must** be equal to one of the [known values below](#{{enum}}-known-values).", - "propertyHeaderType": "Type", - "propertyUnknownType": "Unknown type", - "propertyEnumKnownVaules": "Known Values", - "propertyEnum.tabel.value": "Value", - "propertyEnum.tabel.description": "Description", - "propertyExample": "Example", - "propertyExamples": "Examples", - "arrayTypeNested": "Nested array type:", - "arrayTypeArray": "Array type:", - "arrayTypeList": "All items must be of the type:", - "arrayTypeUnknownType": "Unknown type", - "booleanTypeNullabel": ", nullable", - "booleanTypeEmpty": " ", - "multitpleType.types": "Either one of:", - "multitpleType.none": "or `null`", - "joinTypeAny": "**Any** following *options* needs to be fulfilled.", - "joinTypeAll": "**All** of the following *requirements* need to be fulfilled.", - "joinTypeOne": "**One** of the following *conditions* need to be fulfilled.", - "joinTypeOption": "Option", - "joinTypeRequirement": "Requirement", - "joinTypeCondition": "Condition", - "innerSchemaDefined": "**Defined In:**", - "nestedProperties.tabel.property": "Property", - "nestedProperties.tabel.type": "Type", - "nestedProperties.tabel.required": "Required", - "nestedProperties.tabel.requiredYes": "**Required**", - "nestedProperties.tabel.requiredNo": "Optional", - "nestedProperties.tabel.default": "Default", - "nestedPropertyIs": "is", - "nestedPropertyRequired": "**required**", - "nestedPropertyOptinal": "optional", - "nestedPropertyType": "type:", - "nestedPropertyTypeNestedArray": "nested array", - "nestedPropertyItemsBetween": "between", - "nestedPropertyItemsAnd": "and", - "nestedPropertyItemsBetweenEnd": "items in the array", - "nestedPropertyItemsMax": "no more than", - "nestedPropertyItemsMaxEnd": "items in the array", - "nestedPropertyItemsMin": "at least", - "nestedPropertyItemsMinEnd": "items in the array", - "nestedPropertySchemaDefault": "default:", - "nestedPropertySchemaConst": "The value of this property **must** be equal to:", - "nestedPropertyHeaderType": "Type", - "nestedPropertyUnknownType": "Unknown type", - "nestedPropertySchemaEnum": "The value of this property **must** be equal to one of the [known values below](#{{enum}}-known-values).", - "nestedPropertyEnumKnownVaules": "Known Values", - "nestedPropertyEnum.tabel.value": "Value", - "nestedPropertyEnum.tabel.description": "Description", - "nestedPropertyExample": "Example", - "nestedPropertyExamples": "Examples", - "numberTypeExclusiveMinumum": "value must not be smaller or equal than:", - "numberTypeMinimum": "minimum value:", - "numberTypeExclusiveMaximum": "value must not be greater or equal than:", - "numberTypeMaximum": "maximum value:", - "numberTypeMultipleOf": "must be a multiple of", - "objectTypeObject": "object", - "objectTypeObjectFollowing": "with following properties:", - "patternPropertyPattern": "Pattern:", - "patternPropertyExpression": "Applies to all properties that match the regular expression", - "patternPropertyIsPropertyPattern": "is a property pattern", - "patternPropertyType": "type:", - "patternPropertyNestedArray": "(nested array):", - "patternPropertyBetween": "between", - "patternPropertyBetweenAnd": "and", - "patternPropertyBetweenItems": "items in the array", - "patternPropertyMaxItemsPrefix": "no more than", - "patternPropertyMaxItemsSuffix": "items in the array", - "patternPropertyMinItemsPrefix": "at least", - "patternPropertyMinItemsSuffix": "items in the array", - "patternPropertySchemaDefault": "default:", - "patternPropertySchemaDefinedIn": "defined in", - "patternPropertySchemaDefinedSelf": "this schema", - "patternPropertySchemaConst": "The value of this property **must** be equal to:", - "patternPropertySchemaEnum": "The value of this property **must** be equal to one of the [known values below](#{{enum}}-known-values).", - "patternPropertyHeaderPattern": "Pattern", - "patternPropertyHeaderType": "Type", - "patternPropertyUnknownType": "Unknown type", - "patternPropertyEnumPattern": "Pattern", - "patternPropertyEnumKnownVaules": "Known Values", - "patternPropertyEnum.tabel.value": "Value", - "patternPropertyEnum.tabel.description": "Description", - "patternPropertyExample": "Example", - "patternPropertyPatternExamples": "Pattern", - "patternPropertyExamples": "Examples", - "propertiesTitel": "Properties", - "properties.tabel.property": "Property", - "properties.tabel.type": "Type", - "properties.tabel.required": "Required", - "properties.tabel.nullable": "Nullable", - "properties.tabel.default": "Default", - "properties.tabel.definedBy": "Defined by", - "propertiesRequired": "**Required**", - "propertiesOptional": "Optional", - "propertiesNullableYes": "Yes", - "propertiesNullableNo": "No", - "propertiesSchema": "(this schema)", - "propertiesPattern": "Pattern", - "propertiesAny": "any", - "propertiesAdditional": "Additional", - "propertiesAdditionalYes": "Yes", - "propertiesPatternAdditionalText": "this schema *allows* additional properties", - "readmeHead": "Readme", - "stringTypeUri": "format: `uri` – Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986))", - "stringTypeDateTime": "format: `date-time` – date and time (according to [RFC 3339, section 5.6](http://tools.ietf.org/html/rfc3339))", - "stringTypeEmail": "format: `email` – email address (according to [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322))", - "stringTypeIPv4": "format: `ipv4` – IP (v4) address (according to [RFC 2673, section 3.2](https://tools.ietf.org/html/rfc2673))", - "stringTypeIPv6": "format: `ipv6` – IP (v6) address (according to [RFC 4291, section 2.2](https://tools.ietf.org/html/rfc4291))", - "stringTypeDate": "format: `date` – date, without time (according to [RFC 3339, section 5.6](http://tools.ietf.org/html/rfc3339))", - "stringTypeTime": "format: `time` – time, without date (according to [RFC 3339, section 5.6](http://tools.ietf.org/html/rfc3339))", - "stringTypeIdnEmail": "format: `idn-email` – international email address (according to [RFC 6531](https://tools.ietf.org/html/rfc6531))", - "stringTypeIdnHostname": "format: `idn-hostname` – Internationalized Domain Name (according to [RFC 5890, section 2.3.2.3](https://tools.ietf.org/html/rfc5890))", - "stringTypeUriReference": "format: `uri-reference` – URI Reference (according to [RFC3986](https://tools.ietf.org/html/rfc3986))", - "stringTypeIRI": "format: `iri` – Internationalized Resource Identifier (according to [RFC3987](https://tools.ietf.org/html/rfc3987))", - "stringTypeIRIReference": "format: `iri-reference` – IRI Reference (according to [RFC3987](https://tools.ietf.org/html/rfc3987))", - "stringTypeURITemplate": "format: `uri-template` – URI Template (according to [RFC6570](https://tools.ietf.org/html/rfc6570))", - "stringTypeJSONPointer": "format: `json-pointer` – JSON Pointer (according to [RFC 6901, section 5](https://tools.ietf.org/html/rfc6901))", - "stringTypeRegex": "format: `regex` – Regular Expression (according to [ECMA 262](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf))", - "stringTypeRelativeJsonPointer": "format: `relative-json-pointer` – Relative JSON Pointer (according to [Relative JSON Pointer](http://tools.ietf.org/html/draft-handrews-relative-json-pointer-00))", - "stringTypeHostname": "format: `hostname` – Domain Name (according to [RFC 1034, section 3.1](https://tools.ietf.org/html/rfc1034))", - "stringTypeMinimum": "minimum length:", - "stringTypeMinimumCharacters": "characters", - "stringTypeMaximum": "maximum length:", - "stringTypeMaximumCharacters": "characters", - "stringTypePattern": "All instances must conform to this regular expression ", - "stringTypePatternExampleUndefined": "(test examples [here](https://regexr.com/?expression={{pattern}} )):", - "stringTypePatternExampleString": "((test example: [{{example}}](https://regexr.com/?expression={{pattern}}&text={{text}})):", - "stringTypePatternExampleNotString": "* test example: [{{example}}](https://regexr.com/?expression={{pattern}}&text={{text}})", - "nullType": "This property can only have the value `null`." -} \ No newline at end of file diff --git a/lib/locales/en_US.json b/lib/locales/en_US.json new file mode 100644 index 00000000..06c10042 --- /dev/null +++ b/lib/locales/en_US.json @@ -0,0 +1,6 @@ +{ + "locales": "en_US", + "translations": { + "${0} Schema": "Schema: ${0}" + } +} \ No newline at end of file