How to use @lingui/macro - 10 common examples

To help you get started, we’ve selected a few @lingui/macro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / lingui__macro / lingui__macro-tests.tsx View on Github external
} from '@lingui/macro';

// JS
const age = 12;
const templateResult: MessageDescriptor = t`${age} years old`;
const templateIdResult: MessageDescriptor = t('templateId')`${age} years old`;

const count = 42;

const pluralResult: MessageDescriptor = plural({
    value: count,
    0: 'no books',
    one: '# book',
    other: '# books'
});
const pluralIdResult: MessageDescriptor = plural('pluralId', {
    value: count,
    0: 'no books',
    one: '# book',
    other: '# books'
});

const selectOrdinalResult: MessageDescriptor = selectOrdinal({
    value: count,
    0: 'Zeroth book',
    one: '#st book',
    two: '#nd book',
    few: '#rd book',
    other: '#th book'
});
const selectOrdinalIdResult: MessageDescriptor = selectOrdinal('selectOrdinalId', {
    value: count,
github DefinitelyTyped / DefinitelyTyped / types / lingui__macro / lingui__macro-tests.tsx View on Github external
Trans,
    Plural,
    Select,
    SelectOrdinal,
    DateFormat,
    NumberFormat
} from '@lingui/macro';

// JS
const age = 12;
const templateResult: MessageDescriptor = t`${age} years old`;
const templateIdResult: MessageDescriptor = t('templateId')`${age} years old`;

const count = 42;

const pluralResult: MessageDescriptor = plural({
    value: count,
    0: 'no books',
    one: '# book',
    other: '# books'
});
const pluralIdResult: MessageDescriptor = plural('pluralId', {
    value: count,
    0: 'no books',
    one: '# book',
    other: '# books'
});

const selectOrdinalResult: MessageDescriptor = selectOrdinal({
    value: count,
    0: 'Zeroth book',
    one: '#st book',
github DefinitelyTyped / DefinitelyTyped / types / lingui__macro / lingui__macro-tests.tsx View on Github external
const guest = 'Bob';
const selectResult = select({
    value: gender,
    female: plural({
        value: numOfGuests,
        offset: 1,
        0: `${host} does not give a party.`,
        1: `${host} invites ${guest} to her party.`,
        2: `${host} invites ${guest} and one other person to her party.`,
        other: `${host} invites ${guest} and # other people to her party.`
    }),
    male: 'male',
    other: 'other'
});

const selectIdResult = select('selectId', {
    value: gender,
    female: 'female',
    male: 'male',
    other: 'other'
});

const formattedDate: MessageDescriptor = date(new Date(), { timeZone: 'UTC' });
const formattedNumber: MessageDescriptor = number(1234.56, { style: 'currency', currency: 'EUR' });

// JSX
const App = () => {
    const name = 'Ken';
    const numBooks = 58;
    const gender = 'male';
    const price = 21.35;
    const lastLogin = new Date();
github DefinitelyTyped / DefinitelyTyped / types / lingui__macro / lingui__macro-tests.tsx View on Github external
1: `${host} invites ${guest} to her party.`,
        2: `${host} invites ${guest} and one other person to her party.`,
        other: `${host} invites ${guest} and # other people to her party.`
    }),
    male: 'male',
    other: 'other'
});

const selectIdResult = select('selectId', {
    value: gender,
    female: 'female',
    male: 'male',
    other: 'other'
});

const formattedDate: MessageDescriptor = date(new Date(), { timeZone: 'UTC' });
const formattedNumber: MessageDescriptor = number(1234.56, { style: 'currency', currency: 'EUR' });

// JSX
const App = () => {
    const name = 'Ken';
    const numBooks = 58;
    const gender = 'male';
    const price = 21.35;
    const lastLogin = new Date();
    const age = 23;
    return (
        <>
            Name {name} in <code>Trans</code>.
            Name {name} in <code>Trans</code> with <code>id</code>.
github DefinitelyTyped / DefinitelyTyped / types / lingui__macro / lingui__macro-tests.tsx View on Github external
2: `${host} invites ${guest} and one other person to her party.`,
        other: `${host} invites ${guest} and # other people to her party.`
    }),
    male: 'male',
    other: 'other'
});

const selectIdResult = select('selectId', {
    value: gender,
    female: 'female',
    male: 'male',
    other: 'other'
});

const formattedDate: MessageDescriptor = date(new Date(), { timeZone: 'UTC' });
const formattedNumber: MessageDescriptor = number(1234.56, { style: 'currency', currency: 'EUR' });

// JSX
const App = () =&gt; {
    const name = 'Ken';
    const numBooks = 58;
    const gender = 'male';
    const price = 21.35;
    const lastLogin = new Date();
    const age = 23;
    return (
        &lt;&gt;
            Name {name} in <code>Trans</code>.
            Name {name} in <code>Trans</code> with <code>id</code>.
github xivanalysis / xivanalysis / src / parser / core / modules / Gauge / Gauge.tsx View on Github external
import {t} from '@lingui/macro'
import TimeLineChart from 'components/ui/TimeLineChart'
import {DeathEvent} from 'fflogs'
import Module from 'parser/core/Module'
import React from 'react'
import {isDefined} from 'utilities'
import {AbstractGauge} from './AbstractGauge'
import {TimerGauge} from './TimerGauge'

export class Gauge extends Module {
	static handle = 'gauge'
	static title = t('core.gauge.title')`Gauge`

	private gauges: AbstractGauge[] = []

	protected init() {
		this.addHook('death', {to: 'player'}, this.onDeath)
	}

	/** Add &amp; initialise a gauge implementation to be tracked as part of the core gauge handling. */
	add(gauge: T) {
		gauge.setParser(this.parser)

		// TODO: Work out how to remove this. Probably also the parser, too.
		if (gauge instanceof TimerGauge) {
			gauge.setAddTimestampHook(this.addTimestampHook.bind(this))
			gauge.setRemoveTimestampHook(this.removeTimestampHook.bind(this))
		}
github xivanalysis / xivanalysis / src / parser / jobs / sch / index.js View on Github external
import {t} from '@lingui/macro'
import {Trans} from '@lingui/react'
import React from 'react'
import {Icon, Message} from 'semantic-ui-react'

import TransMarkdown from 'components/ui/TransMarkdown'
import CONTRIBUTORS, {ROLES} from 'data/CONTRIBUTORS'
import {Meta} from 'parser/core/Meta'

const description = t('sch.about.description')`
This analyser aims to identify some of the low-hanging fruit that could be used to improve your SCH gameplay, as well as give a deeper insight into what happened during an encounter.

If you would like to learn more about SCH, check the guides over at [The Balance](https://thebalanceffxiv.com/), and have a chat in the #sch_questions channel.
`

export default new Meta({
	modules: () =&gt; import('./modules' /* webpackChunkName: "jobs-sch" */),

	Description: () =&gt; &lt;&gt;
		
		
			
			
				While the analysis below should be reasonably accurate, this system <em>is</em> still in development, and may get a little mixed up sometimes. If you notice any issues, or have any concerns, please drop by our Discord channel!
github xivanalysis / xivanalysis / src / parser / jobs / smn / modules / DoTs.js View on Github external
// Can never be too careful :blobsweat:
const STATUS_DURATION = {
	[STATUSES.BIO_III.id]: 30000,
	[STATUSES.MIASMA_III.id]: 30000,
}

// In ms
const CLIPPING_SEVERITY = {
	1000: SEVERITY.MINOR,
	10000: SEVERITY.MEDIUM,
	30000: SEVERITY.MAJOR,
}

export default class DoTs extends Module {
	static handle = 'dots'
	static title = t('smn.dots.title')`DoTs`
	static dependencies = [
		'checklist',
		'enemies',
		'gauge',
		'invuln',
		'suggestions',
	]

	_lastApplication = {}
	_clip = {
		[STATUSES.BIO_III.id]: 0,
		[STATUSES.MIASMA_III.id]: 0,
	}
	_application = {
		[STATUSES.BIO_III.id]: [],
		[STATUSES.MIASMA_III.id]: [],
github xivanalysis / xivanalysis / src / data / JOBS.ts View on Github external
colour: string
	role: Role['id']
}

// Yeah I know there's lots of repetition but they're all different apis and endpoints and shit and I don't wanna pull it apart later to fix a desync
const JOBS = {
	// Tank
	PALADIN: {
		name: t('game.job.paladin')`Paladin`,
		logType: ActorType.PALADIN,
		icon: 'pld',
		colour: '#a8d2e6',
		role: ROLES.TANK.id,
	},
	WARRIOR: {
		name: t('game.job.warrior')`Warrior`,
		logType: ActorType.WARRIOR,
		icon: 'war',
		colour: '#cf2621',
		role: ROLES.TANK.id,
	},
	DARK_KNIGHT: {
		name: t('game.job.dark-knight')`Dark Knight`,
		logType: ActorType.DARK_KNIGHT,
		icon: 'drk',
		colour: '#d126cc',
		role: ROLES.TANK.id,
	},
	GUNBREAKER: {
		name: t('game.job.gunbreaker')`Gunbreaker`,
		logType: ActorType.GUNBREAKER,
		icon: 'gnb',
github xivanalysis / xivanalysis / src / data / JOBS.ts View on Github external
const roleData = {
	TANK: {
		id: 1,
		name: t('game.roles.tank')`Tank`,
		colour: colors.tank,
	},

	HEALER: {
		id: 2,
		name: t('game.roles.healer')`Healer`,
		colour: colors.healer,
	},

	MELEE: {
		id: 3,
		name: t('game.roles.melee-dps')`Melee DPS`,
		colour: colors.dps,
	},

	PHYSICAL_RANGED: {
		id: 4,
		name: t('game.roles.physical-ranged-dps')`Physical Ranged DPS`,
		colour: colors.dps,
	},

	MAGICAL_RANGED: {
		id: 5,
		name: t('game.roles.magical-ranged-dps')`Magical Ranged DPS`,
		colour: colors.dps,
	},

	// Not really roles but w/e

@lingui/macro

Macro for generating messages in ICU MessageFormat syntax

MIT
Latest version published 6 days ago

Package Health Score

98 / 100
Full package analysis