From 7c211b05870ebe29d731eff7b7a0d10e70bd1f90 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:00:09 +0100 Subject: [PATCH] munge the emoji names from rust-sdk to match translations (#11168) --- .../views/verification/VerificationShowSas.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/views/verification/VerificationShowSas.tsx b/src/components/views/verification/VerificationShowSas.tsx index 27ec1f0e18..67f137dde7 100644 --- a/src/components/views/verification/VerificationShowSas.tsx +++ b/src/components/views/verification/VerificationShowSas.tsx @@ -42,8 +42,19 @@ interface IState { cancelling?: boolean; } +/** Convert the names of emojis returned by the js-sdk into the display names, which we use as + * a base for our translations. + */ function capFirst(s: string): string { - return s.charAt(0).toUpperCase() + s.slice(1); + // Our translations (currently) have names like "Thumbs up". + // + // With legacy crypto, the js-sdk returns lower-case names ("thumbs up"). With Rust crypto, the js-sdk follows + // the spec and returns title-case names ("Thumbs Up"). So, to convert both into names that match our i18n data, + // we upcase the first character and downcase the rest. + // + // Once legacy crypto is dead, we could consider getting rid of this and just making the i18n data use the + // title-case names (which would also match the spec). + return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase(); } export default class VerificationShowSas extends React.Component {