Skip to content

Commit

Permalink
feat(paper): Format other metadata qualification in cozy-client
Browse files Browse the repository at this point in the history
Was previously on cozy-ui. Now mutualized.
  • Loading branch information
zatteo committed Mar 12, 2024
1 parent ba1339d commit e1be6bc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/cozy-client/src/models/document/locales/en.json
Expand Up @@ -225,6 +225,11 @@
},
"day": "day |||| days"
},
"contact": "Owner",
"page": "Side of the document",
"front": "Front side",
"back": "Back side",
"qualification": "Qualification",
"noInfo": "No information"
}
},
Expand Down
5 changes: 5 additions & 0 deletions packages/cozy-client/src/models/document/locales/fr.json
Expand Up @@ -225,6 +225,11 @@
},
"day": "jour |||| jours"
},
"contact": "Titulaire",
"page": "Face du document",
"front": "Face avant",
"back": "Face arrière",
"qualification": "Qualification",
"noInfo": "Non renseigné(e)"
}
},
Expand Down
29 changes: 29 additions & 0 deletions packages/cozy-client/src/models/paper.js
Expand Up @@ -378,3 +378,32 @@ export const formatInformationMetadataValue = (

return value
}

/**
* @param {string} name - The name of a metadata of type other like 'page' or 'qualification'
* @param {Object} options - Options
* @param {string} options.lang - Lang requested for the translation
* @returns {string} Translated name for the metadata
*/
export const getTranslatedNameForOtherMetadata = (name, { lang }) => {
const t = getLocalizer(lang)

return t(`Scan.qualification.${name}`)
}

/**
* @param {string} value - The value of a metadata of type other
* @param {Object} options - Options
* @param {string} options.lang - Lang requested for the translation
* @param {string} options.name - The name of the metadata
* @returns {string} Formatted and translated value for the metadata
*/
export const formatOtherMetadataValue = (value, { lang, name }) => {
const t = getLocalizer(lang)

if (name === 'qualification') {
return t(`Scan.items.${value}`, { smart_count: 1 })
} else {
return t(`Scan.qualification.${value}`)
}
}

0 comments on commit e1be6bc

Please sign in to comment.