Skip to content

Commit ed2342f

Browse files
rolfbjarneCopilot
andauthored
[localization] Include template JSON files in OneLocBuild configuration. Fixes #20717 (#25717)
The `templatestrings.en.json` files in `dotnet/Templates/` were not included in the `LocProject.json` configuration, which meant OneLocBuild never picked them up for translation. This PR replaces the static `LocProject.json.in` template with a `generate-loc-project.sh` script that dynamically discovers all `templatestrings.en.json` files and includes them in the generated `LocProject.json`. This also fixes a duplicate entry for `Microsoft.Macios.Generator/Resources.resx` that was in the original `.in` file. Hopefully fixes #20717 🤖 Pull request created by Copilot --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9811eaa commit ed2342f

3 files changed

Lines changed: 114 additions & 85 deletions

File tree

tools/devops/LocProject.json.in

Lines changed: 0 additions & 81 deletions
This file was deleted.

tools/devops/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ provision-shared.csx: provision-shared.in.csx Makefile $(TOP)/Make.config
77
-e 's#@XCODE_ROOT_PATH@#$(XCODE_DEVELOPER_ROOT)#g' \
88
$< > $@
99

10-
LocProject.json: LocProject.json.in Makefile $(TOP)/Make.config
11-
$(Q_GEN) sed \
12-
-e 's#@WORKING_DIRECTORY@#$(PWD)#g' \
13-
$< > $(TOP)/Localize/$@;
10+
LocProject.json: generate-loc-project.sh Makefile $(TOP)/Make.config
11+
$(Q_GEN) $(TOP)/tools/devops/generate-loc-project.sh "$(CURDIR)" "$(TOP)" > $(TOP)/Localize/$@;
1412

1513
all check: check-sh check-yaml
1614
@true
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/bin/bash -eu
2+
3+
set -o pipefail
4+
5+
# This script generates the LocProject.json file for OneLocBuild.
6+
# It includes both the static .resx entries and dynamically discovered
7+
# template JSON files (templatestrings.en.json).
8+
9+
WORKING_DIRECTORY="${1:-}"
10+
TOP="${2:-}"
11+
12+
if [ -z "$WORKING_DIRECTORY" ] || [ -z "$TOP" ]; then
13+
echo "Usage: $0 <working-directory> <top-directory>" >&2
14+
exit 1
15+
fi
16+
17+
# Start with the static .resx entries
18+
cat <<EOF
19+
{
20+
"Projects": [
21+
{
22+
"LanguageSet": "VS_Main_Languages",
23+
"LocItems": [
24+
{
25+
"SourceFile": "$WORKING_DIRECTORY/../../msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx",
26+
"Languages": "",
27+
"CopyOption": "LangIDOnName",
28+
"OutputPath": "$WORKING_DIRECTORY/../../msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies",
29+
"LclFile": "",
30+
"LciFile": "",
31+
"Parser": "",
32+
"LssFiles": []
33+
},
34+
{
35+
"SourceFile": "$WORKING_DIRECTORY/../../tools/mtouch/Errors.resx",
36+
"Languages": "",
37+
"CopyOption": "LangIDOnName",
38+
"OutputPath": "$WORKING_DIRECTORY/../../tools/mtouch/TranslatedAssemblies",
39+
"LclFile": "",
40+
"LciFile": "",
41+
"Parser": "",
42+
"LssFiles": []
43+
},
44+
{
45+
"SourceFile": "$WORKING_DIRECTORY/../../src/Resources.resx",
46+
"Languages": "",
47+
"CopyOption": "LangIDOnName",
48+
"OutputPath": "$WORKING_DIRECTORY/../../src/TranslatedAssemblies",
49+
"LclFile": "",
50+
"LciFile": "",
51+
"Parser": "",
52+
"LssFiles": []
53+
},
54+
{
55+
"SourceFile": "$WORKING_DIRECTORY/../../src/rgen/Microsoft.Macios.Generator/Resources.resx",
56+
"Languages": "",
57+
"CopyOption": "LangIDOnName",
58+
"OutputPath": "$WORKING_DIRECTORY/../../src/rgen/Microsoft.Macios.Generator/TranslatedAssemblies",
59+
"LclFile": "",
60+
"LciFile": "",
61+
"Parser": "",
62+
"LssFiles": []
63+
},
64+
{
65+
"SourceFile": "$WORKING_DIRECTORY/../../src/rgen/Microsoft.Macios.Bindings.Analyzer/Resources.resx",
66+
"Languages": "",
67+
"CopyOption": "LangIDOnName",
68+
"OutputPath": "$WORKING_DIRECTORY/../../src/rgen/Microsoft.Macios.Bindings.Analyzer/TranslatedAssemblies",
69+
"LclFile": "",
70+
"LciFile": "",
71+
"Parser": "",
72+
"LssFiles": []
73+
},
74+
{
75+
"SourceFile": "$WORKING_DIRECTORY/../../tools/sharpie/Sharpie.Bind/Resources.resx",
76+
"Languages": "",
77+
"CopyOption": "LangIDOnName",
78+
"OutputPath": "$WORKING_DIRECTORY/../../tools/sharpie/Sharpie.Bind/TranslatedAssemblies",
79+
"LclFile": "",
80+
"LciFile": "",
81+
"Parser": "",
82+
"LssFiles": []
83+
EOF
84+
85+
# Add entries for all template localization JSON files
86+
ABSTOP=$(cd "$TOP" && pwd)
87+
find "$ABSTOP/dotnet/Templates" -name 'templatestrings.en.json' | sort | while read -r f; do
88+
dir=$(dirname "$f")
89+
cat <<EOF
90+
},
91+
{
92+
"SourceFile": "$f",
93+
"Languages": "",
94+
"CopyOption": "LangIDOnName",
95+
"OutputPath": "$dir",
96+
"LclFile": "",
97+
"LciFile": "",
98+
"Parser": "",
99+
"LssFiles": []
100+
EOF
101+
done
102+
103+
# Close the JSON structure
104+
cat <<EOF
105+
}
106+
],
107+
"LssFiles": [],
108+
"CloneLanguageSet": ""
109+
}
110+
]
111+
}
112+
EOF

0 commit comments

Comments
 (0)