Publish Preview: i18n

Fix remaining fields
This commit is contained in:
infinite-persistence 2022-03-29 15:20:55 +08:00 committed by Thomas Zarebczan
parent e358f0715d
commit 2fb0e00bc0
2 changed files with 16 additions and 4 deletions

View file

@ -4,7 +4,7 @@ import ModalPublishPreview from './view';
import { makeSelectPublishFormValue, selectPublishFormValues, selectIsStillEditing } from 'redux/selectors/publish';
import { selectMyChannelClaims, selectIsStreamPlaceholderForUri } from 'redux/selectors/claims';
import * as SETTINGS from 'constants/settings';
import { selectFfmpegStatus, selectClientSetting } from 'redux/selectors/settings';
import { selectFfmpegStatus, selectClientSetting, selectLanguage } from 'redux/selectors/settings';
import { doPublishDesktop } from 'redux/actions/publish';
import { doSetClientSetting } from 'redux/actions/settings';
@ -22,6 +22,7 @@ const select = (state, props) => {
ffmpegStatus: selectFfmpegStatus(state),
enablePublishPreview: selectClientSetting(state, SETTINGS.ENABLE_PUBLISH_PREVIEW),
isLivestreamClaim: selectIsStreamPlaceholderForUri(state, editingUri),
appLanguage: selectLanguage(state), // note: publishForm above has 'language'
};
};

View file

@ -7,6 +7,7 @@ import { Modal } from 'modal/modal';
import Card from 'component/common/card';
import Tag from 'component/tag';
import MarkdownPreview from 'component/common/markdown-preview';
import { getLanguageName } from 'constants/languages';
import { COPYRIGHT, OTHER } from 'constants/licenses';
import LbcSymbol from 'component/common/lbc-symbol';
import ChannelThumbnail from 'component/channelThumbnail';
@ -48,6 +49,7 @@ type Props = {
publishing: boolean,
isLivestreamClaim: boolean,
remoteFile: string,
appLanguage: string,
};
// class ModalPublishPreview extends React.PureComponent<Props> {
@ -82,6 +84,7 @@ const ModalPublishPreview = (props: Props) => {
closeModal,
isLivestreamClaim,
remoteFile,
appLanguage,
} = props;
const maxCharsBeforeOverflow = 128;
@ -198,7 +201,7 @@ const ModalPublishPreview = (props: Props) => {
{licenseUrl}
</p>
) : (
<p>{licenseType}</p>
<p>{__(licenseType)}</p>
);
const visibleTags = tags.filter((tag) => !INTERNAL_TAGS.includes(tag.name));
@ -234,7 +237,15 @@ const ModalPublishPreview = (props: Props) => {
};
const releaseTimeStr = (time) => {
return time ? moment(new Date(time * 1000)).format('MMMM Do, YYYY - h:mm a') : '';
if (time) {
try {
return new Date(time * 1000).toLocaleString(appLanguage);
} catch {
return moment(new Date(time * 1000)).format('MMMM Do, YYYY - h:mm a');
}
} else {
return '';
}
};
return (
@ -256,7 +267,7 @@ const ModalPublishPreview = (props: Props) => {
{createRow(__('URL'), formattedUri)}
{createRow(__('Deposit'), depositValue)}
{createRow(__('Price'), priceValue)}
{createRow(__('Language'), language)}
{createRow(__('Language'), language ? getLanguageName(language) : '')}
{releaseTimeEdited && createRow(releaseDateText, releaseTimeStr(releaseTimeEdited))}
{createRow(__('License'), licenseValue)}
{createRow(__('Tags'), tagsValue)}