mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 10:19:20 +08:00
f2cfd90c46
* Added localization code to pipeline and created one LocProject json for Settings * Fixed typo * Reordered nuget source * Moved nuget install to restore step * Added FZ.rc file to LocProj * Added FZ resx file and modified rc file * Fixed file names * Changed to check folder for LocProject files * Updated folder * Changed directory * Changed to src directory * Changed language set and name format, removed rc file localization * Added all projects with resx/resw files * Added newline to end of file * Removed nuget source as it is not used * Updated comments * Updated keyboard manager to use resx file * Tweaked resources.resx and added it to project files * Added comments and added in string table to resx script * Remove change from bad merge * Fix syntax error in convert stringtable * Changed file type to None * Migrated color picker's resources * Migrated resources for Microsoft.Launcher * Migrated resources for fancy zones * Revert fancyzones changes * Migrated resources for ImageResizer and modified script to add language specific code * Added try catch and checks for modification to avoid unnecessary file creation * Changed tab insertion to 4 spaces to avoid mixed file types in rc file * Migrated resources for power preview project * Added LocProject.json file for 5 projects * added resgen exception check * Moved non-localizable strings out of resx for powerpreview
32 lines
1.6 KiB
PowerShell
32 lines
1.6 KiB
PowerShell
# This script is used to move the resources from a string table txt file to a resx file
|
|
|
|
# File containing only the rows of the string table
|
|
$stringTableFile = $args[0]
|
|
|
|
# Output resx file
|
|
$resxFile = $args[1]
|
|
|
|
# Temporary text file used by resgen
|
|
$tempFile = "temporaryResourceFile.txt"
|
|
|
|
$newLinesForTempFile = ""
|
|
foreach ($line in Get-Content $stringTableFile) {
|
|
# Each line of string table text file is of the form IDS_ResName L"ResourceValue" where there can be any number of spaces between the two.
|
|
$content = $line.Trim() -split "\s+", 2
|
|
|
|
# Each line of the resgen text input needs to be of the form ResourceName=ResourceValue with no spaces.
|
|
# For the resource name for the resx file, we remove the IDS_ prefix and convert the words to title case. This can be imperfect since the parts between underscores may also comprise of multiple words, so that will have to be manually tweaked
|
|
# For the resource value we only keep the content inside L""
|
|
$lineInTempFileFormat = (Get-Culture).TextInfo.ToTitleCase($content[0].Substring(4).Replace("_", " ").ToLower()).Replace(" ", "_") + "=" + $content[1].Substring(2, $content[1].Length - 3)
|
|
$newLinesForTempFile = $newLinesForTempFile + "`r`n" + $lineInTempFileFormat
|
|
}
|
|
|
|
# Save the text to a file
|
|
Set-Content -Path $tempFile -Value $newLinesForTempFile
|
|
|
|
# Use resgen to parse the txt to resx. More details at https://docs.microsoft.com/en-us/dotnet/framework/tools/resgen-exe-resource-file-generator#converting-between-resource-file-types
|
|
resgen $tempFile $resxFile
|
|
|
|
# Delete temporary text file used by resgen
|
|
Remove-Item $tempFile
|