Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smartling translations are completed for commit d7336d9b2851df7b1cec8480d432dbd0e157e269 from main #1207

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
17 changes: 4 additions & 13 deletions .github/scripts/fixTranslations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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")) {
Expand All @@ -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) {
Expand All @@ -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.");
}
Expand Down
44 changes: 32 additions & 12 deletions .github/workflows/fix_translations.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Fix translations
on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
i18n-fixes:
name: Fix translated files
Expand All @@ -10,39 +12,57 @@ 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:
node-version: "20.x"
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<<EOF'
echo $modified_files
echo EOF
}>> $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 }}
10 changes: 5 additions & 5 deletions src/content/docs/zh/sdk/react-native/v5/features/att.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ redirects:

如果您要记录设备的广告主 ID \(即 IDFA\),需要先展示弹窗获得用户的授权。要达到这个目的,您需要在应用中添加 Apple 的 App Tracking Transparency \(ATT\) 框架。Adjust SDK 会存储用户的授权状态并在每次请求中将该信息发送至 Adjust 服务器。

## 授权状态{#authorization-statuses}
## 授权状态\{\#authorization\-statuses\}

| 状态 | 代码 | 描述 |
| --------------------------------------------------- | ---- | -------------------------------------------------- |
Expand All @@ -29,7 +29,7 @@ redirects:

</Callout>

## ATT 授权包装器{#att-authorization-wrapper}
## ATT 授权包装器\{\#att\-authorization\-wrapper\}

<CodeBlock title="方法签名">

Expand Down Expand Up @@ -101,7 +101,7 @@ Adjust.requestAppTrackingAuthorization(function (status) {
});
```

## 获取当前授权状态{#get-current-authorization-status}
## 获取当前授权状态\{\#get\-current\-authorization\-status\}

<CodeBlock title="方法签名">

Expand Down Expand Up @@ -129,7 +129,7 @@ Adjust.getAppTrackingAuthorizationStatus(function (status) {
});
```

## 自定义弹窗时机{#custom-prompt-timing}
## 自定义弹窗时机\{\#custom\-prompt\-timing\}

<CodeBlock title="方法签名">

Expand All @@ -139,7 +139,7 @@ public setAttConsentWaitingInterval(attConsentWaitingInterval: number): void

</CodeBlock>

如果您的应用包含新手引导流程或教程,那么最好在用户完成新手引导流程或教程后再发送用户的 ATT 许可状态。您可以设置 `attConsentWaitingInterval` 属性将数据发送延迟最多 **120 秒** ,让用户有足够的时间完成初始用户引导。延时结束或用户设置许可状态后,SDK 会将在延迟时间内记录的所有信息以及用户许可状态发送给 Adjust 服务器。
如果您的应用包含新手引导流程或教程,那么最好在用户完成新手引导流程或教程后再发送用户的 ATT 许可状态。您可以设置 `attConsentWaitingInterval` 属性将数据发送延迟最多 **360 秒** ,让用户有足够的时间完成初始用户引导。延时结束或用户设置许可状态后,SDK 会将在延迟时间内记录的所有信息以及用户许可状态发送给 Adjust 服务器。

<Callout type="note">

Expand Down