Skip to content

Commit

Permalink
fix: i18n for media filename template
Browse files Browse the repository at this point in the history
  • Loading branch information
prinsss committed Apr 12, 2024
1 parent 8c020bd commit 38069a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/components/modals/export-media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Table } from '@tanstack/table-core';
import { IconCircleCheck, IconCircleDashed, IconInfoCircle } from '@tabler/icons-preact';

import { FileLike, ProgressCallback, zipStreamDownload } from '@/utils/download';
import { DEFAULT_FILENAME_PATTERN, FILENAME_PATTERN_TOOLTIP, extractMedia } from '@/utils/media';
import { DEFAULT_FILENAME_PATTERN, extractMedia, patterns } from '@/utils/media';
import { Modal } from '@/components/common';
import { TranslationKey, useTranslation } from '@/i18n';
import { Tweet, User } from '@/types';
Expand Down Expand Up @@ -106,7 +106,9 @@ export function ExportMediaModal<T>({
<p class="mr-2 leading-8">{t('Filename template:')}</p>
<div
class="flex-grow tooltip tooltip-bottom before:whitespace-pre-line before:max-w-max"
data-tip={FILENAME_PATTERN_TOOLTIP}
data-tip={Object.entries(patterns)
.map(([key, value]) => `{${key}} - ${t(value.description as TranslationKey)}`)
.reduce((acc, cur) => acc + cur + '\n', '')}
>
<input
type="text"
Expand Down
4 changes: 0 additions & 4 deletions src/utils/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ export const patterns: Record<string, { description: string; extractor: PatternE

export const DEFAULT_FILENAME_PATTERN = '{screen_name}_{id}_{type}_{num}_{date}.{ext}';

export const FILENAME_PATTERN_TOOLTIP = Object.entries(patterns)
.map(([key, value]) => `{${key}} - ${value.description}`)
.reduce((acc, cur) => acc + cur + '\n', '');

/**
* Extract media from tweets and users.
*/
Expand Down

0 comments on commit 38069a3

Please sign in to comment.