What you expected to happen :
Use the extra translations for external standards provided in the schema repositories (see CAMPUS example in CoA-schema ).
Those translations will go beyond the current translations located at the root of schemas repositories that only translates properties known in the schema.
They will only be loaded if the standards are declared in the certificate and once loaded, they can be used in the generators (HTML and PDF) by matching the PropertyId value from the certificate to the corresponding Id from a translation object.
[x] Resolve the extra translations located under the pattern path https://schemas.s1seven.com/coa-schemas/v0.1.0/<extra-translation>/<language>.json
load dynamically the URL path parameter(s) ( eg: <extra-translation>) based on property(ies) path, using lodash.get
example : passing Certificate.Analysis.PropertiesStandards from a certificate using the CoA-schema would get the specification CAMPUS (if is defined of course).
consider that translations from multiple external standards could need to be loaded.
compose our URL to fetch those translations using getTranslations as a base. It should create URLs with the pattern https://schemas.s1seven.com/coa-schemas/v0.1.0/<extra-translation>/<language>.json
[x] Update translations types and compose a new object to store loaded translations
export type CampusTranslations = {
[key in Languages]?: { Id: string; Property: string; TestConditions?: string }[];
};
export type ExternalStandardsTranslations = {
};
export type ExtraTranslations = {
[key in ExternalStandards]?: ExternalStandardsTranslations[key];
};
// once downloaded external standards translations downloaded we would get an object like :
const extraTranslations: ExtraTranslations = {
CAMPUS: { EN: [{ Id: '38', Property: 'Melt volume-flow rate', TestConditions: 'MVR' },...] },
};
// ... from which we can safely retrieve a given standard translations
const campusTranslations: CampusTranslations = t.CAMPUS;
- [x] allow to provide `extraTranslations` from the generator options
- [x] within handlebarsBaseOptions, define a custom helper to handle extraTranslations.
- This custom helper would use the `CertificateLanguages`, the `PropertyId` and the `<propertyName>` to replace.
- if `<propertyName>` does not exist in the translations, resolve the `<propertyName>` in the certificate object as fallback
- [x] Edit template.hbs to use the new helper function
Description
Is this a BUG REPORT or FEATURE REQUEST ? FEATURE
What you expected to happen : Use the extra translations for external standards provided in the schema repositories (see CAMPUS example in CoA-schema ). Those translations will go beyond the current translations located at the root of schemas repositories that only translates properties known in the schema. They will only be loaded if the standards are declared in the certificate and once loaded, they can be used in the generators (HTML and PDF) by matching the
PropertyId
value from the certificate to the correspondingId
from a translation object.[x] Resolve the extra translations located under the pattern path
https://schemas.s1seven.com/coa-schemas/v0.1.0/<extra-translation>/<language>.json
<extra-translation>
) based on property(ies) path, using lodash.get example : passingCertificate.Analysis.PropertiesStandards
from a certificate using the CoA-schema would get the specificationCAMPUS
(if is defined of course).getTranslations
as a base. It should create URLs with the patternhttps://schemas.s1seven.com/coa-schemas/v0.1.0/<extra-translation>/<language>.json
[x] Update translations types and compose a new object to store loaded translations
export type CampusTranslations = { [key in Languages]?: { Id: string; Property: string; TestConditions?: string }[]; };
export type ExternalStandardsTranslations = {
};
export type ExtraTranslations = { [key in ExternalStandards]?: ExternalStandardsTranslations[key]; };
// once downloaded external standards translations downloaded we would get an object like : const extraTranslations: ExtraTranslations = { CAMPUS: { EN: [{ Id: '38', Property: 'Melt volume-flow rate', TestConditions: 'MVR' },...] }, }; // ... from which we can safely retrieve a given standard translations const campusTranslations: CampusTranslations = t.CAMPUS;