chore: add missing translations (#5929)

This commit is contained in:
Paul
2024-04-20 15:57:22 -03:00
committed by GitHub
parent 56df60f520
commit 7b263be01b
13 changed files with 52 additions and 31 deletions

View File

@@ -4,6 +4,7 @@ import { forgotPasswordOperation } from 'payload/operations'
import type { CollectionRouteHandler } from '../types.js' import type { CollectionRouteHandler } from '../types.js'
export const forgotPassword: CollectionRouteHandler = async ({ collection, req }) => { export const forgotPassword: CollectionRouteHandler = async ({ collection, req }) => {
const { t } = req
await forgotPasswordOperation({ await forgotPasswordOperation({
collection, collection,
data: { data: {
@@ -16,8 +17,7 @@ export const forgotPassword: CollectionRouteHandler = async ({ collection, req }
return Response.json( return Response.json(
{ {
// TODO(translate) message: t('general:success'),
message: 'Success',
}, },
{ {
status: httpStatus.OK, status: httpStatus.OK,

View File

@@ -6,7 +6,7 @@ import { isNumber } from 'payload/utilities'
import type { CollectionRouteHandler } from '../types.js' import type { CollectionRouteHandler } from '../types.js'
export const login: CollectionRouteHandler = async ({ collection, req }) => { export const login: CollectionRouteHandler = async ({ collection, req }) => {
const { searchParams } = req const { searchParams, t } = req
const depth = searchParams.get('depth') const depth = searchParams.get('depth')
const result = await loginOperation({ const result = await loginOperation({
@@ -31,8 +31,7 @@ export const login: CollectionRouteHandler = async ({ collection, req }) => {
return Response.json( return Response.json(
{ {
// TODO(translate) message: t('authentication:passed'),
message: 'Auth Passed',
...result, ...result,
}, },
{ {

View File

@@ -5,6 +5,7 @@ import { logoutOperation } from 'payload/operations'
import type { CollectionRouteHandler } from '../types.js' import type { CollectionRouteHandler } from '../types.js'
export const logout: CollectionRouteHandler = async ({ collection, req }) => { export const logout: CollectionRouteHandler = async ({ collection, req }) => {
const { t } = req
const result = await logoutOperation({ const result = await logoutOperation({
collection, collection,
req, req,
@@ -13,7 +14,7 @@ export const logout: CollectionRouteHandler = async ({ collection, req }) => {
if (!result) { if (!result) {
return Response.json( return Response.json(
{ {
message: 'Logout failed.', message: t('error:logoutFailed'),
}, },
{ {
status: httpStatus.BAD_REQUEST, status: httpStatus.BAD_REQUEST,
@@ -28,8 +29,7 @@ export const logout: CollectionRouteHandler = async ({ collection, req }) => {
return Response.json( return Response.json(
{ {
// TODO(translate) message: t('authentication:logoutSuccessful'),
message: 'Logout successful.',
}, },
{ {
headers: new Headers({ headers: new Headers({

View File

@@ -6,13 +6,13 @@ import { refreshOperation } from 'payload/operations'
import type { CollectionRouteHandler } from '../types.js' import type { CollectionRouteHandler } from '../types.js'
export const refresh: CollectionRouteHandler = async ({ collection, req }) => { export const refresh: CollectionRouteHandler = async ({ collection, req }) => {
const { t } = req
const token = typeof req.data?.token === 'string' ? req.data.token : extractJWT(req) const token = typeof req.data?.token === 'string' ? req.data.token : extractJWT(req)
if (!token) { if (!token) {
return Response.json( return Response.json(
{ {
// TODO(translate) message: t('error:tokenNotProvided'),
message: 'Token not provided.',
}, },
{ {
status: httpStatus.UNAUTHORIZED, status: httpStatus.UNAUTHORIZED,
@@ -38,8 +38,7 @@ export const refresh: CollectionRouteHandler = async ({ collection, req }) => {
return Response.json( return Response.json(
{ {
// TODO(translate) message: t('authentication:tokenRefreshSuccessful'),
message: 'Token refresh successful',
...result, ...result,
}, },
{ {

View File

@@ -6,7 +6,7 @@ import { registerFirstUserOperation } from 'payload/operations'
import type { CollectionRouteHandler } from '../types.js' import type { CollectionRouteHandler } from '../types.js'
export const registerFirstUser: CollectionRouteHandler = async ({ collection, req }) => { export const registerFirstUser: CollectionRouteHandler = async ({ collection, req }) => {
const data = req.data const { data, t } = req
if (data?.password !== data['confirm-password']) { if (data?.password !== data['confirm-password']) {
throw new ValidationError([ throw new ValidationError([
@@ -36,8 +36,7 @@ export const registerFirstUser: CollectionRouteHandler = async ({ collection, re
return Response.json( return Response.json(
{ {
exp: result.exp, exp: result.exp,
// TODO(translate) message: t('authentication:successfullyRegisteredFirstUser'),
message: 'Successfully registered first user.',
token: result.token, token: result.token,
user: result.user, user: result.user,
}, },

View File

@@ -5,7 +5,7 @@ import { resetPasswordOperation } from 'payload/operations'
import type { CollectionRouteHandler } from '../types.js' import type { CollectionRouteHandler } from '../types.js'
export const resetPassword: CollectionRouteHandler = async ({ collection, req }) => { export const resetPassword: CollectionRouteHandler = async ({ collection, req }) => {
const { searchParams } = req const { searchParams, t } = req
const depth = searchParams.get('depth') const depth = searchParams.get('depth')
const result = await resetPasswordOperation({ const result = await resetPasswordOperation({
@@ -30,8 +30,7 @@ export const resetPassword: CollectionRouteHandler = async ({ collection, req })
return Response.json( return Response.json(
{ {
// TODO(translate) message: t('authentication:passwordResetSuccessfully'),
message: 'Password reset successfully.',
...result, ...result,
}, },
{ {

View File

@@ -4,6 +4,8 @@ import { unlockOperation } from 'payload/operations'
import type { CollectionRouteHandler } from '../types.js' import type { CollectionRouteHandler } from '../types.js'
export const unlock: CollectionRouteHandler = async ({ collection, req }) => { export const unlock: CollectionRouteHandler = async ({ collection, req }) => {
const { t } = req
await unlockOperation({ await unlockOperation({
collection, collection,
data: { email: req.data.email as string }, data: { email: req.data.email as string },
@@ -12,8 +14,7 @@ export const unlock: CollectionRouteHandler = async ({ collection, req }) => {
return Response.json( return Response.json(
{ {
// TODO(translate) message: t('general:success'),
message: 'Success',
}, },
{ {
status: httpStatus.OK, status: httpStatus.OK,

View File

@@ -4,6 +4,7 @@ import { verifyEmailOperation } from 'payload/operations'
import type { CollectionRouteHandlerWithID } from '../types.js' import type { CollectionRouteHandlerWithID } from '../types.js'
export const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection, req }) => { export const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {
const { t } = req
await verifyEmailOperation({ await verifyEmailOperation({
collection, collection,
req, req,
@@ -12,8 +13,7 @@ export const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection
return Response.json( return Response.json(
{ {
// TODO(translate) message: t('authentication:emailVerified'),
message: 'Email verified successfully.',
}, },
{ {
status: httpStatus.OK, status: httpStatus.OK,

View File

@@ -6,6 +6,7 @@ import { Popup, PopupList } from '@payloadcms/ui/elements/Popup'
import { Chevron } from '@payloadcms/ui/icons/Chevron' import { Chevron } from '@payloadcms/ui/icons/Chevron'
import { LinkIcon } from '@payloadcms/ui/icons/Link' import { LinkIcon } from '@payloadcms/ui/icons/Link'
import { X } from '@payloadcms/ui/icons/X' import { X } from '@payloadcms/ui/icons/X'
import { useTranslation } from '@payloadcms/ui/providers/Translation'
import React from 'react' import React from 'react'
import { useLivePreviewContext } from '../../Context/context.js' import { useLivePreviewContext } from '../../Context/context.js'
@@ -14,14 +15,16 @@ import './index.scss'
const baseClass = 'live-preview-toolbar-controls' const baseClass = 'live-preview-toolbar-controls'
const zoomOptions = [50, 75, 100, 125, 150, 200] const zoomOptions = [50, 75, 100, 125, 150, 200]
const customOption = {
label: 'Custom', // TODO: Add i18n to this string
value: 'custom',
}
export const ToolbarControls: React.FC<EditViewProps> = () => { export const ToolbarControls: React.FC<EditViewProps> = () => {
const { breakpoint, breakpoints, setBreakpoint, setPreviewWindowType, setZoom, url, zoom } = const { breakpoint, breakpoints, setBreakpoint, setPreviewWindowType, setZoom, url, zoom } =
useLivePreviewContext() useLivePreviewContext()
const { t } = useTranslation()
const customOption = {
label: t('general:custom'),
value: 'custom',
}
return ( return (
<div className={baseClass}> <div className={baseClass}>

View File

@@ -44,6 +44,5 @@ export const LogoutClient: React.FC<{
) )
} }
// TODO(i18n): needs translation in all languages return <Fragment>{t('authentication:loggingOut')}</Fragment>
return <Fragment>Logging Out...</Fragment>
} }

View File

@@ -9,12 +9,12 @@ export const richTextValidate: Validate<
unknown, unknown,
RichTextField<any[], AdapterArguments>, RichTextField<any[], AdapterArguments>,
RichTextField<any[], AdapterArguments> RichTextField<any[], AdapterArguments>
> = (value, { required }) => { > = (value, { req, required }) => {
const { t } = req
if (required) { if (required) {
const stringifiedDefaultValue = JSON.stringify(defaultRichTextValue) const stringifiedDefaultValue = JSON.stringify(defaultRichTextValue)
if (value && JSON.stringify(value) !== stringifiedDefaultValue) return true if (value && JSON.stringify(value) !== stringifiedDefaultValue) return true
// TODO: translate this string return t('validation:required')
return 'This field is required.'
} }
return true return true

View File

@@ -12,6 +12,7 @@ export const clientTranslationKeys = [
'authentication:createFirstUser', 'authentication:createFirstUser',
'authentication:emailNotValid', 'authentication:emailNotValid',
'authentication:emailSent', 'authentication:emailSent',
'authentication:emailVerified',
'authentication:enableAPIKey', 'authentication:enableAPIKey',
'authentication:failedToUnlock', 'authentication:failedToUnlock',
'authentication:forceUnlock', 'authentication:forceUnlock',
@@ -23,16 +24,22 @@ export const clientTranslationKeys = [
'authentication:logBackIn', 'authentication:logBackIn',
'authentication:loggedOutInactivity', 'authentication:loggedOutInactivity',
'authentication:loggedOutSuccessfully', 'authentication:loggedOutSuccessfully',
'authentication:loggingOut',
'authentication:login', 'authentication:login',
'authentication:logOut', 'authentication:logOut',
'authentication:logout', 'authentication:logout',
'authentication:logoutUser', 'authentication:logoutUser',
'authentication:logoutSuccessful',
'authentication:newAPIKeyGenerated', 'authentication:newAPIKeyGenerated',
'authentication:newPassword', 'authentication:newPassword',
'authentication:passed',
'authentication:passwordResetSuccessfully',
'authentication:resetPassword', 'authentication:resetPassword',
'authentication:stayLoggedIn', 'authentication:stayLoggedIn',
'authentication:successfullyRegisteredFirstUser',
'authentication:successfullyUnlocked', 'authentication:successfullyUnlocked',
'authentication:unableToVerify', 'authentication:unableToVerify',
'authentication:tokenRefreshSuccessful',
'authentication:verified', 'authentication:verified',
'authentication:verifiedSuccessfully', 'authentication:verifiedSuccessfully',
'authentication:verify', 'authentication:verify',
@@ -43,6 +50,7 @@ export const clientTranslationKeys = [
'error:correctInvalidFields', 'error:correctInvalidFields',
'error:deletingTitle', 'error:deletingTitle',
'error:loadingDocument', 'error:loadingDocument',
'error:logoutFailed',
'error:noMatchedField', 'error:noMatchedField',
'error:notAllowedToAccessPage', 'error:notAllowedToAccessPage',
'error:previewing', 'error:previewing',
@@ -51,6 +59,7 @@ export const clientTranslationKeys = [
'error:unauthorized', 'error:unauthorized',
'error:unknown', 'error:unknown',
'error:unspecific', 'error:unspecific',
'error:tokenNotProvided',
'fields:addLabel', 'fields:addLabel',
'fields:addLink', 'fields:addLink',
@@ -113,6 +122,7 @@ export const clientTranslationKeys = [
'general:createNewLabel', 'general:createNewLabel',
'general:creating', 'general:creating',
'general:creatingNewLabel', 'general:creatingNewLabel',
'general:custom',
'general:dark', 'general:dark',
'general:dashboard', 'general:dashboard',
'general:delete', 'general:delete',
@@ -182,6 +192,7 @@ export const clientTranslationKeys = [
'general:stayOnThisPage', 'general:stayOnThisPage',
'general:submissionSuccessful', 'general:submissionSuccessful',
'general:submit', 'general:submit',
'general:success',
'general:successfullyCreated', 'general:successfullyCreated',
'general:successfullyDeleted', 'general:successfullyDeleted',
'general:thisLanguage', 'general:thisLanguage',

View File

@@ -19,6 +19,7 @@ export const en: Language = {
createFirstUser: 'Create first user', createFirstUser: 'Create first user',
emailNotValid: 'The email provided is not valid', emailNotValid: 'The email provided is not valid',
emailSent: 'Email Sent', emailSent: 'Email Sent',
emailVerified: 'Email verified successfully.',
enableAPIKey: 'Enable API Key', enableAPIKey: 'Enable API Key',
failedToUnlock: 'Failed to unlock', failedToUnlock: 'Failed to unlock',
forceUnlock: 'Force Unlock', forceUnlock: 'Force Unlock',
@@ -38,22 +39,28 @@ export const en: Language = {
'To change your password, go to your <0>account</0> and edit your password there.', 'To change your password, go to your <0>account</0> and edit your password there.',
loggedOutInactivity: 'You have been logged out due to inactivity.', loggedOutInactivity: 'You have been logged out due to inactivity.',
loggedOutSuccessfully: 'You have been logged out successfully.', loggedOutSuccessfully: 'You have been logged out successfully.',
loggingOut: 'Logging out...',
login: 'Login', login: 'Login',
loginAttempts: 'Login Attempts', loginAttempts: 'Login Attempts',
loginUser: 'Login user', loginUser: 'Login user',
loginWithAnotherUser: 'To log in with another user, you should <0>log out</0> first.', loginWithAnotherUser: 'To log in with another user, you should <0>log out</0> first.',
logout: 'Logout', logout: 'Logout',
logoutSuccessful: 'Logout successful.',
logoutUser: 'Logout user', logoutUser: 'Logout user',
newAPIKeyGenerated: 'New API Key Generated.', newAPIKeyGenerated: 'New API Key Generated.',
newAccountCreated: newAccountCreated:
'A new account has just been created for you to access <a href="{{serverURL}}">{{serverURL}}</a> Please click on the following link or paste the URL below into your browser to verify your email: <a href="{{verificationURL}}">{{verificationURL}}</a><br> After verifying your email, you will be able to log in successfully.', 'A new account has just been created for you to access <a href="{{serverURL}}">{{serverURL}}</a> Please click on the following link or paste the URL below into your browser to verify your email: <a href="{{verificationURL}}">{{verificationURL}}</a><br> After verifying your email, you will be able to log in successfully.',
newPassword: 'New Password', newPassword: 'New Password',
passed: 'Authentication Passed',
passwordResetSuccessfully: 'Password reset successfully.',
resetPassword: 'Reset Password', resetPassword: 'Reset Password',
resetPasswordExpiration: 'Reset Password Expiration', resetPasswordExpiration: 'Reset Password Expiration',
resetPasswordToken: 'Reset Password Token', resetPasswordToken: 'Reset Password Token',
resetYourPassword: 'Reset Your Password', resetYourPassword: 'Reset Your Password',
stayLoggedIn: 'Stay logged in', stayLoggedIn: 'Stay logged in',
successfullyRegisteredFirstUser: 'Successfully registered first user.',
successfullyUnlocked: 'Successfully unlocked', successfullyUnlocked: 'Successfully unlocked',
tokenRefreshSuccessful: 'Token refresh successful.',
unableToVerify: 'Unable to Verify', unableToVerify: 'Unable to Verify',
verified: 'Verified', verified: 'Verified',
verifiedSuccessfully: 'Verified Successfully', verifiedSuccessfully: 'Verified Successfully',
@@ -83,6 +90,7 @@ export const en: Language = {
loadingDocument: 'There was a problem loading the document with ID of {{id}}.', loadingDocument: 'There was a problem loading the document with ID of {{id}}.',
localesNotSaved_one: 'The following locale could not be saved:', localesNotSaved_one: 'The following locale could not be saved:',
localesNotSaved_other: 'The following locales could not be saved:', localesNotSaved_other: 'The following locales could not be saved:',
logoutFailed: 'Logout failed.',
missingEmail: 'Missing email.', missingEmail: 'Missing email.',
missingIDOfDocument: 'Missing ID of document to update.', missingIDOfDocument: 'Missing ID of document to update.',
missingIDOfVersion: 'Missing ID of version.', missingIDOfVersion: 'Missing ID of version.',
@@ -96,6 +104,7 @@ export const en: Language = {
previewing: 'There was a problem previewing this document.', previewing: 'There was a problem previewing this document.',
problemUploadingFile: 'There was a problem while uploading the file.', problemUploadingFile: 'There was a problem while uploading the file.',
tokenInvalidOrExpired: 'Token is either invalid or has expired.', tokenInvalidOrExpired: 'Token is either invalid or has expired.',
tokenNotProvided: 'Token not provided.',
unPublishingDocument: 'There was a problem while un-publishing this document.', unPublishingDocument: 'There was a problem while un-publishing this document.',
unableToDeleteCount: 'Unable to delete {{count}} out of {{total}} {{label}}.', unableToDeleteCount: 'Unable to delete {{count}} out of {{total}} {{label}}.',
unableToUpdateCount: 'Unable to update {{count}} out of {{total}} {{label}}.', unableToUpdateCount: 'Unable to update {{count}} out of {{total}} {{label}}.',
@@ -185,6 +194,7 @@ export const en: Language = {
createdAt: 'Created At', createdAt: 'Created At',
creating: 'Creating', creating: 'Creating',
creatingNewLabel: 'Creating new {{label}}', creatingNewLabel: 'Creating new {{label}}',
custom: 'Custom',
dark: 'Dark', dark: 'Dark',
dashboard: 'Dashboard', dashboard: 'Dashboard',
delete: 'Delete', delete: 'Delete',
@@ -261,6 +271,7 @@ export const en: Language = {
stayOnThisPage: 'Stay on this page', stayOnThisPage: 'Stay on this page',
submissionSuccessful: 'Submission Successful.', submissionSuccessful: 'Submission Successful.',
submit: 'Submit', submit: 'Submit',
success: 'Success',
successfullyCreated: '{{label}} successfully created.', successfullyCreated: '{{label}} successfully created.',
successfullyDuplicated: '{{label}} successfully duplicated.', successfullyDuplicated: '{{label}} successfully duplicated.',
thisLanguage: 'English', thisLanguage: 'English',