-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/php-integration-tests
- Loading branch information
Showing
18 changed files
with
620 additions
and
152 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Check Translations | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check-translations: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22.x | ||
|
||
- name: Run translation check | ||
run: ./scripts/check-translations.ps1 | ||
shell: pwsh | ||
|
||
- name: Upload untranslated strings | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: untranslated-strings | ||
path: ./untranslated_strings.html |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,83 @@ | ||
# Step 1: Find all instances of vscode.l10n.t() and extract the strings from .ts and .tsx files | ||
$withParamsPattern = 'vscode\.l10n\.t\(["''`](.+?)["''`],' | ||
Get-ChildItem -Path vscode/microsoft-kiota/src -Recurse -Include *.ts, *.tsx | | ||
Select-String -Pattern $withParamsPattern | | ||
ForEach-Object { $_.Matches.Groups[1].Value } | | ||
Sort-Object | | ||
Get-Unique | | ||
Out-File -FilePath "strings_with_params.txt" | ||
|
||
$withoutParamsPattern = 'vscode\.l10n\.t\(["' + "`'" + '`]([^"' + "`'" + '`]+)["' + "`'" + '`]\)' | ||
Get-ChildItem -Path vscode/microsoft-kiota/src -Recurse -Include *.ts, *.tsx | | ||
Select-String -Pattern $withoutParamsPattern | | ||
ForEach-Object { $_.Matches.Groups[1].Value } | | ||
Sort-Object | | ||
Get-Unique | | ||
Out-File -FilePath "strings_without_params.txt" | ||
|
||
Get-Content strings_with_params.txt, strings_without_params.txt | | ||
Sort-Object | | ||
Get-Unique | | ||
Out-File -FilePath "strings.txt" | ||
|
||
# Step 2: Check translation files in the l10n folder | ||
$results = @() | ||
foreach ($file in Get-ChildItem -Path "vscode/microsoft-kiota/l10n" -Filter bundle.l10n.*.json -Recurse) { | ||
$translations = Get-Content $file.FullName | | ||
Select-String -Pattern '"[^"]+"' | | ||
ForEach-Object { $_.Matches.Groups[0].Value.Trim('"') } | | ||
Sort-Object | ||
$missing = Compare-Object (Get-Content "strings.txt") $translations -PassThru | | ||
Where-Object { $_.SideIndicator -eq "<=" } | ||
|
||
if ($missing) { | ||
$untranslatedItems = $missing | ForEach-Object { "<li>$_</li>" } | ||
$results += [PSCustomObject]@{ | ||
"LanguageFile" = "$($file.Name)" | ||
"Count" = "$($untranslatedItems.Count) found" | ||
"UntranslatedStrings" = "<ul>$($untranslatedItems -join "`n")</ul>" | ||
} | ||
} | ||
} | ||
|
||
# Create the HTML table | ||
$htmlTable = @" | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
table { width: 100%; border-collapse: collapse; } | ||
th, td { border: 1px solid black; padding: 8px; text-align: left; } | ||
th { background-color: #f2f2f2; } | ||
</style> | ||
</head> | ||
<body> | ||
<h2>Untranslated Strings</h2> | ||
<table> | ||
<tr> | ||
<th>Language File</th> | ||
<th>Untranslated Strings</th> | ||
</tr> | ||
"@ | ||
foreach ($result in $results) { | ||
$htmlTable += "<tr><td>$($result.LanguageFile) ($($result.Count))</td><td>$($result.UntranslatedStrings)</td></tr>" | ||
} | ||
$htmlTable += @" | ||
</table> | ||
</body> | ||
</html> | ||
"@ | ||
$htmlTable | Out-File -FilePath "untranslated_strings.html" | ||
|
||
# Output a summary table to the workflow log | ||
if ($results.Count -gt 0) { | ||
Write-Host "Untranslated strings found. See untranslated_strings.html for details." -ForegroundColor Red | ||
Write-Host "| Language File | Count |" | ||
Write-Host "|----------------------------------------|---------|" | ||
foreach ($result in $results) { | ||
Write-Host "| $($result.LanguageFile) | $($result.Count) |" | ||
} | ||
} | ||
else { | ||
Write-Host "All strings have translations." -ForegroundColor Green | ||
} |
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
Oops, something went wrong.