diff --git a/.github/scripts/fixTranslations.mjs b/.github/scripts/fixTranslations.mjs index d3d096b44..8110e6a20 100644 --- a/.github/scripts/fixTranslations.mjs +++ b/.github/scripts/fixTranslations.mjs @@ -129,14 +129,6 @@ function fixMdocContent(content, locale) { return content; } -const modifiedFiles = []; - -// Get the list of modified files in the current PR -function getModifiedFiles() { - const output = execSync("git diff --name-only HEAD~1", { encoding: "utf-8" }); - return output.split("\n").filter((file) => file.trim() !== ""); -} - // Format MDX files using Prettier async function formatMdxFile(file) { return new Promise((resolve, reject) => { @@ -179,7 +171,6 @@ async function processFile(file, locale) { if (finalContent !== originalContent) { await fs.writeFile(file, finalContent, "utf-8"); - modifiedFiles.push(file); // Format the file after writing changes if (file.endsWith(".mdx")) { @@ -190,9 +181,9 @@ async function processFile(file, locale) { } } -// Main function to process only modified files +// Main function to process only modified files passed from the GitHub Actions workflow async function main() { - const files = getModifiedFiles(); + const files = process.argv.slice(2); console.log("Modified files:", files); for (const locale of locales) { @@ -205,8 +196,8 @@ async function main() { } } - if (modifiedFiles.length > 0) { - console.log("Processed files:", modifiedFiles.join(", ")); + if (files.length > 0) { + console.log("Processed files:", files.join(", ")); } else { console.log("No relevant files were modified."); } diff --git a/.github/workflows/fix_translations.yml b/.github/workflows/fix_translations.yml index 39c71a8bc..1d9333a65 100644 --- a/.github/workflows/fix_translations.yml +++ b/.github/workflows/fix_translations.yml @@ -1,6 +1,8 @@ name: Fix translations on: pull_request: + types: [opened, synchronize, reopened] + jobs: i18n-fixes: name: Fix translated files @@ -10,12 +12,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.ADJUST_NPM_TOKEN }} steps: - - name: Checkout the full PR history + - name: Checkout the PR branch uses: actions/checkout@v4 with: + ref: ${{ github.event.pull_request.head.ref }} fetch-depth: 0 - # Set up Node.js environment - name: Set up Node.js uses: actions/setup-node@v4 with: @@ -23,26 +25,44 @@ jobs: registry-url: https://npm.pkg.github.com/ scope: "@adjust" - # Install npm dependencies - name: Install dependencies - working-directory: .github/scripts run: npm install - # Run the .mjs script to fix translations and format modified files + - name: Get modified files in the PR + id: files + run: | + git fetch origin ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }} + modified_files=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...${{ github.event.pull_request.head.ref }}) + + { + echo 'modified_files<> $GITHUB_OUTPUT + - name: Run translation fixes script - working-directory: .github/scripts - run: node fixTranslations.mjs + run: | + modified_files="${{ steps.files.outputs.modified_files }}" + modified_files=$(echo "$modified_files" | grep -E '\.mdx$|\.mdoc$') + + if [ -n "$modified_files" ]; then + echo "Files to process: $modified_files" + node .github/scripts/fixTranslations.mjs $modified_files + else + echo "No MDX or MDOC files modified. Skipping translation fixes." + fi - # Check for modified files - - name: Check for modified files + - name: Check for modified files after script id: git-check - run: echo "MODIFIED=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)" >> "$GITHUB_OUTPUT" + run: | + MODIFIED=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi) + echo "MODIFIED=$MODIFIED" >> $GITHUB_ENV + echo "MODIFIED=$MODIFIED" >> $GITHUB_OUTPUT - # Commit and push changes if any files were modified - name: Commit changes if: ${{ steps.git-check.outputs.MODIFIED == 'true' }} run: | git config --global user.name "github-actions" git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git commit -am "Fix translated and formatted files" - git push + git push origin ${{ github.head_ref }} diff --git a/src/content/docs/zh/sdk/react-native/v5/features/att.mdx b/src/content/docs/zh/sdk/react-native/v5/features/att.mdx index 21e8291b6..8a28b1266 100644 --- a/src/content/docs/zh/sdk/react-native/v5/features/att.mdx +++ b/src/content/docs/zh/sdk/react-native/v5/features/att.mdx @@ -14,7 +14,7 @@ redirects: 如果您要记录设备的广告主 ID \(即 IDFA\),需要先展示弹窗获得用户的授权。要达到这个目的,您需要在应用中添加 Apple 的 App Tracking Transparency \(ATT\) 框架。Adjust SDK 会存储用户的授权状态并在每次请求中将该信息发送至 Adjust 服务器。 -## 授权状态{#authorization-statuses} +## 授权状态\{\#authorization\-statuses\} | 状态 | 代码 | 描述 | | --------------------------------------------------- | ---- | -------------------------------------------------- | @@ -29,7 +29,7 @@ redirects: -## ATT 授权包装器{#att-authorization-wrapper} +## ATT 授权包装器\{\#att\-authorization\-wrapper\} @@ -101,7 +101,7 @@ Adjust.requestAppTrackingAuthorization(function (status) { }); ``` -## 获取当前授权状态{#get-current-authorization-status} +## 获取当前授权状态\{\#get\-current\-authorization\-status\} @@ -129,7 +129,7 @@ Adjust.getAppTrackingAuthorizationStatus(function (status) { }); ``` -## 自定义弹窗时机{#custom-prompt-timing} +## 自定义弹窗时机\{\#custom\-prompt\-timing\} @@ -139,7 +139,7 @@ public setAttConsentWaitingInterval(attConsentWaitingInterval: number): void -如果您的应用包含新手引导流程或教程,那么最好在用户完成新手引导流程或教程后再发送用户的 ATT 许可状态。您可以设置 `attConsentWaitingInterval` 属性将数据发送延迟最多 **120 秒** ,让用户有足够的时间完成初始用户引导。延时结束或用户设置许可状态后,SDK 会将在延迟时间内记录的所有信息以及用户许可状态发送给 Adjust 服务器。 +如果您的应用包含新手引导流程或教程,那么最好在用户完成新手引导流程或教程后再发送用户的 ATT 许可状态。您可以设置 `attConsentWaitingInterval` 属性将数据发送延迟最多 **360 秒** ,让用户有足够的时间完成初始用户引导。延时结束或用户设置许可状态后,SDK 会将在延迟时间内记录的所有信息以及用户许可状态发送给 Adjust 服务器。