Skip to content
Discussion options

You must be logged in to vote

Hey @vabyars

Here is another solution:

import { enu, insert, type Dictionary } from 'intlayer';

const content = {
  key: 'ranking_component',
  content: {
    ordinal: enu({
      1: insert('{{count}}st place'),
      2: insert('{{count}}nd place'),
      3: insert('{{count}}rd place'),
      'fallback': insert('{{count}}th place'),
    }),
  },
} satisfies Dictionary;

export default content;
const { ordinal } = useIntlayer('ranking_component');

const value = 5
const lastDigit = Math.abs(count) % 10

return <>{ordinal(lastDigit)({ count })}</>

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@vabyars
Comment options

Answer selected by vabyars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants