Skip to content

Commit

Permalink
fix(suite, suite-data): call defineMessages after type-check to fix c…
Browse files Browse the repository at this point in the history
…rowdin CLI
  • Loading branch information
komret committed Dec 3, 2024
1 parent 72bb37b commit 6a194ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions packages/suite-data/src/translations/backport-en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ Object.entries(source).forEach(([key, value]) => {
fs.writeFileSync(
targetPath,
`
import { defineMessagesWithTypeCheck } from './utils';
import { defineMessages } from 'react-intl';
export default defineMessagesWithTypeCheck(${JSON.stringify(messages, null, 2).replace(/"([^"]+)":/g, '$1:')})
import { defineMessagesWithTypeCheck } from './defineMessagesWithTypeCheck';
const messages = defineMessagesWithTypeCheck(${JSON.stringify(messages, null, 2).replace(/"([^"]+)":/g, '$1:')})
export default defineMessages(messages);
`,
);
Expand Down
4 changes: 1 addition & 3 deletions packages/suite/src/support/defineMessagesWithTypeCheck.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { defineMessages } from 'react-intl';

type MessageDescriptor<K extends string> = {
// Must correspond to the property name.
id: K;
Expand All @@ -16,4 +14,4 @@ Checks whether id corresponds to the property name. Otherwise, text is not trans
*/
export const defineMessagesWithTypeCheck = <Key extends string>(messages: {
[K in Key]: MessageDescriptor<K>;
}) => defineMessages(messages);
}) => messages;
6 changes: 5 additions & 1 deletion packages/suite/src/support/messages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { defineMessages } from 'react-intl';

import { defineMessagesWithTypeCheck } from './defineMessagesWithTypeCheck';

export default defineMessagesWithTypeCheck({
const messages = defineMessagesWithTypeCheck({
TR_404_DESCRIPTION: {
defaultMessage: 'Looks like a wrong URL or broken link.',
id: 'TR_404_DESCRIPTION',
Expand Down Expand Up @@ -9265,3 +9267,5 @@ export default defineMessagesWithTypeCheck({
defaultMessage: 'Trezor Connect',
},
});

export default defineMessages(messages);

0 comments on commit 6a194ef

Please sign in to comment.