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'
export const forgotPassword: CollectionRouteHandler = async ({ collection, req }) => {
const { t } = req
await forgotPasswordOperation({
collection,
data: {
@@ -16,8 +17,7 @@ export const forgotPassword: CollectionRouteHandler = async ({ collection, req }
return Response.json(
{
// TODO(translate)
message: 'Success',
message: t('general:success'),
},
{
status: httpStatus.OK,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,6 +4,7 @@ import { verifyEmailOperation } from 'payload/operations'
import type { CollectionRouteHandlerWithID } from '../types.js'
export const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {
const { t } = req
await verifyEmailOperation({
collection,
req,
@@ -12,8 +13,7 @@ export const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection
return Response.json(
{
// TODO(translate)
message: 'Email verified successfully.',
message: t('authentication:emailVerified'),
},
{
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 { LinkIcon } from '@payloadcms/ui/icons/Link'
import { X } from '@payloadcms/ui/icons/X'
import { useTranslation } from '@payloadcms/ui/providers/Translation'
import React from 'react'
import { useLivePreviewContext } from '../../Context/context.js'
@@ -14,14 +15,16 @@ import './index.scss'
const baseClass = 'live-preview-toolbar-controls'
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> = () => {
const { breakpoint, breakpoints, setBreakpoint, setPreviewWindowType, setZoom, url, zoom } =
useLivePreviewContext()
const { t } = useTranslation()
const customOption = {
label: t('general:custom'),
value: 'custom',
}
return (
<div className={baseClass}>

View File

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

View File

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

View File

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

View File

@@ -19,6 +19,7 @@ export const en: Language = {
createFirstUser: 'Create first user',
emailNotValid: 'The email provided is not valid',
emailSent: 'Email Sent',
emailVerified: 'Email verified successfully.',
enableAPIKey: 'Enable API Key',
failedToUnlock: 'Failed to 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.',
loggedOutInactivity: 'You have been logged out due to inactivity.',
loggedOutSuccessfully: 'You have been logged out successfully.',
loggingOut: 'Logging out...',
login: 'Login',
loginAttempts: 'Login Attempts',
loginUser: 'Login user',
loginWithAnotherUser: 'To log in with another user, you should <0>log out</0> first.',
logout: 'Logout',
logoutSuccessful: 'Logout successful.',
logoutUser: 'Logout user',
newAPIKeyGenerated: 'New API Key Generated.',
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.',
newPassword: 'New Password',
passed: 'Authentication Passed',
passwordResetSuccessfully: 'Password reset successfully.',
resetPassword: 'Reset Password',
resetPasswordExpiration: 'Reset Password Expiration',
resetPasswordToken: 'Reset Password Token',
resetYourPassword: 'Reset Your Password',
stayLoggedIn: 'Stay logged in',
successfullyRegisteredFirstUser: 'Successfully registered first user.',
successfullyUnlocked: 'Successfully unlocked',
tokenRefreshSuccessful: 'Token refresh successful.',
unableToVerify: 'Unable to Verify',
verified: 'Verified',
verifiedSuccessfully: 'Verified Successfully',
@@ -83,6 +90,7 @@ export const en: Language = {
loadingDocument: 'There was a problem loading the document with ID of {{id}}.',
localesNotSaved_one: 'The following locale could not be saved:',
localesNotSaved_other: 'The following locales could not be saved:',
logoutFailed: 'Logout failed.',
missingEmail: 'Missing email.',
missingIDOfDocument: 'Missing ID of document to update.',
missingIDOfVersion: 'Missing ID of version.',
@@ -96,6 +104,7 @@ export const en: Language = {
previewing: 'There was a problem previewing this document.',
problemUploadingFile: 'There was a problem while uploading the file.',
tokenInvalidOrExpired: 'Token is either invalid or has expired.',
tokenNotProvided: 'Token not provided.',
unPublishingDocument: 'There was a problem while un-publishing this document.',
unableToDeleteCount: 'Unable to delete {{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',
creating: 'Creating',
creatingNewLabel: 'Creating new {{label}}',
custom: 'Custom',
dark: 'Dark',
dashboard: 'Dashboard',
delete: 'Delete',
@@ -261,6 +271,7 @@ export const en: Language = {
stayOnThisPage: 'Stay on this page',
submissionSuccessful: 'Submission Successful.',
submit: 'Submit',
success: 'Success',
successfullyCreated: '{{label}} successfully created.',
successfullyDuplicated: '{{label}} successfully duplicated.',
thisLanguage: 'English',