mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06:00
fix: tolgee flow (#4765)
This commit is contained in:
committed by
GitHub
parent
ae3524b79f
commit
0e748050f3
30
.github/workflows/tolgee.yml
vendored
30
.github/workflows/tolgee.yml
vendored
@@ -30,13 +30,37 @@ jobs:
|
||||
npx tolgee tag \
|
||||
--api-key ${{ secrets.TOLGEE_API_KEY }} \
|
||||
--filter-extracted \
|
||||
--filter-tag "draft: ${BRANCH_NAME}" \
|
||||
--filter-tag "draft:${BRANCH_NAME}" \
|
||||
--tag production \
|
||||
--untag "draft: ${BRANCH_NAME}"
|
||||
--untag "draft:${BRANCH_NAME}"
|
||||
|
||||
- name: Tag Deprecated Keys
|
||||
- name: Tag unused production keys as Deprecated
|
||||
run: |
|
||||
npx tolgee tag \
|
||||
--api-key ${{ secrets.TOLGEE_API_KEY }} \
|
||||
--filter-not-extracted --filter-tag production \
|
||||
--tag deprecated --untag production
|
||||
|
||||
- name: Tag unused draft:current-branch keys as Deprecated
|
||||
run: |
|
||||
BRANCH_NAME=${GITHUB_REF##*/}
|
||||
npx tolgee tag \
|
||||
--api-key ${{ secrets.TOLGEE_API_KEY }} \
|
||||
--filter-not-extracted --filter-tag "draft:${BRANCH_NAME}" \
|
||||
--tag deprecated --untag "draft:${BRANCH_NAME}"
|
||||
|
||||
- name: Sync with backup
|
||||
run: |
|
||||
npx tolgee sync \
|
||||
--api-key ${{ secrets.TOLGEE_API_KEY }} \
|
||||
--backup ./tolgee-backup \
|
||||
--remove-unused \
|
||||
--continue-on-warning \
|
||||
--yes
|
||||
|
||||
- name: Upload backup as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tolgee-backup-${{ github.sha }}
|
||||
path: ./tolgee-backup
|
||||
retention-days: 90
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -59,4 +59,7 @@ packages/lib/uploads
|
||||
apps/web/public/js
|
||||
|
||||
|
||||
packages/database/migrations
|
||||
packages/database/migrations
|
||||
|
||||
# tolgee
|
||||
branch.json
|
||||
@@ -1 +1 @@
|
||||
echo "{\"branchName\": \"$(git rev-parse --abbrev-ref HEAD)\"}" > ../branch.json
|
||||
echo "{\"branchName\": \"$(git rev-parse --abbrev-ref HEAD)\"}" > ./branch.json
|
||||
@@ -1 +1 @@
|
||||
echo "{\"branchName\": \"$(git rev-parse --abbrev-ref HEAD)\"}" > ../branch.json
|
||||
echo "{\"branchName\": \"$(git rev-parse --abbrev-ref HEAD)\"}" > ./branch.json
|
||||
@@ -1,5 +1,17 @@
|
||||
pnpm lint-staged
|
||||
pnpm tolgee-pull || true
|
||||
echo "{\"branchName\": \"main\"}" > ../branch.json
|
||||
git add branch.json packages/lib/messages/*.json
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
# Load environment variables from .env files
|
||||
if [ -f .env ]; then
|
||||
export $(cat .env | grep -v '#' | xargs)
|
||||
fi
|
||||
|
||||
pnpm lint-staged
|
||||
|
||||
if [ -z "$NEXT_PUBLIC_TOLGEE_API_KEY" ]; then
|
||||
echo "Skipping tolgee-pull: NEXT_PUBLIC_TOLGEE_API_KEY is not set"
|
||||
else
|
||||
pnpm run tolgee-pull
|
||||
git add packages/lib/messages
|
||||
fi
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { TolgeeProvider, TolgeeStaticData } from "@tolgee/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
import { branchName } from "../../../branch.json";
|
||||
import branch from "../../../branch.json";
|
||||
import { TolgeeBase } from "./shared";
|
||||
|
||||
type Props = {
|
||||
@@ -13,7 +13,7 @@ type Props = {
|
||||
};
|
||||
|
||||
const tolgee = TolgeeBase().init({
|
||||
tagNewKeys: [`draft: ${branchName}`],
|
||||
tagNewKeys: [`draft:${branch.branchName}`],
|
||||
});
|
||||
|
||||
export const TolgeeNextProvider = ({ language, staticData, children }: Props) => {
|
||||
@@ -25,6 +25,7 @@ export const TolgeeNextProvider = ({ language, staticData, children }: Props) =>
|
||||
router.refresh();
|
||||
});
|
||||
return () => unsubscribe();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [tolgee, router]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createServerInstance } from "@tolgee/react/server";
|
||||
import { branchName } from "../../../branch.json";
|
||||
import branch from "../../../branch.json";
|
||||
import { getLocale } from "./language";
|
||||
import { TolgeeBase } from "./shared";
|
||||
|
||||
@@ -7,7 +7,7 @@ export const { getTolgee, getTranslate, T } = createServerInstance({
|
||||
getLocale: getLocale,
|
||||
createTolgee: async (language) => {
|
||||
return TolgeeBase().init({
|
||||
tagNewKeys: [`draft: ${branchName}`],
|
||||
tagNewKeys: [`draft:${branch.branchName}`],
|
||||
observerOptions: {
|
||||
fullKeyEncode: true,
|
||||
},
|
||||
|
||||
@@ -1 +1 @@
|
||||
{ "branchName": "main" }
|
||||
{"branchName": "fix-tolgee-flow"}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
"prepare": "husky install",
|
||||
"storybook": "turbo run storybook",
|
||||
"fb-migrate-dev": "pnpm --filter @formbricks/database create-migration && pnpm prisma generate",
|
||||
"tolgee-pull": "tolgee pull && prettier --write ./packages/lib/messages/*.json"
|
||||
"tolgee-pull": "BRANCH_NAME=$(node -p \"require('./branch.json').branchName\") && tolgee pull --tags \"draft:$BRANCH_NAME\" \"production\" && prettier --write ./packages/lib/messages/*.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@azure/microsoft-playwright-testing": "1.0.0-beta.6",
|
||||
|
||||
Reference in New Issue
Block a user