-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: translation data migrations (#643)
# Pull Request type Please check the type of change your PR introduces: - [x] Bugfix - Link up nav menu pages - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [ ] Build-related changes - [ ] Documentation content changes - [x] Other (please describe): - update translation keys in db - update translation keys on CrowdIn ## What is the current behavior? Issue Number: N/A ## What is the new behavior? - - - ## Does this introduce a breaking change? - [ ] Yes - [ ] No ## Other information PR-URL: #643 Co-authored-by: Joe Karow <58997957+JoeKarow@users.noreply.github.com>
- Loading branch information
Showing
48 changed files
with
568 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Center, Grid, Loader, Overlay, Stack, Title } from '@mantine/core' | ||
import { type GetServerSideProps, InferGetServerSidePropsType } from 'next' | ||
import { useRouter } from 'next/router' | ||
import { useSession } from 'next-auth/react' | ||
import { useTranslation } from 'next-i18next' | ||
|
||
import { getServerSession } from '@weareinreach/auth' | ||
import { QuickPromotionModal } from '@weareinreach/ui/modals' | ||
import { getServerSideTranslations } from '~app/utils/i18n' | ||
|
||
const Reviews = () => { | ||
const { t } = useTranslation('common') | ||
const { data: session, status } = useSession() | ||
const router = useRouter() | ||
if (status === 'loading') { | ||
return ( | ||
<Center> | ||
<Loader /> | ||
</Center> | ||
) | ||
} | ||
if (status === 'unauthenticated' || session === null) { | ||
return ( | ||
<Overlay blur={2}> | ||
<QuickPromotionModal autoLaunch onClose={() => router.replace('/')} /> | ||
</Overlay> | ||
) | ||
} | ||
|
||
return ( | ||
<Grid.Col xs={12} sm={12}> | ||
<Stack h='100vh' align='flex-start' w='100%'> | ||
<Title order={2}>{t('words.reviews')}</Title> | ||
<Stack spacing={0} align='center' justify='center' h='100%' w='100%'> | ||
<Title order={2}>🚧</Title> | ||
<Title order={2}>{t('words.coming-soon')}</Title> | ||
</Stack> | ||
</Stack> | ||
</Grid.Col> | ||
) | ||
} | ||
|
||
export const getServerSideProps: GetServerSideProps = async ({ locale, req, res }) => { | ||
const session = await getServerSession({ req, res }) | ||
|
||
return { | ||
props: { | ||
session, | ||
...(await getServerSideTranslations(locale, ['common'])), | ||
}, | ||
} | ||
} | ||
export default Reviews |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
crowdin/generated/*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { kv as redis } from '@vercel/kv' | ||
import { Logger } from 'tslog' | ||
|
||
const log = new Logger({ name: 'Cache - Slug to OrgId' }) | ||
|
||
export const readSlugCache = async (slug: string) => { | ||
try { | ||
if ((await redis.ping()) !== 'PONG') { | ||
log.warn('Skipping cache read - Redis client not connected') | ||
return null | ||
} | ||
const organizationId = await redis.hget<string>('slugToOrgId', slug) | ||
return organizationId | ||
} catch (err) { | ||
log.error(err) | ||
return null | ||
} | ||
} | ||
|
||
export const writeSlugCache = async (slug: string, organizationId: string) => { | ||
try { | ||
if ((await redis.ping()) !== 'PONG') { | ||
log.warn('Skipping cache write - Redis client not connected') | ||
return | ||
} | ||
await redis.hset('slugToOrgId', { [slug]: organizationId }) | ||
} catch (err) { | ||
log.error(err) | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
import { prisma } from '@weareinreach/db' | ||
import { crowdinApi } from '~api/crowdin/client' | ||
|
||
interface KeyData { | ||
key: string | ||
crowdinId: number | ||
slug: string | ||
} | ||
|
||
interface TestData { | ||
id: number | ||
key: string | ||
} | ||
|
||
const run = async () => { | ||
const data = await prisma.translationKey.findMany({ | ||
where: { ns: 'org-data' }, | ||
select: { key: true, crowdinId: true }, | ||
}) | ||
|
||
const batchSize = 100 | ||
const totalBatches = Math.ceil(data.length / batchSize) | ||
let batchCount = 1 | ||
while (data.length) { | ||
const batch = data.splice(0, batchSize) | ||
|
||
console.log(`[${batchCount}/${totalBatches}] Processing ${batch.length} items.`) | ||
|
||
const result = await crowdinApi.sourceStringsApi.stringBatchOperations( | ||
12, | ||
batch.map(({ key, crowdinId }) => ({ | ||
op: 'replace', | ||
path: `/${crowdinId}/identifier`, | ||
value: key, | ||
})) | ||
) | ||
// const result = { data: batch } | ||
console.log(`\tResult count: ${result.data.length}`) | ||
batchCount++ | ||
} | ||
|
||
// const updates = await crowdinApi.sourceStringsApi.stringBatchOperations( | ||
// 12, | ||
// data.map(({ key, crowdinId, slug }) => ({ | ||
// op: 'replace', | ||
// path: `/${crowdinId}/context`, | ||
// value: `https://app.inreach.org/org/${slug}`, | ||
// })) | ||
// ) | ||
// console.log(updates) | ||
} | ||
|
||
run() | ||
|
||
const test = async () => { | ||
// const out: Record<string, string> = {} | ||
// for (let i = 0; i < 5000; i++) { | ||
// out[`key-${i.toString().padStart(4, '0')}`] = `Text item ${i.toString().padStart(4, '0')}` | ||
// } | ||
const data: unknown[] = [] | ||
for (let i = 0; i < 10; i++) { | ||
console.log(`Batch ${i + 1}`) | ||
const result = await crowdinApi.sourceStringsApi.listProjectStrings(14, { | ||
fileId: 3141, | ||
limit: 500, | ||
offset: 500 * i, | ||
}) | ||
data.push(...result.data.map(({ data }) => ({ id: data.id, key: data.identifier }))) | ||
} | ||
fs.writeFileSync('data.json', JSON.stringify(data)) | ||
} | ||
// test() |
Oops, something went wrong.