mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-22 08:36:21 +01:00
All the updates for Lingui v5
Possibly might break if I accidentally miss something
This commit is contained in:
parent
dcf22b53cd
commit
acb7084d18
57 changed files with 845 additions and 922 deletions
|
@ -1,6 +1,6 @@
|
|||
import './account-block.css';
|
||||
|
||||
import { Plural, t, Trans } from '@lingui/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
|
||||
// import { useNavigate } from 'react-router-dom';
|
||||
import enhanceContent from '../utils/enhance-content';
|
||||
|
@ -28,6 +28,7 @@ function AccountBlock({
|
|||
relationship = {},
|
||||
excludeRelationshipAttrs = [],
|
||||
}) {
|
||||
const { t } = useLingui();
|
||||
if (skeleton) {
|
||||
return (
|
||||
<div class="account-block skeleton">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import './account-info.css';
|
||||
|
||||
import { msg, plural, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg, plural } from '@lingui/core/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import {
|
||||
useCallback,
|
||||
|
@ -24,7 +24,7 @@ import pmem from '../utils/pmem';
|
|||
import shortenNumber from '../utils/shorten-number';
|
||||
import showCompose from '../utils/show-compose';
|
||||
import showToast from '../utils/show-toast';
|
||||
import states, { hideAllModals } from '../utils/states';
|
||||
import states from '../utils/states';
|
||||
import store from '../utils/store';
|
||||
import { getCurrentAccountID, updateAccount } from '../utils/store-utils';
|
||||
import supports from '../utils/supports';
|
||||
|
@ -135,7 +135,7 @@ function AccountInfo({
|
|||
instance,
|
||||
authenticated,
|
||||
}) {
|
||||
const { i18n } = useLingui();
|
||||
const { i18n, t } = useLingui();
|
||||
const { masto } = api({
|
||||
instance,
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useEffect } from 'preact/hooks';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
|
@ -9,6 +9,7 @@ import AccountInfo from './account-info';
|
|||
import Icon from './icon';
|
||||
|
||||
function AccountSheet({ account, instance: propInstance, onClose }) {
|
||||
const { t } = useLingui();
|
||||
const { masto, instance, authenticated } = api({ instance: propInstance });
|
||||
const isString = typeof account === 'string';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { memo } from 'preact/compat';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
|
@ -13,6 +13,8 @@ const STREAMING_TIMEOUT = 1000 * 3; // 3 seconds
|
|||
const POLL_INTERVAL = 20_000; // 20 seconds
|
||||
|
||||
export default memo(function BackgroundService({ isLoggedIn }) {
|
||||
const { t } = useLingui();
|
||||
|
||||
// Notifications service
|
||||
// - WebSocket to receive notifications when page is visible
|
||||
const [visible, setVisible] = useState(true);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
|
@ -23,6 +23,7 @@ const scrollIntoViewOptions = {
|
|||
};
|
||||
|
||||
function Columns() {
|
||||
const { t } = useLingui();
|
||||
useTitle(t`Home`, '/');
|
||||
const snapStates = useSnapshot(states);
|
||||
const { shortcuts } = snapStates;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
|
@ -9,6 +9,7 @@ import states from '../utils/states';
|
|||
import Icon from './icon';
|
||||
|
||||
export default function ComposeButton() {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
|
||||
function handleButton(e) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import './compose.css';
|
||||
import '@github/text-expander-element';
|
||||
|
||||
import { msg, plural, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg, plural } from '@lingui/core/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { MenuItem } from '@szhsin/react-menu';
|
||||
import { deepEqual } from 'fast-equals';
|
||||
import Fuse from 'fuse.js';
|
||||
|
@ -217,7 +217,7 @@ function Compose({
|
|||
standalone,
|
||||
hasOpener,
|
||||
}) {
|
||||
const { i18n, _ } = useLingui();
|
||||
const { i18n, _, t } = useLingui();
|
||||
const rtf = RTF(i18n.locale);
|
||||
const lf = LF(i18n.locale);
|
||||
|
||||
|
@ -2244,7 +2244,7 @@ function MediaAttachment({
|
|||
onDescriptionChange = () => {},
|
||||
onRemove = () => {},
|
||||
}) {
|
||||
const { i18n } = useLingui();
|
||||
const { i18n, t } = useLingui();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const supportsEdit = supports('@mastodon/edit-media-attributes');
|
||||
const { type, id, file } = attachment;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './drafts.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useMemo, useReducer, useState } from 'react';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
|
@ -14,6 +14,7 @@ import Loader from './loader';
|
|||
import MenuConfirm from './menu-confirm';
|
||||
|
||||
function Drafts({ onClose }) {
|
||||
const { t } = useLingui();
|
||||
const { masto } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [drafts, setDrafts] = useState([]);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import './embed-modal.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
|
||||
import Icon from './icon';
|
||||
|
||||
function EmbedModal({ html, url, width, height, onClose = () => {} }) {
|
||||
const { t } = useLingui();
|
||||
return (
|
||||
<div class="embed-modal-container">
|
||||
<div class="top-controls">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useState } from 'preact/hooks';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
|
@ -7,6 +7,7 @@ import Icon from './icon';
|
|||
import Loader from './loader';
|
||||
|
||||
function FollowRequestButtons({ accountID, onChange }) {
|
||||
const { t } = useLingui();
|
||||
const { masto } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [requestState, setRequestState] = useState(null); // accept, reject
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './generic-accounts.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { InView } from 'react-intersection-observer';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
@ -21,8 +21,9 @@ export default function GenericAccounts({
|
|||
excludeRelationshipAttrs = [],
|
||||
postID,
|
||||
onClose = () => {},
|
||||
blankCopy = t`Nothing to show`,
|
||||
blankCopy,
|
||||
}) {
|
||||
const { t } = useLingui();
|
||||
const { masto, instance: currentInstance } = api();
|
||||
const isCurrentInstance = instance ? instance === currentInstance : true;
|
||||
const snapStates = useSnapshot(states);
|
||||
|
@ -227,7 +228,9 @@ export default function GenericAccounts({
|
|||
<Trans>Error loading accounts</Trans>
|
||||
</p>
|
||||
) : (
|
||||
<p class="ui-state insignificant">{blankCopy}</p>
|
||||
<p class="ui-state insignificant">
|
||||
{blankCopy || t`Nothing to show`}
|
||||
</p>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './keyboard-shortcuts-help.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { memo } from 'preact/compat';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
@ -11,6 +11,7 @@ import Icon from './icon';
|
|||
import Modal from './modal';
|
||||
|
||||
export default memo(function KeyboardShortcutsHelp() {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
|
||||
function onClose() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
|
@ -9,6 +9,7 @@ import Icon from './icon';
|
|||
import MenuConfirm from './menu-confirm';
|
||||
|
||||
function ListAddEdit({ list, onClose }) {
|
||||
const { t } = useLingui();
|
||||
const { masto } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const editMode = !!list;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { Menu, MenuItem } from '@szhsin/react-menu';
|
||||
import { useState } from 'preact/hooks';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
@ -13,6 +13,7 @@ import Menu2 from './menu2';
|
|||
import TranslationBlock from './translation-block';
|
||||
|
||||
export default function MediaAltModal({ alt, lang, onClose }) {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const [forceTranslate, setForceTranslate] = useState(false);
|
||||
const targetLanguage = getTranslateTargetLanguage(true);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import { getBlurHashAverageColor } from 'fast-blurhash';
|
||||
import {
|
||||
|
@ -32,6 +32,7 @@ function MediaModal({
|
|||
index = 0,
|
||||
onClose = () => {},
|
||||
}) {
|
||||
const { t } = useLingui();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const carouselRef = useRef(null);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './media-post.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { memo } from 'preact/compat';
|
||||
import { useContext, useMemo } from 'preact/hooks';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
@ -22,6 +22,7 @@ function MediaPost({
|
|||
// allowFilters,
|
||||
onMediaClick,
|
||||
}) {
|
||||
const { t } = useLingui();
|
||||
let sKey = statusKey(statusID, instance);
|
||||
const snapStates = useSnapshot(states);
|
||||
if (!status) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { getBlurHashAverageColor } from 'fast-blurhash';
|
||||
import { Fragment } from 'preact';
|
||||
import { memo } from 'preact/compat';
|
||||
|
@ -32,6 +32,7 @@ audio = Audio track
|
|||
|
||||
const dataAltLabel = 'ALT';
|
||||
const AltBadge = (props) => {
|
||||
const { t } = useLingui();
|
||||
const { alt, lang, index, ...rest } = props;
|
||||
if (!alt || !alt.trim()) return null;
|
||||
return (
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useEffect } from 'preact/hooks';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { subscribe, useSnapshot } from 'valtio';
|
||||
|
@ -30,6 +30,7 @@ subscribe(states, (changes) => {
|
|||
});
|
||||
|
||||
export default function Modals() {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './nav-menu.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { ControlledMenu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import { memo } from 'preact/compat';
|
||||
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
||||
|
@ -21,6 +21,7 @@ import MenuLink from './menu-link';
|
|||
import SubMenu2 from './submenu2';
|
||||
|
||||
function NavMenu(props) {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const { masto, instance, authenticated } = api();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { memo } from 'preact/compat';
|
||||
import { useLayoutEffect, useState } from 'preact/hooks';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
@ -33,6 +33,7 @@ import Notification from './notification';
|
|||
}
|
||||
|
||||
export default memo(function NotificationService() {
|
||||
const { t } = useLingui();
|
||||
if (!('serviceWorker' in navigator)) return null;
|
||||
|
||||
const snapStates = useSnapshot(states);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { msg, Plural, Select, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg, t } from '@lingui/core/macro';
|
||||
import { Plural, Select, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { Fragment } from 'preact';
|
||||
import { memo } from 'preact/compat';
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Plural, plural, t, Trans } from '@lingui/macro';
|
||||
import { plural } from '@lingui/core/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useState } from 'preact/hooks';
|
||||
|
||||
import shortenNumber from '../utils/shorten-number';
|
||||
|
@ -14,6 +15,7 @@ export default function Poll({
|
|||
refresh = () => {},
|
||||
votePoll = () => {},
|
||||
}) {
|
||||
const { t } = useLingui();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const {
|
||||
expired,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { i18n } from '@lingui/core';
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { useEffect, useMemo, useReducer } from 'preact/hooks';
|
||||
|
||||
import localeMatch from '../utils/locale-match';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import './report-modal.css';
|
||||
|
||||
import { msg, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { Fragment } from 'preact';
|
||||
import { useMemo, useRef, useState } from 'preact/hooks';
|
||||
|
||||
|
@ -46,7 +46,7 @@ const CATEGORIES_INFO = {
|
|||
};
|
||||
|
||||
function ReportModal({ account, post, onClose }) {
|
||||
const { _ } = useLingui();
|
||||
const { _, t } = useLingui();
|
||||
const { masto } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [username, domain] = account.acct.split('@');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { forwardRef } from 'preact/compat';
|
||||
import { useImperativeHandle, useRef, useState } from 'preact/hooks';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
|
@ -9,6 +9,7 @@ import Icon from './icon';
|
|||
import Link from './link';
|
||||
|
||||
const SearchForm = forwardRef((props, ref) => {
|
||||
const { t } = useLingui();
|
||||
const { instance } = api();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [searchMenuOpen, setSearchMenuOpen] = useState(false);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import './shortcuts-settings.css';
|
||||
|
||||
import { useAutoAnimate } from '@formkit/auto-animate/preact';
|
||||
import { msg, Plural, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg, t } from '@lingui/core/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import {
|
||||
compressToEncodedURIComponent,
|
||||
decompressFromEncodedURIComponent,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import './shortcuts.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { MenuDivider } from '@szhsin/react-menu';
|
||||
import { memo } from 'preact/compat';
|
||||
import { useRef, useState } from 'preact/hooks';
|
||||
|
@ -22,6 +21,7 @@ import Menu2 from './menu2';
|
|||
import SubMenu2 from './submenu2';
|
||||
|
||||
function Shortcuts() {
|
||||
const { t } = useLingui();
|
||||
const { _ } = useLingui();
|
||||
const { instance } = api();
|
||||
const snapStates = useSnapshot(states);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import './status.css';
|
||||
import '@justinribeiro/lite-youtube';
|
||||
|
||||
import { msg, plural, Plural, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg, plural } from '@lingui/core/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import {
|
||||
ControlledMenu,
|
||||
Menu,
|
||||
|
@ -308,7 +308,7 @@ function Status({
|
|||
showReplyParent,
|
||||
mediaFirst,
|
||||
}) {
|
||||
const { _ } = useLingui();
|
||||
const { _, t } = useLingui();
|
||||
|
||||
if (skeleton) {
|
||||
return (
|
||||
|
@ -2967,6 +2967,7 @@ function EditedAtModal({
|
|||
fetchStatusHistory = () => {},
|
||||
onClose,
|
||||
}) {
|
||||
const { t } = useLingui();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [editHistory, setEditHistory] = useState([]);
|
||||
|
||||
|
@ -3202,6 +3203,7 @@ function generateHTMLCode(post, instance, level = 0) {
|
|||
}
|
||||
|
||||
function EmbedModal({ post, instance, onClose }) {
|
||||
const { t } = useLingui();
|
||||
const {
|
||||
account: {
|
||||
url: accountURL,
|
||||
|
@ -3578,7 +3580,7 @@ function FilteredStatus({
|
|||
showFollowedTags,
|
||||
quoted,
|
||||
}) {
|
||||
const { _ } = useLingui();
|
||||
const { _, t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const {
|
||||
id: statusID,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { plural, t, Trans } from '@lingui/macro';
|
||||
import { plural } from '@lingui/core/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { memo } from 'preact/compat';
|
||||
import {
|
||||
useCallback,
|
||||
|
@ -60,6 +61,7 @@ function Timeline({
|
|||
showReplyParent,
|
||||
clearWhenRefresh,
|
||||
}) {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const [items, setItems] = useState([]);
|
||||
const [uiState, setUIState] = useState('start');
|
||||
|
@ -573,6 +575,7 @@ const TimelineItem = memo(
|
|||
showReplyParent,
|
||||
mediaFirst,
|
||||
}) => {
|
||||
const { t } = useLingui();
|
||||
console.debug('RENDER TimelineItem', status.id);
|
||||
const { id: statusID, reblog, items, type, _pinned } = status;
|
||||
if (_pinned) useItemID = false;
|
||||
|
@ -836,6 +839,7 @@ const TimelineItem = memo(
|
|||
);
|
||||
|
||||
function StatusCarousel({ title, class: className, children }) {
|
||||
const { t } = useLingui();
|
||||
const carouselRef = useRef();
|
||||
// const { reachStart, reachEnd, init } = useScroll({
|
||||
// scrollableRef: carouselRef,
|
||||
|
@ -929,6 +933,7 @@ function StatusCarousel({ title, class: className, children }) {
|
|||
}
|
||||
|
||||
function TimelineStatusCompact({ status, instance, filterContext }) {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const { id, visibility, language } = status;
|
||||
const statusPeekText = statusPeek(status);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './translation-block.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import pRetry from 'p-retry';
|
||||
import pThrottle from 'p-throttle';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
|
@ -80,6 +80,7 @@ function TranslationBlock({
|
|||
mini,
|
||||
autoDetected,
|
||||
}) {
|
||||
const { t } = useLingui();
|
||||
const targetLang = getTranslateTargetLanguage(true);
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [pronunciationContent, setPronunciationContent] = useState(null);
|
||||
|
|
|
@ -3,8 +3,8 @@ import './app.css';
|
|||
import './polyfills';
|
||||
|
||||
import { i18n } from '@lingui/core';
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { I18nProvider } from '@lingui/react';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { render } from 'preact';
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
|
||||
|
@ -12,7 +12,7 @@ import ComposeSuspense from './components/compose-suspense';
|
|||
import Loader from './components/loader';
|
||||
import { initActivateLang } from './utils/lang';
|
||||
import { initStates } from './utils/states';
|
||||
import { getCurrentAccount, setCurrentAccountID } from './utils/store-utils';
|
||||
import { getCurrentAccount } from './utils/store-utils';
|
||||
import useTitle from './utils/useTitle';
|
||||
|
||||
initActivateLang();
|
||||
|
@ -22,6 +22,7 @@ if (window.opener) {
|
|||
}
|
||||
|
||||
function App() {
|
||||
const { t } = useLingui();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [isLoggedIn, setIsLoggedIn] = useState(null);
|
||||
|
||||
|
|
1540
src/locales/en.po
generated
1540
src/locales/en.po
generated
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { MenuItem } from '@szhsin/react-menu';
|
||||
import {
|
||||
useCallback,
|
||||
|
@ -51,6 +50,7 @@ async function _isSearchEnabled(instance) {
|
|||
const isSearchEnabled = pmem(_isSearchEnabled);
|
||||
|
||||
function AccountStatuses() {
|
||||
const { i18n, t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const { id, ...params } = useParams();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
@ -229,7 +229,6 @@ function AccountStatuses() {
|
|||
}
|
||||
|
||||
const [featuredTags, setFeaturedTags] = useState([]);
|
||||
const { i18n } = useLingui();
|
||||
let title = t`Account posts`;
|
||||
if (account?.acct) {
|
||||
const acctDisplay = (/@/.test(account.acct) ? '' : '@') + account.acct;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import './accounts.css';
|
||||
|
||||
import { useAutoAnimate } from '@formkit/auto-animate/preact';
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { Menu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import { useReducer } from 'preact/hooks';
|
||||
|
||||
|
@ -20,6 +20,7 @@ import { getCurrentAccountID, setCurrentAccountID } from '../utils/store-utils';
|
|||
const isStandalone = window.matchMedia('(display-mode: standalone)').matches;
|
||||
|
||||
function Accounts({ onClose }) {
|
||||
const { t } = useLingui();
|
||||
const { masto } = api();
|
||||
// Accounts
|
||||
const accounts = store.local.getJSON('accounts');
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
|
||||
import './annual-report.css';
|
||||
|
||||
import { Trans } from '@lingui/react/macro';
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useRef } from 'preact/hooks';
|
||||
|
||||
import Timeline from '../components/timeline';
|
||||
|
@ -8,6 +8,7 @@ import useTitle from '../utils/useTitle';
|
|||
const LIMIT = 20;
|
||||
|
||||
function Bookmarks() {
|
||||
const { t } = useLingui();
|
||||
useTitle(t`Bookmarks`, '/bookmarks');
|
||||
const { masto, instance } = api();
|
||||
const bookmarksIterator = useRef();
|
||||
|
|
|
@ -2,8 +2,8 @@ import '../components/links-bar.css';
|
|||
import './catchup.css';
|
||||
|
||||
import autoAnimate from '@formkit/auto-animate';
|
||||
import { msg, Plural, select, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg, select } from '@lingui/core/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { getBlurHashAverageColor } from 'fast-blurhash';
|
||||
import { Fragment } from 'preact';
|
||||
import { memo } from 'preact/compat';
|
||||
|
@ -95,7 +95,7 @@ const DTF = mem(
|
|||
);
|
||||
|
||||
function Catchup() {
|
||||
const { i18n, _ } = useLingui();
|
||||
const { i18n, _, t } = useLingui();
|
||||
const dtf = DTF(i18n.locale);
|
||||
|
||||
useTitle(`Catch-up`, '/catchup');
|
||||
|
@ -1834,6 +1834,7 @@ function postDensity(post) {
|
|||
const MEDIA_SIZE = 48;
|
||||
|
||||
function PostPeek({ post, filterInfo }) {
|
||||
const { t } = useLingui();
|
||||
const {
|
||||
spoilerText,
|
||||
sensitive,
|
||||
|
@ -2048,6 +2049,7 @@ function PostPeek({ post, filterInfo }) {
|
|||
}
|
||||
|
||||
function PostStats({ post }) {
|
||||
const { t } = useLingui();
|
||||
const { reblogsCount, repliesCount, favouritesCount } = post;
|
||||
return (
|
||||
<span class="post-stats">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useRef } from 'preact/hooks';
|
||||
|
||||
import Timeline from '../components/timeline';
|
||||
|
@ -8,6 +8,7 @@ import useTitle from '../utils/useTitle';
|
|||
const LIMIT = 20;
|
||||
|
||||
function Favourites() {
|
||||
const { t } = useLingui();
|
||||
useTitle(t`Likes`, '/favourites');
|
||||
const { masto, instance } = api();
|
||||
const favouritesIterator = useRef();
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import './filters.css';
|
||||
|
||||
import { i18n } from '@lingui/core';
|
||||
import { msg, Plural, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useReducer, useRef, useState } from 'preact/hooks';
|
||||
|
||||
import Icon from '../components/icon';
|
||||
|
@ -50,6 +49,7 @@ const EXPIRY_DURATIONS_LABELS = {
|
|||
};
|
||||
|
||||
function Filters() {
|
||||
const { t } = useLingui();
|
||||
const { masto } = api();
|
||||
useTitle(t`Filters`, `/ft`);
|
||||
const [uiState, setUIState] = useState('default');
|
||||
|
@ -197,7 +197,7 @@ function Filters() {
|
|||
let _id = 1;
|
||||
const incID = () => _id++;
|
||||
function FiltersAddEdit({ filter, onClose }) {
|
||||
const { _ } = useLingui();
|
||||
const { _, t } = useLingui();
|
||||
const { masto } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const editMode = !!filter;
|
||||
|
@ -596,6 +596,7 @@ function FiltersAddEdit({ filter, onClose }) {
|
|||
}
|
||||
|
||||
function ExpiryStatus({ expiresAt, showNeverExpires }) {
|
||||
const { t } = useLingui();
|
||||
const hasExpiry = !!expiresAt;
|
||||
const expiresAtDate = hasExpiry && new Date(expiresAt);
|
||||
const expired = hasExpiry && expiresAtDate <= new Date();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Plural, t, Trans } from '@lingui/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
|
||||
import Icon from '../components/icon';
|
||||
|
@ -10,6 +10,7 @@ import { fetchFollowedTags } from '../utils/followed-tags';
|
|||
import useTitle from '../utils/useTitle';
|
||||
|
||||
function FollowedHashtags() {
|
||||
const { t } = useLingui();
|
||||
const { masto, instance } = api();
|
||||
useTitle(t`Followed Hashtags`, `/fh`);
|
||||
const [uiState, setUIState] = useState('default');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useRef } from 'preact/hooks';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
|
@ -17,6 +17,7 @@ import useTitle from '../utils/useTitle';
|
|||
const LIMIT = 20;
|
||||
|
||||
function Following({ title, path, id, ...props }) {
|
||||
const { t } = useLingui();
|
||||
useTitle(
|
||||
title ||
|
||||
t({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { plural, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { plural } from '@lingui/core/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import {
|
||||
FocusableItem,
|
||||
MenuDivider,
|
||||
|
@ -31,6 +31,7 @@ const TAGS_LIMIT_PER_MODE = 4;
|
|||
const TOTAL_TAGS_LIMIT = TAGS_LIMIT_PER_MODE + 1;
|
||||
|
||||
function Hashtags({ media: mediaView, columnMode, ...props }) {
|
||||
const { t } = useLingui();
|
||||
// const navigate = useNavigate();
|
||||
let { hashtag, ...params } = columnMode ? {} : useParams();
|
||||
if (props.hashtag) hashtag = props.hashtag;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import './notifications-menu.css';
|
||||
|
||||
import { msg, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { ControlledMenu } from '@szhsin/react-menu';
|
||||
import { memo } from 'preact/compat';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
|
@ -62,6 +62,7 @@ function Home() {
|
|||
}
|
||||
|
||||
function NotificationsLink() {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const notificationLinkRef = useRef();
|
||||
const [menuState, setMenuState] = useState(undefined);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans } from '@lingui/react/macro';
|
||||
import { useLayoutEffect, useState } from 'preact/hooks';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './lists.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { Menu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { InView } from 'react-intersection-observer';
|
||||
|
@ -25,6 +25,7 @@ import useTitle from '../utils/useTitle';
|
|||
const LIMIT = 20;
|
||||
|
||||
function List(props) {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const { masto, instance } = api();
|
||||
const id = props?.id || useParams()?.id;
|
||||
|
@ -222,6 +223,7 @@ function List(props) {
|
|||
|
||||
const MEMBERS_LIMIT = 40;
|
||||
function ListManageMembers({ listID, onClose }) {
|
||||
const { t } = useLingui();
|
||||
// Show list of members with [Remove] button
|
||||
// API only returns 40 members at a time, so this need to be paginated with infinite scroll
|
||||
// Show [Add] button after removing a member
|
||||
|
@ -301,6 +303,7 @@ function ListManageMembers({ listID, onClose }) {
|
|||
}
|
||||
|
||||
function RemoveAddButton({ account, listID }) {
|
||||
const { t } = useLingui();
|
||||
const { masto } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [removed, setRemoved] = useState(false);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './lists.css';
|
||||
|
||||
import { Plural, t, Trans } from '@lingui/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useReducer, useState } from 'preact/hooks';
|
||||
|
||||
import Icon from '../components/icon';
|
||||
|
@ -13,6 +13,7 @@ import { fetchLists } from '../utils/lists';
|
|||
import useTitle from '../utils/useTitle';
|
||||
|
||||
function Lists() {
|
||||
const { t } = useLingui();
|
||||
useTitle(t`Lists`, `/l`);
|
||||
const [uiState, setUIState] = useState('default');
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './login.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import Fuse from 'fuse.js';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
|
@ -23,6 +23,7 @@ import useTitle from '../utils/useTitle';
|
|||
const { PHANPY_DEFAULT_INSTANCE: DEFAULT_INSTANCE } = import.meta.env;
|
||||
|
||||
function Login() {
|
||||
const { t } = useLingui();
|
||||
useTitle('Log in');
|
||||
const instanceURLRef = useRef();
|
||||
const cachedInstanceURL = store.local.get('instanceURL');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useMemo, useRef, useState } from 'preact/hooks';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
|
||||
|
@ -13,6 +13,7 @@ const LIMIT = 20;
|
|||
const emptySearchParams = new URLSearchParams();
|
||||
|
||||
function Mentions({ columnMode, ...props }) {
|
||||
const { t } = useLingui();
|
||||
const { masto, instance } = api();
|
||||
const [searchParams] = columnMode ? [emptySearchParams] : useSearchParams();
|
||||
const [stateType, setStateType] = useState(null);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import './notifications.css';
|
||||
|
||||
import { msg, Plural, t, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { Fragment } from 'preact';
|
||||
import { memo } from 'preact/compat';
|
||||
import {
|
||||
|
@ -109,7 +109,7 @@ const NOTIFICATIONS_POLICIES_TEXT = {
|
|||
};
|
||||
|
||||
function Notifications({ columnMode }) {
|
||||
const { _ } = useLingui();
|
||||
const { _, t } = useLingui();
|
||||
useTitle(t`Notifications`, '/notifications');
|
||||
const { masto, instance } = api();
|
||||
const snapStates = useSnapshot(states);
|
||||
|
@ -1173,6 +1173,7 @@ function NotificationRequestModalButton({ request }) {
|
|||
}
|
||||
|
||||
function NotificationRequestButtons({ request, onChange }) {
|
||||
const { t } = useLingui();
|
||||
const { masto } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [requestState, setRequestState] = useState(null); // accept, dismiss
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { Menu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import { useRef } from 'preact/hooks';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
|
@ -16,6 +16,7 @@ import useTitle from '../utils/useTitle';
|
|||
const LIMIT = 20;
|
||||
|
||||
function Public({ local, columnMode, ...props }) {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const isLocal = !!local;
|
||||
const params = columnMode ? {} : useParams();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import './search.css';
|
||||
|
||||
import { useAutoAnimate } from '@formkit/auto-animate/preact';
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { InView } from 'react-intersection-observer';
|
||||
|
@ -31,6 +31,7 @@ const scrollIntoViewOptions = {
|
|||
};
|
||||
|
||||
function Search({ columnMode, ...props }) {
|
||||
const { t } = useLingui();
|
||||
const params = columnMode ? {} : useParams();
|
||||
const { masto, instance, authenticated } = api({
|
||||
instance: params.instance,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './settings.css';
|
||||
|
||||
import { Plural, t, Trans } from '@lingui/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
|
@ -36,6 +36,7 @@ const {
|
|||
} = import.meta.env;
|
||||
|
||||
function Settings({ onClose }) {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const currentTheme = store.local.get('theme') || 'auto';
|
||||
const themeFormRef = useRef();
|
||||
|
@ -957,6 +958,7 @@ async function clearCaches() {
|
|||
}
|
||||
|
||||
function PushNotificationsSection({ onClose }) {
|
||||
const { t } = useLingui();
|
||||
if (!isPushSupported()) return null;
|
||||
|
||||
const { instance } = api();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './status.css';
|
||||
|
||||
import { Plural, t, Trans } from '@lingui/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { Menu, MenuDivider, MenuHeader, MenuItem } from '@szhsin/react-menu';
|
||||
import debounce from 'just-debounce-it';
|
||||
import pRetry from 'p-retry';
|
||||
|
@ -73,6 +73,7 @@ const STATUSES_SELECTOR =
|
|||
const STATUS_URL_REGEX = /\/s\//i;
|
||||
|
||||
function StatusPage(params) {
|
||||
const { t } = useLingui();
|
||||
const { id } = params;
|
||||
const { masto, instance } = api({ instance: params.instance });
|
||||
const snapStates = useSnapshot(states);
|
||||
|
@ -214,6 +215,7 @@ function createdAtSort(a, b) {
|
|||
}
|
||||
|
||||
function StatusThread({ id, closeLink = '/', instance: propInstance }) {
|
||||
const { t } = useLingui();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const mediaParam = searchParams.get('media');
|
||||
const mediaStatusID = searchParams.get('mediaStatusID');
|
||||
|
@ -1377,6 +1379,7 @@ function SubComments({
|
|||
openAll,
|
||||
parentLink,
|
||||
}) {
|
||||
const { t } = useLingui();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
||||
// Total comments count, including sub-replies
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import '../components/links-bar.css';
|
||||
import './trending.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { MenuItem } from '@szhsin/react-menu';
|
||||
import { getBlurHashAverageColor } from 'fast-blurhash';
|
||||
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
||||
|
@ -62,6 +62,7 @@ function fetchLinkList(masto, params) {
|
|||
}
|
||||
|
||||
function Trending({ columnMode, ...props }) {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
const params = columnMode ? {} : useParams();
|
||||
const { masto, instance } = api({
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './welcome.css';
|
||||
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
|
||||
import boostsCarouselUrl from '../assets/features/boosts-carousel.jpg';
|
||||
import groupedNotificationsUrl from '../assets/features/grouped-notifications.jpg';
|
||||
|
@ -31,6 +31,7 @@ const appVersion = __BUILD_TIME__
|
|||
: null;
|
||||
|
||||
function Welcome() {
|
||||
const { t } = useLingui();
|
||||
useTitle(null, ['/', '/welcome']);
|
||||
return (
|
||||
<main id="welcome">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { t } from '@lingui/core/macro';
|
||||
|
||||
export default function openCompose(opts) {
|
||||
const url = URL.parse('/compose/', window.location);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { t, Trans } from '@lingui/macro';
|
||||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import openOSK from './open-osk';
|
||||
import showToast from './show-toast';
|
||||
|
|
Loading…
Reference in a new issue