From 6c27cc350570d61b9000782eff3befaa898b029a Mon Sep 17 00:00:00 2001 From: AlexisG Date: Wed, 12 Apr 2023 12:59:26 +0200 Subject: [PATCH] feat: Add pluralization to the qualification labels BREAKING CHANGE: getBoundT: With the arrival of pluralization, the return of this function has been updated The second parameter, to indicate the country, is no longer of String type. Before, we use this implementation: ``` const t = getBoundT(lang) t("translation.key", "fr" ) ``` Now please follow the following example: ``` const t = getBoundT(lang) t("translation.key", { country: "fr" }) ``` For pluralization, just add the `smart_count` option ``` t("translation.key", { country: "fr", smart_count: 2 }) ``` The `Items.invoices` translation key has been removed, its value has been added to the `Items.invoice` key in its plural version. Please use this new implementation: ``` t("Items.invoice", { smart_count: 2 }) ``` The following translation keys are no longer plural by default. `Items.other_revenue`, `Items.unemployment_benefit`, `Items.personal_sporting_licence`, `Items.tax_timetable`. Please use this new implementation: ``` t("translation.key", { smart_count: 2 }) --- .../modules/models.document.locales.md | 10 +- .../src/models/document/locales/en.json | 169 +++++++++--------- .../src/models/document/locales/fr.json | 157 ++++++++-------- .../src/models/document/locales/index.js | 13 +- .../src/models/document/locales/index.spec.js | 30 +++- .../types/models/document/locales/index.d.ts | 7 +- 6 files changed, 205 insertions(+), 181 deletions(-) diff --git a/docs/api/cozy-client/modules/models.document.locales.md b/docs/api/cozy-client/modules/models.document.locales.md index 531f46d4ef..53eae44121 100644 --- a/docs/api/cozy-client/modules/models.document.locales.md +++ b/docs/api/cozy-client/modules/models.document.locales.md @@ -8,7 +8,7 @@ ### getBoundT -▸ **getBoundT**(`lang`): (`label`: `string`, `country?`: `string`) => `string` +▸ **getBoundT**(`lang`): (`label`: `string`, `opts?`: { `country?`: `string` ; `smart_count?`: `number` }) => `string` *Parameters* @@ -20,14 +20,18 @@ `fn` -▸ (`label`, `country?`): `string` +) => string} + +▸ (`label`, `opts?`): `string` *Parameters* | Name | Type | | :------ | :------ | | `label` | `string` | -| `country?` | `string` | +| `opts?` | `Object` | +| `opts.country?` | `string` | +| `opts.smart_count?` | `number` | *Returns* diff --git a/packages/cozy-client/src/models/document/locales/en.json b/packages/cozy-client/src/models/document/locales/en.json index afc3ad97a1..83a4dbc018 100644 --- a/packages/cozy-client/src/models/document/locales/en.json +++ b/packages/cozy-client/src/models/document/locales/en.json @@ -19,98 +19,97 @@ "qualified_ok": "You just have successfully described your file! " }, "items": { - "accommodation_proof": "Proof of accommodation", - "appliance_invoice": "Appliance invoice", + "accommodation_proof": "Proof of accommodation |||| Proof of accommodations", + "appliance_invoice": "Appliance invoice |||| Appliance invoices", "bank_details": "IBAN", - "bank_statement": "Bank statement", - "birth_certificate": "Birth certificate", - "building_permit": "Building permit", - "caf": "Social benefit rate", - "car_insurance": "Car insurance certificate", - "citizen_registration_certificate": "Certificate of citizen registration", - "diploma": "Diploma", - "divorce": "Divorce", - "driver_license": "Driving license", - "electoral_card": "Electoral card", - "employment_center_certificate": "Employment center certificate", - "energy_contract": "Energy provider contract", - "energy_invoice": "Energy invoice", - "family_record_book": "Family record book", + "bank_statement": "Bank statement |||| Bank statements", + "birth_certificate": "Birth certificate |||| Birth certificates", + "building_permit": "Building permit |||| Building permits", + "caf": "Social benefit rate |||| Social benefit rates", + "car_insurance": "Car insurance certificate |||| Car insurance certificates", + "citizen_registration_certificate": "Certificate of citizen registration |||| Certificates of citizen registration", + "diploma": "Diploma |||| Diplomas", + "divorce": "Divorce |||| Divorces", + "driver_license": "Driving license |||| Driving licenses", + "electoral_card": "Electoral card |||| Electoral cards", + "employment_center_certificate": "Employment center certificate |||| Employment center certificates", + "energy_contract": "Energy provider contract |||| Energy provider contracts", + "energy_invoice": "Energy invoice |||| Energy invoices", + "family_record_book": "Family record book |||| Family record books", "family": "Family", - "fidelity_card": "Fidelity card", - "gradebook": "Gradebook", - "grocery_invoice": "Grocery invoice", - "health_book": "Health book", - "health_certificate": "Health/Vaccination certificate", - "health_insurance_card": "Insurance card", - "health_invoice": "Health invoice", + "fidelity_card": "Fidelity card |||| Fidelity cards", + "gradebook": "Gradebook |||| Gradebooks", + "grocery_invoice": "Grocery invoice |||| Grocery invoices", + "health_book": "Health book |||| Health books", + "health_certificate": "Health/Vaccination certificate |||| Health/Vaccination certificates", + "health_insurance_card": "Insurance card |||| Insurance cards", + "health_invoice": "Health invoice |||| Health invoices", "health": "Health", "home": "Home", - "house_insurance": "Home insurance", - "house_sale_agreeement": "House sale agreement", - "identity_photo": "Identity photo", + "house_insurance": "Home insurance |||| Home insurances", + "house_sale_agreeement": "House sale agreement |||| House sale agreements", + "identity_photo": "Identity photo |||| Identity photos", "identity": "Identity", - "invoice": "Invoice", - "invoices": "Invoices", - "isp_invoice": "ISP invoice", - "large_family_card": " Large Family Card", - "lease": "Lease", - "library_card": "library card", - "loan_agreement": "Loan agreement", - "mechanic_invoice": "Repair bill", - "motivation_letter": "Motivation letter", - "national_health_insurance_card": "National health insurance card", - "national_health_insurance_right_certificate": "National health insurance right certificate", - "national_id_card": "ID card", - "other_activity_document": "Other sports document", - "other_bank_document": "Other banking document", - "other_family_document": "Other family document", - "other_health_document": "Other health document", - "other_house_document": "Other house document", - "other_identity_document": "Other document of identity", - "other_invoice": "Other invoice", - "other_revenue": "Other revenues", - "other_tax_document": "Other tax document", - "other_transport_document": "Other transport document", - "other_work_document": "Other work document", + "invoice": "Invoice |||| Invoices", + "isp_invoice": "ISP invoice |||| ISP invoices", + "large_family_card": " Large Family Card |||| Large Family Cards", + "lease": "Lease |||| Leases", + "library_card": "library card |||| library cards", + "loan_agreement": "Loan agreement |||| Loan agreements", + "mechanic_invoice": "Repair bill |||| Repair bills", + "motivation_letter": "Motivation letter |||| Motivation letters", + "national_health_insurance_card": "National health insurance card |||| National health insurance cards", + "national_health_insurance_right_certificate": "National health insurance right certificate |||| National health insurance right certificates", + "national_id_card": "ID card |||| ID cards", + "other_activity_document": "Other sports document |||| Other sports documents", + "other_bank_document": "Other banking document |||| Other banking documents", + "other_family_document": "Other family document |||| Other family documents", + "other_health_document": "Other health document |||| Other health documents", + "other_house_document": "Other house document |||| Other house documents", + "other_identity_document": "Other document of identity |||| Other documents of identity", + "other_invoice": "Other invoice |||| Other invoices", + "other_revenue": "Other revenue |||| Other revenues", + "other_tax_document": "Other tax document |||| Other tax documents", + "other_transport_document": "Other transport document |||| Other transport documents", + "other_work_document": "Other work document |||| Other work documents", "others": "Others", - "pacs": "Civil union", - "passport": "Passeport", - "pay_sheet": "Pay sheet", - "payment_proof_family_allowance": "family allowance payment proof", - "pension": "Pension", - "personal_sporting_licence": "Sporting licence", - "phone_invoice": "Phone invoice", - "pregnancy_medical_certificate": "Certificate of pregnancy", - "prescription": "Prescription", - "real_estate_tax": "Real estate tax", - "receipt": "Receipt", - "rent_receipt": "Rent receipt", - "residence_permit": "Residence permit", - "restaurant_invoice": "Restaurant invoice", - "resume": "Resume", - "school_attendance_certificate": "Certificate of school attendance", - "school_insurance_certificate": "Certificate of school insurance", - "single_parent_benefit": "Single parent benefit", - "student_card": "Student card", - "tax_notice": "Tax notice", - "tax_return": "Tax return", - "tax_timetable": "Payment Plans Installment Agreements", - "technical_diagnostic_record": "Technical diagnostic record", - "telecom_invoice": "Telecom invoice", - "transport_card": "Transport card", - "transport_invoice": "Transport invoice", + "pacs": "Civil union |||| Civil unions", + "passport": "Passeport |||| Passeports", + "pay_sheet": "Pay sheet |||| Pay sheets", + "payment_proof_family_allowance": "family allowance payment proof |||| family allowance payment proofs", + "pension": "Pension |||| Pensions", + "personal_sporting_licence": "Sporting licence |||| Sporting licences", + "phone_invoice": "Phone invoice |||| Phone invoices", + "pregnancy_medical_certificate": "Certificate of pregnancy |||| Certificates of pregnancy", + "prescription": "Prescription |||| Prescriptions", + "real_estate_tax": "Real estate tax |||| Real estate taxes", + "receipt": "Receipt |||| Receipts", + "rent_receipt": "Rent receipt |||| Rent receipts", + "residence_permit": "Residence permit |||| Residence permits", + "restaurant_invoice": "Restaurant invoice |||| Restaurant invoices", + "resume": "Resume |||| Resumes", + "school_attendance_certificate": "Certificate of school attendance |||| Certificates of school attendance", + "school_insurance_certificate": "Certificate of school insurance |||| Certificates of school insurance", + "single_parent_benefit": "Single parent benefit |||| Single parent benefits", + "student_card": "Student card |||| Student cards", + "tax_notice": "Tax notice |||| Tax notices", + "tax_return": "Tax return |||| Tax returns", + "tax_timetable": "Payment Plans Installment Agreement |||| Payment Plans Installment Agreements", + "technical_diagnostic_record": "Technical diagnostic record |||| Technical diagnostic records", + "telecom_invoice": "Telecom invoice |||| Telecom invoices", + "transport_card": "Transport card |||| Transport cards", + "transport_invoice": "Transport invoice |||| Transport invoices", "transport": "Transport", - "unemployment_benefit": "Unemployment benefit", - "unfit_for_habitation_declaration": "Declaration of unfit for habitation", - "vehicle_registration": "Vehicle registration", - "water_invoice": "Water invoice", - "web_service_invoice": "Web service invoice", - "wedding": "Wedding contract", - "work_contract": "Work contract", - "work_disability_recognition": "Recognition of disability", - "work_invoice": "Work invoice", - "work_quote": "Work quote", + "unemployment_benefit": "Unemployment benefit |||| Unemployment benefits", + "unfit_for_habitation_declaration": "Declaration of unfit for habitation |||| Declarations of unfit for habitation", + "vehicle_registration": "Vehicle registration |||| Vehicle registrations", + "water_invoice": "Water invoice |||| Water invoices", + "web_service_invoice": "Web service invoice |||| Web service invoices", + "wedding": "Wedding contract |||| Wedding contracts", + "work_contract": "Work contract |||| Work contracts", + "work_disability_recognition": "Recognition of disability |||| Recognitions of disability", + "work_invoice": "Work invoice |||| Work invoices", + "work_quote": "Work quote |||| Work quotes", "work_study": "Work & Study" }, "attributes":{ diff --git a/packages/cozy-client/src/models/document/locales/fr.json b/packages/cozy-client/src/models/document/locales/fr.json index fe6fb16f49..67e9ce3449 100644 --- a/packages/cozy-client/src/models/document/locales/fr.json +++ b/packages/cozy-client/src/models/document/locales/fr.json @@ -19,97 +19,96 @@ "qualified_ok": "Vous venez de qualifier votre fichier avec succès !" }, "items": { - "accommodation_proof": "Attestation d'hébergement", - "appliance_invoice": "Facture d'électroménager", + "accommodation_proof": "Attestation d'hébergement |||| Attestations d'hébergement", + "appliance_invoice": "Facture d'électroménager |||| Factures d'électroménager", "bank_details": "IBAN", - "bank_statement": "Relevé de compte", - "birth_certificate": "Certificat de naissance", + "bank_statement": "Relevé de compte |||| Relevés de compte", + "birth_certificate": "Certificat de naissance |||| Certificats de naissance", "building_permit": "Permis de construire", - "caf": "Attestation de quotient familial (CAF)", - "car_insurance": "Attestation d'assurance auto", - "citizen_registration_certificate": "Attestation de recensement citoyen", - "diploma": "Diplôme", - "divorce": "Attestation de divorce", + "caf": "Attestation de quotient familial (CAF) |||| Attestations de quotient familial (CAF)", + "car_insurance": "Attestation d'assurance auto |||| Attestations d'assurance auto", + "citizen_registration_certificate": "Attestation de recensement citoyen |||| Attestations de recensement citoyen", + "diploma": "Diplôme |||| Diplômes", + "divorce": "Attestation de divorce |||| Attestations de divorce", "driver_license": "Permis", - "electoral_card": "Carte électorale", - "employment_center_certificate": "Attestation de Pôle emploi", - "energy_contract": "Contrat de fournisseur d'énergies", - "energy_invoice": "Facture d'énergie", - "family_record_book": "Livret de famille", + "electoral_card": "Carte électorale |||| Cartes électorales", + "employment_center_certificate": "Attestation de Pôle emploi |||| Attestations de Pôle emploi", + "energy_contract": "Contrat de fournisseur d'énergies |||| Contrats de fournisseur d'énergies", + "energy_invoice": "Facture d'énergie |||| Factures d'énergie", + "family_record_book": "Livret de famille |||| Livrets de famille", "family": "Famille", - "fidelity_card": "Carte de fidélité", - "gradebook": "Bulletin de notes", - "grocery_invoice": "Facture de courses", - "health_book": "Carnet de santé", - "health_certificate": "Certificat de santé/vaccination", - "health_insurance_card": "Carte de mutuelle", - "health_invoice": "Facture médicale", + "fidelity_card": "Carte de fidélité |||| Cartes de fidélité", + "gradebook": "Bulletin de notes |||| Bulletins de notes", + "grocery_invoice": "Facture de courses |||| Factures de courses", + "health_book": "Carnet de santé |||| Carnets de santé", + "health_certificate": "Certificat de santé/vaccination |||| Certificats de santé/vaccination", + "health_insurance_card": "Carte de mutuelle |||| Cartes de mutuelle", + "health_invoice": "Facture médicale |||| Factures médicales", "health": "Santé", "home": "Logement", - "house_insurance": "Assurance logement", + "house_insurance": "Assurance logement |||| Assurances logement", "house_sale_agreeement": "Compromis de vente", - "identity_photo": "Photo d'identité", + "identity_photo": "Photo d'identité |||| Photos d'identité", "identity": "Identité", - "invoice": "Factures", - "invoices": "Factures", - "isp_invoice": "Facture d'internet", - "large_family_card": "Carte famille nombreuse", - "lease": "Bail", - "library_card": "Carte de bibliothèque", - "loan_agreement": "Contrat de prêt", - "mechanic_invoice": "Facture de réparation", - "motivation_letter": "Lettre de motivation", - "national_health_insurance_card": "Carte vitale", - "national_health_insurance_right_certificate": "Attestation de droits de l'Assurance Maladie (vitale)", - "national_id_card": "Carte d'identité", - "other_activity_document": "Autre document sportif", - "other_bank_document": "Autre document bancaire", - "other_family_document": "Autre document de famille", - "other_health_document": "Autre document de santé", - "other_house_document": "Autre document de logement", - "other_identity_document": "Autre document d'identité", - "other_invoice": "Autre facture", - "other_revenue": "Autres revenus", - "other_tax_document": "Impôts - Autre document", - "other_transport_document": "Autre document de transport", - "other_work_document": "Autre document de travail", + "invoice": "Facture |||| Factures", + "isp_invoice": "Facture d'internet |||| Factures d'internet", + "large_family_card": "Carte famille nombreuse |||| Cartes famille nombreuse", + "lease": "Bail |||| Baux", + "library_card": "Carte de bibliothèque |||| Cartes de bibliothèque", + "loan_agreement": "Contrat de prêt |||| Contrats de prêt", + "mechanic_invoice": "Facture de réparation |||| Factures de réparation", + "motivation_letter": "Lettre de motivation |||| Lettres de motivation", + "national_health_insurance_card": "Carte vitale |||| Cartes vitales", + "national_health_insurance_right_certificate": "Attestation de droits de l'Assurance Maladie (vitale) |||| Attestations de droits de l'Assurance Maladie (vitale)", + "national_id_card": "Carte d'identité |||| Cartes d'identité", + "other_activity_document": "Autre document sportif |||| Autres documents sportifs", + "other_bank_document": "Autre document bancaire |||| Autres documents bancaires", + "other_family_document": "Autre document de famille |||| Autres documents de famille", + "other_health_document": "Autre document de santé |||| Autres documents de santé", + "other_house_document": "Autre document de logement |||| Autres documents de logement", + "other_identity_document": "Autre document d'identité |||| Autres documents d'identité", + "other_invoice": "Autre facture |||| Autres factures", + "other_revenue": "Autre revenu |||| Autres revenus", + "other_tax_document": "Impôts - Autre document |||| Impôts - Autres documents", + "other_transport_document": "Autre document de transport |||| Autres documents de transport", + "other_work_document": "Autre document de travail |||| Autres documents de travail", "others": "Autres", - "pacs": "Attestation de PACS", - "passport": "Passeport", - "pay_sheet": "Fiche de paie", - "payment_proof_family_allowance": "Attestation de paiement CAF", - "pension": "Retraite", - "personal_sporting_licence": "Licences sportives", - "phone_invoice": "Facture de téléphone", - "pregnancy_medical_certificate": "Certificat de grossesse", - "prescription": "Ordonnance", - "real_estate_tax": "Taxe foncière", - "receipt": "Accusé de réception", - "rent_receipt": "Quittance de loyer", - "residence_permit": "Titre de séjour", - "restaurant_invoice": "Facture de restaurant", + "pacs": "Attestation de PACS |||| Attestations de PACS", + "passport": "Passeport |||| Passeports", + "pay_sheet": "Fiche de paie |||| Fiches de paie", + "payment_proof_family_allowance": "Attestation de paiement CAF |||| Attestations de paiement CAF", + "pension": "Retraite |||| Retraites", + "personal_sporting_licence": "Licence sportive |||| Licences sportives", + "phone_invoice": "Facture de téléphone |||| Factures de téléphone", + "pregnancy_medical_certificate": "Certificat de grossesse |||| Certificats de grossesse", + "prescription": "Ordonnance |||| Ordonnances", + "real_estate_tax": "Taxe foncière |||| Taxes foncières", + "receipt": "Accusé de réception |||| Accusés de réception", + "rent_receipt": "Quittance de loyer |||| Quittances de loyer", + "residence_permit": "Titre de séjour |||| Titres de séjour", + "restaurant_invoice": "Facture de restaurant |||| Factures de restaurant", "resume": "CV", - "school_attendance_certificate": "Certificat de scolarité", - "school_insurance_certificate": "Attestation d'assurance scolaire", - "single_parent_benefit": "Allocation parent isolé", - "student_card": "Carte d'étudiant", + "school_attendance_certificate": "Certificat de scolarité |||| Certificats de scolarité", + "school_insurance_certificate": "Attestation d'assurance scolaire |||| Attestations d'assurance scolaire", + "single_parent_benefit": "Allocation parent isolé |||| Allocations parent isolé", + "student_card": "Carte d'étudiant |||| Cartes d'étudiant", "tax_notice": "Impôts - Avis d'imposition", - "tax_return": "Impôts - Déclaration de revenus", - "tax_timetable": "Impôts - Echéancier", - "technical_diagnostic_record": "Dossier de diagnostic technique", - "telecom_invoice": "Facture de télécom", - "transport_card": "Carte de transport", - "transport_invoice": "Facture de transport", + "tax_return": "Impôts - Déclaration de revenus |||| Impôts - Déclarations de revenus", + "tax_timetable": "Impôts - Echéancier |||| Impôts - Echéanciers", + "technical_diagnostic_record": "Dossier de diagnostic technique |||| Dossiers de diagnostic technique", + "telecom_invoice": "Facture de télécom |||| Factures de télécom", + "transport_card": "Carte de transport |||| Cartes de transport", + "transport_invoice": "Facture de transport |||| Factures de transport", "transport": "Transport", - "unemployment_benefit": "Allocations chômage", - "unfit_for_habitation_declaration": "Arrêté d'insalubrité", - "vehicle_registration": "Carte grise", - "water_invoice": "Facture d'eau", - "web_service_invoice": "Facture de service web", - "wedding": "Contrat de mariage", - "work_contract": "Contrat de travail", - "work_disability_recognition": "Reconnaissance de handicap - RQTH", - "work_invoice": "Facture de travaux", + "unemployment_benefit": "Allocation chômage |||| Allocations chômage", + "unfit_for_habitation_declaration": "Arrêté d'insalubrité |||| Arrêtés d'insalubrité", + "vehicle_registration": "Carte grise |||| Cartes grises", + "water_invoice": "Facture d'eau |||| Factures d'eau", + "web_service_invoice": "Facture de service web |||| Factures de service web", + "wedding": "Contrat de mariage |||| Contrats de mariage", + "work_contract": "Contrat de travail |||| Contrats de travail", + "work_disability_recognition": "Reconnaissance de handicap - RQTH |||| Reconnaissances de handicap - RQTH", + "work_invoice": "Facture de travaux |||| Factures de travaux", "work_quote": "Devis de travaux", "work_study": "Travail & Études" }, diff --git a/packages/cozy-client/src/models/document/locales/index.js b/packages/cozy-client/src/models/document/locales/index.js index 4448dc0a5c..97fca74015 100644 --- a/packages/cozy-client/src/models/document/locales/index.js +++ b/packages/cozy-client/src/models/document/locales/index.js @@ -18,16 +18,21 @@ for (const lang of langs) { /** * @param {string} lang - fr, en, etc - * @returns {(label: string, country?: string) => string} + * @returns {(label: string, opts?: {country?: string, smart_count?: number}) => string} */ const getBoundT = lang => { const polyglot = polyglots[lang] || polyglots['en'] const t = polyglot.t.bind(polyglot) - return (label, country) => { - const emojiCountry = getEmojiByCountry(country, t) + return (label, opts = {}) => { + const newOpts = { + smart_count: opts?.smart_count || 1 + } + const emojiCountry = getEmojiByCountry(opts?.country, t) - return emojiCountry ? `${t(label)} (${emojiCountry})` : t(label) + return emojiCountry + ? `${t(label, newOpts)} (${emojiCountry})` + : t(label, newOpts) } } diff --git a/packages/cozy-client/src/models/document/locales/index.spec.js b/packages/cozy-client/src/models/document/locales/index.spec.js index 1f618a3627..b6b36ecd24 100644 --- a/packages/cozy-client/src/models/document/locales/index.spec.js +++ b/packages/cozy-client/src/models/document/locales/index.spec.js @@ -3,19 +3,33 @@ import { getBoundT } from './index' describe('getBoundT', () => { const t = getBoundT('en') - it('should return "ID card" without suffix', () => { + it('should return singular translation by default (without options param)', () => { const res = t('Scan.items.national_id_card') expect(res).toBe('ID card') }) - it('should return "ID card" with "(Stranger)" suffix', () => { - const res = t('Scan.items.national_id_card', 'stranger') + it('should return translation if it has no pluralization pipes', () => { + const res = t('Scan.items.bank_details') - expect(res).toBe('ID card (Stranger)') + expect(res).toBe('IBAN') }) - it('should return "ID card" with "🇫🇷" suffix', () => { - const res = t('Scan.items.national_id_card', 'fr') - expect(res).toBe('ID card (🇫🇷)') - }) + it.each` + translationKey | country | smart_count | lang | expected + ${'Scan.items.national_id_card'} | ${undefined} | ${undefined} | ${'en'} | ${'ID card'} + ${'Scan.items.national_id_card'} | ${'fr'} | ${undefined} | ${'en'} | ${'ID card (🇫🇷)'} + ${'Scan.items.national_id_card'} | ${'stranger'} | ${undefined} | ${'en'} | ${'ID card (Stranger)'} + ${'Scan.items.national_id_card'} | ${'fr'} | ${1} | ${'en'} | ${'ID card (🇫🇷)'} + ${'Scan.items.national_id_card'} | ${'fr'} | ${2} | ${'en'} | ${'ID cards (🇫🇷)'} + ${'Scan.items.national_id_card'} | ${undefined} | ${1} | ${'en'} | ${'ID card'} + ${'Scan.items.national_id_card'} | ${undefined} | ${2} | ${'en'} | ${'ID cards'} + `( + 'should test if the translation is suitable with the param country: $country and with the param smart_count: $smart_count', + ({ translationKey, country, smart_count, lang, expected }) => { + const t = getBoundT(lang) + const res = t(translationKey, { country, smart_count }) + + expect(res).toBe(expected) + } + ) }) diff --git a/packages/cozy-client/types/models/document/locales/index.d.ts b/packages/cozy-client/types/models/document/locales/index.d.ts index cb3217ee78..bf691cae5d 100644 --- a/packages/cozy-client/types/models/document/locales/index.d.ts +++ b/packages/cozy-client/types/models/document/locales/index.d.ts @@ -1,5 +1,8 @@ /** * @param {string} lang - fr, en, etc - * @returns {(label: string, country?: string) => string} + * @returns {(label: string, opts?: {country?: string, smart_count?: number}) => string} */ -export function getBoundT(lang: string): (label: string, country?: string) => string; +export function getBoundT(lang: string): (label: string, opts?: { + country?: string; + smart_count?: number; +}) => string;