Skip to content

Commit

Permalink
Translate strings in src/lib/api/index.ts (#5750)
Browse files Browse the repository at this point in the history
  • Loading branch information
surfdude29 authored Oct 14, 2024
1 parent ef5bc52 commit 0f40013
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/lib/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ComAtprotoRepoStrongRef,
RichText,
} from '@atproto/api'
import {t} from '@lingui/macro'
import {QueryClient} from '@tanstack/react-query'

import {isNetworkError} from '#/lib/strings/errors'
Expand Down Expand Up @@ -52,7 +53,7 @@ export async function post(
{cleanNewlines: true},
)

opts.onStateChange?.('Processing...')
opts.onStateChange?.(t`Processing...`)

await rt.detectFacets(agent)

Expand Down Expand Up @@ -102,7 +103,7 @@ export async function post(

let res
try {
opts.onStateChange?.('Posting...')
opts.onStateChange?.(t`Posting...`)
res = await agent.post({
text: rt.text,
facets: rt.facets,
Expand All @@ -117,7 +118,7 @@ export async function post(
})
if (isNetworkError(e)) {
throw new Error(
'Post failed to upload. Please check your Internet connection and try again.',
t`Post failed to upload. Please check your Internet connection and try again.`,
)
} else {
throw e
Expand All @@ -141,7 +142,7 @@ export async function post(
safeMessage: e.message,
})
throw new Error(
'Failed to save post interaction settings. Your post was created but users may be able to interact with it.',
t`Failed to save post interaction settings. Your post was created but users may be able to interact with it.`,
)
}
}
Expand All @@ -166,7 +167,7 @@ export async function post(
safeMessage: e.message,
})
throw new Error(
'Failed to save post interaction settings. Your post was created but users may be able to interact with it.',
t`Failed to save post interaction settings. Your post was created but users may be able to interact with it.`,
)
}
}
Expand Down Expand Up @@ -248,7 +249,7 @@ async function resolveMedia(
logger.debug(`Uploading images`, {
count: imagesDraft.length,
})
onStateChange?.(`Uploading images...`)
onStateChange?.(t`Uploading images...`)
const images: AppBskyEmbedImages.Image[] = await Promise.all(
imagesDraft.map(async (image, i) => {
logger.debug(`Compressing image #${i}`)
Expand Down Expand Up @@ -302,7 +303,7 @@ async function resolveMedia(
)
let blob: BlobRef | undefined
if (resolvedGif.thumb) {
onStateChange?.('Uploading link thumbnail...')
onStateChange?.(t`Uploading link thumbnail...`)
const {path, mime} = resolvedGif.thumb.source
const response = await uploadBlob(agent, path, mime)
blob = response.data.blob
Expand All @@ -326,7 +327,7 @@ async function resolveMedia(
if (resolvedLink.type === 'external') {
let blob: BlobRef | undefined
if (resolvedLink.thumb) {
onStateChange?.('Uploading link thumbnail...')
onStateChange?.(t`Uploading link thumbnail...`)
const {path, mime} = resolvedLink.thumb.source
const response = await uploadBlob(agent, path, mime)
blob = response.data.blob
Expand All @@ -352,7 +353,7 @@ async function resolveRecord(
): Promise<ComAtprotoRepoStrongRef.Main> {
const resolvedLink = await fetchResolveLinkQuery(queryClient, agent, uri)
if (resolvedLink.type !== 'record') {
throw Error('Expected uri to resolve to a record')
throw Error(t`Expected uri to resolve to a record`)
}
return resolvedLink.record
}

0 comments on commit 0f40013

Please sign in to comment.