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

[Feature Request]: translation builder scipt #799

Open
necrose99 opened this issue Dec 26, 2024 · 2 comments
Open

[Feature Request]: translation builder scipt #799

necrose99 opened this issue Dec 26, 2024 · 2 comments
Labels
enhancement New feature or request stale

Comments

@necrose99
Copy link

The request

simple script for users or volunteers suck in template xml parse through api and manually check as desired ...

if a new language is desired can export a file users can use and make available in new languages or assist you in their upkeep.

# Define the GitHub repository and paths
$repoUrl = "https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/heads/main.zip"
$localePath = "Sources/Winget-AutoUpdate/locale"
$locales = @("ja", "de", "es")  # Add more language codes as needed

# Download the latest release zip file
$zipPath = "$env:TEMP\Winget-AutoUpdate.zip"
Invoke-WebRequest -Uri $repoUrl -OutFile $zipPath

# Extract the zip file
Expand-Archive -Path $zipPath -DestinationPath "$env:TEMP\Winget-AutoUpdate"

# Function to translate text using Microsoft Translator API
function Translate-Text {
    param (
        [string]$text,
        [string]$toLanguage
    )
    # Replace with your Microsoft Translator API key
    $apiKey = "YOUR_API_KEY"
    $uri = "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=$toLanguage"
    $body = @(@{ Text = $text }) | ConvertTo-Json
    $headers = @{
        "Ocp-Apim-Subscription-Key" = $apiKey
        "Content-Type" = "application/json"
    }
    $response = Invoke-RestMethod -Uri $uri -Method Post -Body $body -Headers $headers
    return $response.translations[0].text
}

# Read the original XML file (e.g., fr.xml)
$originalXmlPath = "$env:TEMP\Winget-AutoUpdate\Winget-AutoUpdate-main\$localePath\fr.xml"
[xml]$originalXml = Get-Content -Path $originalXmlPath

# Create translated XML files for each locale
foreach ($locale in $locales) {
    $translatedXmlPath = "$env:TEMP\Winget-AutoUpdate\Winget-AutoUpdate-main\$localePath\$locale.xml"
    $translatedXml = $originalXml.Clone()
    foreach ($node in $translatedXml.SelectNodes("//text()")) {
        $node.Value = Translate-Text -text $node.Value -toLanguage $locale
    }
    $translatedXml.Save($translatedXmlPath)
    Write-Output "Translated XML file created: $translatedXmlPath"
}

Write-Output "Translation process completed. Please review and edit the translations as needed."

Is your feature request related to a problem?

Quick Nihongo/ generated via copilot from fr-FR xml 

'<local>
	<outputs>
		<output id="0">
			<!--Check network connection-->
			<title>ネットワーク接続を確認してください。</title>
			<!--Unable to check for software updates at this time!-->
			<message>現在、ソフトウェアの更新を確認できません!</message>
		</output>
		<output id="1">
			<!--No internet connection-->
			<title>インターネット接続がありません。</title>
			<!--Updates could not be verified-->
			<message>ソフトウェアの更新を確認できませんでした!</message>
		</output>
		<output id="2">
			<!--{App} will be updated-->
			<title>{0} が更新されます!</title>
			<!--{v1.0} to {v2.0}-->
			<message>{0} から {1} へ</message>
		</output>
		<output id="3">
			<!--{App} updated-->
			<title>{0} が更新されました。</title>
			<!--Installed version: {v1.0}-->
			<message>インストールされたバージョン: {0}</message>
		</output>
		<output id="4">
			<!--{App} could not be updated-->
			<title>{0} を更新できませんでした!</title>
			<!--Please contact support-->
			<message>サポートに連絡してください。</message>
		</output>
		<output id="5">
			<!--Logs are not available yet-->
			<message>ログはまだ利用できません</message>
		</output>
		<output id="6">
			<!--Starting a manual check for updated apps-->
			<message>ソフトウェアの更新を手動で確認しています...</message>
		</output>
		<output id="7">
			<!--Couldn't start a manual check for updated apps-->
			<message>ソフトウェアの更新の手動確認を開始できませんでした!</message>
		</output>
		<output id="8">
			<!--Check for updated apps already running-->
			<message>ソフトウェアの更新確認が既に実行されています...</message>
		</output>
		<output id="9">
			<!--Manual check for updated apps completed-->
			<message>ソフトウェアの更新確認が完了しました。</message>
		</output>
		<output id="10">
			<!--See changelog-->
			<message>変更履歴を見る</message>
		</output>
		<output id="11">
			<!--Open log file-->
			<message>ログファイルを開く</message>
		</output>
	</outputs>
</local>'

Here's the translated XML content to Vietnamese:  (current boss in American but of Viet.. decent) 

<local>
	<outputs>
		<output id="0">
			<!--Check network connection-->
			<title>Kiểm tra kết nối mạng của bạn.</title>
			<!--Unable to check for software updates at this time!-->
			<message>Không thể kiểm tra cập nhật phần mềm vào lúc này!</message>
		</output>
		<output id="1">
			<!--No internet connection-->
			<title>Không có kết nối internet.</title>
			<!--Updates could not be verified-->
			<message>Không thể xác minh các bản cập nhật!</message>
		</output>
		<output id="2">
			<!--{App} will be updated-->
			<title>{0} sẽ được cập nhật!</title>
			<!--{v1.0} to {v2.0}-->
			<message>{0} từ {1}</message>
		</output>
		<output id="3">
			<!--{App} updated-->
			<title>{0} đã được cập nhật.</title>
			<!--Installed version: {v1.0}-->
			<message>Phiên bản đã cài đặt: {0}</message>
		</output>
		<output id="4">
			<!--{App} could not be updated-->
			<title>{0} không thể được cập nhật!</title>
			<!--Please contact support-->
			<message>Vui lòng liên hệ hỗ trợ.</message>
		</output>
		<output id="5">
			<!--Logs are not available yet-->
			<message>Nhật ký chưa có sẵn</message>
		</output>
		<output id="6">
			<!--Starting a manual check for updated apps-->
			<message>Đang bắt đầu kiểm tra thủ công các ứng dụng đã cập nhật...</message>
		</output>
		<output id="7">
			<!--Couldn't start a manual check for updated apps-->
			<message>Không thể bắt đầu kiểm tra thủ công các ứng dụng đã cập nhật!</message>
		</output>
		<output id="8">
			<!--Check for updated apps already running-->
			<message>Kiểm tra các ứng dụng đã cập nhật đang chạy...</message>
		</output>
		<output id="9">
			<!--Manual check for updated apps completed-->
			<message>Kiểm tra thủ công các ứng dụng đã cập nhật đã hoàn thành.</message>
		</output>
		<output id="10">
			<!--See changelog-->
			<message>Xem nhật ký thay đổi</message>
		</output>
		<output id="11">
			<!--Open log file-->
			<message>Mở tệp nhật ký</message>
		</output>
	</outputs>
</local>

Additional information

No response

@necrose99 necrose99 added the enhancement New feature or request label Dec 26, 2024
@necrose99
Copy link
Author

while my Japanese's is a tad rusted much of it looks ok thus far.

Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

1 participant