linguiMacro.tsx 863 B

12345678910111213141516171819202122232425262728
  1. import { MessageDescriptor } from '@lingui/core';
  2. import { Trans as OriginalTrans } from '@lingui/macro';
  3. import React from 'react';
  4. export const Trans: typeof OriginalTrans = ({ id, children }) => {
  5. return <>{children ?? id}</>;
  6. };
  7. export const Plural: React.FC = () => {
  8. throw new Error('Plural mock not implemented yet');
  9. };
  10. export const Select: React.FC = () => {
  11. throw new Error('Select mock not implemented yet');
  12. };
  13. export const SelectOrdinal: React.FC = () => {
  14. throw new Error('SelectOrdinal mock not implemented yet');
  15. };
  16. export const t = (msg: string | { message: string }) => {
  17. return typeof msg === 'string' ? msg : msg.message;
  18. };
  19. export const defineMessage = (descriptor: MessageDescriptor) => {
  20. // We return the message as the ID so we can assert on the plain english value
  21. return { ...descriptor, id: descriptor.message };
  22. };