diff --git a/i18n/resources.json b/i18n/resources.json
index c4ba0ef..47210c8 100644
--- a/i18n/resources.json
+++ b/i18n/resources.json
@@ -5,12 +5,12 @@
"quotedFrom": "Quoting {name} (@{screen_name})",
"replyingTo": "Replying to @{screen_name}",
"threadPartHeader": "A part of @${screen_name}'s thread",
-
+
"ivAuthorActionReply": "Reply from {authorName} (@{authorScreenName}):",
"ivAuthorActionOriginal": "Original from {authorName} (@{authorScreenName}):",
"ivAuthorActionFollowUp": "Follow-up from {authorName} (@{authorScreenName}):",
"ivQuoteHeader": "Quoting {authorName} (@{authorHandle})",
-
+
"photoCount": "Photo {number} / {total}",
"videoCount": "Video {number} / {total}",
"mediaCount": "Media {number} / {total}",
diff --git a/src/embed/status.ts b/src/embed/status.ts
index ccc188b..5746927 100644
--- a/src/embed/status.ts
+++ b/src/embed/status.ts
@@ -10,7 +10,7 @@ import { renderInstantView } from '../render/instantview';
import { constructTwitterThread } from '../providers/twitter/conversation';
import { Experiment, experimentCheck } from '../experiments';
import i18next from 'i18next';
-import icu from "i18next-icu";
+import icu from 'i18next-icu';
import translationResources from '../../i18n/resources.json';
export const returnError = (c: Context, error: string): Response => {
@@ -488,7 +488,7 @@ export const handleStatus = async (
const mediaType = overrideMedia ?? status.media.videos?.[0]?.type;
if (mediaType === 'gif') {
- provider = i18next.t('gifIndicator', {brandingName: Constants.BRANDING_NAME});
+ provider = i18next.t('gifIndicator', { brandingName: Constants.BRANDING_NAME });
} else if (
status.embed_card === 'player' &&
providerEngagementText !== Strings.DEFAULT_AUTHOR_TEXT
diff --git a/src/render/instantview.ts b/src/render/instantview.ts
index cd1c787..a7458cd 100644
--- a/src/render/instantview.ts
+++ b/src/render/instantview.ts
@@ -115,8 +115,8 @@ const notApplicableComment = '';
const truncateSocialCount = (count: number, locale = 'en-US') => {
const formatter = new Intl.NumberFormat(locale, {
- notation: "compact",
- compactDisplay: "short",
+ notation: 'compact',
+ compactDisplay: 'short',
maximumFractionDigits: 1
});
@@ -143,7 +143,7 @@ const generateInlineAuthorHeader = (
authorScreenName: author.screen_name
})}`;
}
- // Reply / unknown
+ // Reply / unknown
return `
${i18next.t('ivAuthorActionReply', {
statusUrl: status.url,
authorName: author.name,
@@ -170,7 +170,12 @@ const wrapForeignLinks = (url: string) => {
: url;
};
-const generateStatusFooter = (status: APIStatus, isQuote = false, author: APIUser, language: string): string => {
+const generateStatusFooter = (
+ status: APIStatus,
+ isQuote = false,
+ author: APIUser,
+ language: string
+): string => {
let description = author.description;
description = htmlifyLinks(description);
description = htmlifyHashtags(description);
@@ -221,10 +226,10 @@ const generatePoll = (poll: APIPoll, language: string): string => {
poll.choices.forEach(choice => {
const bar = '█'.repeat((choice.percentage / 100) * barLength);
// eslint-disable-next-line no-irregular-whitespace
- str += `${bar}
${choice.label}
${i18next.t('ivPollChoice', { voteCount: intlFormat.format(choice.count), percentage: intlFormat.format(choice.percentage)})}
`;
+ str += `${bar}
${choice.label}
${i18next.t('ivPollChoice', { voteCount: intlFormat.format(choice.count), percentage: intlFormat.format(choice.percentage) })}
`;
});
/* Finally, add the footer of the poll with # of votes and time left */
- str += `
${i18next.t('pollVotes', { voteCount: intlFormat.format(poll.total_votes), timeLeft: poll.time_left_en})}`;
+ str += `
${i18next.t('pollVotes', { voteCount: intlFormat.format(poll.total_votes), timeLeft: poll.time_left_en })}`;
return str;
};
@@ -300,19 +305,20 @@ const generateStatus = (
${status.poll ? generatePoll(status.poll, status.lang ?? 'en') : notApplicableComment}
- ${!isQuote && status.quote ? generateStatus(status.quote, author, language, true, null) : notApplicableComment}`
- .format({
- quoteHeader: isQuote
- ? '' +
- i18next.t('ivQuoteHeader').format({
- url: status.url,
- authorName: status.author.name,
- authorHandle: status.author.screen_name,
- authorURL: `${Constants.TWITTER_ROOT}/${status.author.screen_name}`
- }) +
- '
'
- : ''
- });
+ ${!isQuote && status.quote ? generateStatus(status.quote, author, language, true, null) : notApplicableComment}`.format(
+ {
+ quoteHeader: isQuote
+ ? '' +
+ i18next.t('ivQuoteHeader').format({
+ url: status.url,
+ authorName: status.author.name,
+ authorHandle: status.author.screen_name,
+ authorURL: `${Constants.TWITTER_ROOT}/${status.author.screen_name}`
+ }) +
+ '
'
+ : ''
+ }
+ );
};
export const renderInstantView = (properties: RenderProperties): ResponseInstructions => {
@@ -322,8 +328,8 @@ export const renderInstantView = (properties: RenderProperties): ResponseInstruc
let previousThreadPieceAuthor: string | null = null;
let originalAuthor: string | null = null;
-
- const useThread = thread?.thread ?? [ thread?.status ]
+
+ const useThread = thread?.thread ?? [thread?.status];
if (!status) {
throw new Error('Status is undefined');
@@ -359,7 +365,8 @@ export const renderInstantView = (properties: RenderProperties): ResponseInstruc
${i18next.t('ivViewOriginal')}
${status.author.name} (@${status.author.screen_name})
- ${useThread.map(status => {
+ ${useThread
+ .map(status => {
console.log('previousThreadPieceAuthor', previousThreadPieceAuthor);
if (!status) {
return '';
@@ -395,7 +402,13 @@ export const renderInstantView = (properties: RenderProperties): ResponseInstruc
previousThreadPieceAuthor = status.author?.id;
- return generateStatus(status, status.author ?? thread?.author, properties?.targetLanguage ?? 'en', false, authorAction,);
+ return generateStatus(
+ status,
+ status.author ?? thread?.author,
+ properties?.targetLanguage ?? 'en',
+ false,
+ authorAction
+ );
})
.join('')}
${generateStatusFooter(status, false, thread?.author ?? status.author, properties?.targetLanguage ?? 'en')}
diff --git a/src/render/photo.ts b/src/render/photo.ts
index 587400f..968e6f4 100644
--- a/src/render/photo.ts
+++ b/src/render/photo.ts
@@ -14,7 +14,9 @@ export const renderPhoto = (
const all = status.media?.all as APIMedia[];
const baseString =
- all.length === status.media?.photos?.length ? i18next.t('photoCount') : i18next.t('mediaCount');
+ all.length === status.media?.photos?.length
+ ? i18next.t('photoCount')
+ : i18next.t('mediaCount');
const photoCounter = baseString.format({
number: String(all.indexOf(photo) + 1),
diff --git a/src/render/video.ts b/src/render/video.ts
index 73c0c96..bd00b8c 100644
--- a/src/render/video.ts
+++ b/src/render/video.ts
@@ -33,7 +33,9 @@ export const renderVideo = (
we'll put an indicator if there are more than one video */
if (all && all.length > 1 && (userAgent?.indexOf('Telegram') ?? 0) > -1) {
const baseString =
- all.length === status.media?.videos?.length ? i18next.t('videoCount') : i18next.t('mediaCount');
+ all.length === status.media?.videos?.length
+ ? i18next.t('videoCount')
+ : i18next.t('mediaCount');
const videoCounter = baseString.format({
number: String(all.indexOf(video) + 1),
total: String(all.length)