Skip to content

Commit c145278

Browse files
Merge tag 'FieldWorks9.2.5' into develop
2 parents 23a9c52 + 7ec92b5 commit c145278

313 files changed

Lines changed: 111649 additions & 4007 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: NDP461-DevPack-KB3105179-ENU.exe /q
3535

3636
- name: Setup dotnet
37-
uses: actions/setup-dotnet@v3
37+
uses: actions/setup-dotnet@v4
3838
with:
3939
dotnet-version: |
4040
2.1.x
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Commit messages check
2+
on:
3+
pull_request:
4+
workflow_call:
5+
6+
jobs:
7+
gitlint:
8+
name: Check commit messages
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- name: Install dependencies
16+
run: |
17+
pip install --upgrade gitlint
18+
- name: Lint git commit messages
19+
shell: bash
20+
# run the linter and tee the output to a file, this will make the check fail but allow us to use the results in summary
21+
run: gitlint --ignore body-is-missing --commits origin/$GITHUB_BASE_REF.. 2>&1 | tee check_results.log
22+
- name: Propegate Error Summary
23+
if: always()
24+
shell: bash
25+
# put the output of the commit message linting into the summary for the job and in an environment variable
26+
run: |
27+
# Change the commit part of the log into a markdown link to the commit
28+
commitsUrl="https:\/\/github.com\/${{ github.repository_owner }}\/${{ github.event.repository.name }}\/commit\/"
29+
sed -i "s/Commit \([0-9a-f]\{7,40\}\)/[commit \1]($commitsUrl\1)/g" check_results.log
30+
# Put the results into the job summary
31+
cat check_results.log >> "$GITHUB_STEP_SUMMARY"
32+
# Put the results into a multi-line environment variable to use in the next step
33+
echo "check_results<<###LINT_DELIMITER###" >> "$GITHUB_ENV"
34+
echo "$(cat check_results.log)" >> "$GITHUB_ENV"
35+
echo "###LINT_DELIMITER###" >> "$GITHUB_ENV"
36+
# add a comment on the PR if the commit message linting failed
37+
- name: Comment on PR
38+
if: failure()
39+
uses: marocchino/sticky-pull-request-comment@v2
40+
with:
41+
header: Commit Comment
42+
message: |
43+
⚠️ Commit Message Format Issues ⚠️
44+
${{ env.check_results }}
45+
- name: Clear PR Comment
46+
if: success()
47+
uses: marocchino/sticky-pull-request-comment@v2
48+
with:
49+
header: Commit Comment
50+
hide: true
51+
hide_classify: "RESOLVED"
52+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: check-whitespace
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
# Avoid unnecessary builds
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
check-whitespace:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: git log --check
21+
id: check_out
22+
run: |
23+
echo "Starting the script."
24+
baseSha=${{ github.event.pull_request.base.sha }}
25+
git log --check --pretty=format:"---% h% s" ${baseSha}.. | tee check-results.log
26+
problems=()
27+
commit=
28+
commitText=
29+
commitTextmd=
30+
# Use git log --check to look for whitespace errors in each commit of this PR
31+
log_output=$(cat check-results.log)
32+
echo "${log_output}"
33+
# Use a for loop to iterate over lines of log_output
34+
IFS=$'\n'
35+
for line in $log_output; do
36+
echo "Line: ${line}"
37+
case "${line}" in
38+
"--- "*)
39+
IFS=' ' read -r _ commit commitText <<< "$line"
40+
commitTextmd="[${commit}](https://github.com/${{ github.repository }}/commit/${commit}) ${commitText}"
41+
;;
42+
"")
43+
;;
44+
*:[1-9]*:*) # contains file and line number information - This indicates that a whitespace error was found
45+
file="${line%%:*}"
46+
afterFile="${line#*:}" # Remove the first colon and everything before it
47+
lineNumber="${afterFile%%:*}" # Remove anything after and including the first remaining colon to get only the line number
48+
problems+=("[${commitTextmd}]")
49+
problems+=("[${line}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${file}#L${lineNumber})")
50+
problems+=""
51+
;;
52+
esac
53+
done
54+
if test ${#problems[*]} -gt 0; then
55+
echo "⚠️ Please review the Summary output for further information." >> $GITHUB_STEP_SUMMARY
56+
echo "### A whitespace issue was found in one or more of the commits." >> $GITHUB_STEP_SUMMARY
57+
echo "" >> $GITHUB_STEP_SUMMARY
58+
echo "Errors:" >> $GITHUB_STEP_SUMMARY
59+
for i in "${problems[@]}"; do
60+
echo "${i}" >> $GITHUB_STEP_SUMMARY
61+
done
62+
exit 1
63+
fi
64+
echo "No problems found"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Bin/_setLatestBuildConfig.bat
2929
Bin/_setroot.bat
3030
Lib/debug/DebugProcs.lib
3131
Lib/debug/Generic.lib
32+
Lib/debug/System.ValueTuple.dll
3233
Lib/debug/unit++.*
3334
Lib/release/DebugProcs.lib
3435
Lib/release/Generic.lib

Build/Installer.targets

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@
101101
A base build should warn if we have 'RemovedSinceLastBase' items to help us remember to clear these out.
102102
-->
103103
<Target Name="RescuePatching">
104-
<!-- <ItemGroup>
105-
<RemovedSinceLastBase Include="$(dir-outputBase)/Example.dll" />
104+
<ItemGroup>
105+
<RemovedSinceLastBase Include="$(dir-outputBase)/Helps/WW-ConceptualIntro/ConceptualIntroduction.htm" />
106106
</ItemGroup>
107-
<WriteLinesToFile File="%(RemovedSinceLastBase.FullPath)" Lines="" /> -->
107+
<WriteLinesToFile File="%(RemovedSinceLastBase.FullPath)" Lines="" />
108108
</Target>
109109
<!-- ########################################################################################################## -->
110110
<!-- ### Compile Targets ### -->
@@ -210,6 +210,7 @@
210210
<L10nFiles Include="$(OutputDirForConfig)\ur\**\*"/>
211211
<L10nFiles Include="$(OutputDirForConfig)\vi\**\*"/>
212212
<L10nFiles Include="$(OutputDirForConfig)\zh-CN\**\*"/>
213+
<L10nFiles Include="$(OutputDirForConfig)\zlm\**\*"/>
213214
<!-- no need to install the following; most are installed by merge modules -->
214215
<MergeModules Include="$(OutputDirForConfig)\asserts.log"/>
215216
<MergeModules Include="$(OutputDirForConfig)\basicTest.xml"/>
@@ -303,7 +304,8 @@
303304
<PropertyGroup>
304305
<!-- Substring keeps Chinese the same length as everyone else (and '-' is an illegal character in some places) -->
305306
<!-- "The nail that sticks up gets hammered down" (Japanese proverb) -->
306-
<SafeTargetLocale>$(TargetLocale.Substring(0,2))</SafeTargetLocale>
307+
<SafeTargetLocale Condition="'$(TargetLocale)'=='zh-CN'">$(TargetLocale.Substring(0,2))</SafeTargetLocale>
308+
<SafeTargetLocale Condition="'$(TargetLocale)'!='zh-CN'">$(TargetLocale)</SafeTargetLocale>
307309
<!-- KeyPathFix changes KeyPath="yes" to KeyPath="no" so we can overwrite later versions of files, if necessary. -->
308310
<!-- See https://github.com/sillsdev/genericinstaller's README for details. -->
309311
<KeyPathFixArg Condition="'$(FixKeyPath)'=='true'">-t $(InstallerDir)/BaseInstallerBuild/KeyPathFix.xsl</KeyPathFixArg>
@@ -396,7 +398,8 @@
396398
Condition="!Exists('$(WixLibsDir)/vcredist_2015-19_x64.exe') And $(Platform)=='x64'"
397399
DownloadsDir="$(WixLibsDir)"/> <!-- VisualC++ 14.1 runtime -->
398400
<!-- FLEx Bridge -->
399-
<DownloadFile Address="https://build.palaso.org/guestAuth/repository/download/FLExBridgeDevelopWin32InstallerSansPublish/fw-9.1.22.tcbuildtag/FLExBridge_Offline.exe"
401+
<DownloadFile Address="https://software.sil.org/downloads/r/fieldworks/FlexBridge_Offline_4.2.0.exe"
402+
LocalFilename="FLExBridge_Offline.exe"
400403
Condition="!Exists('$(WixLibsDir)/FLExBridge_Offline.exe')"
401404
DownloadsDir="$(WixLibsDir)"/> <!-- TODO: always download to get the latest version -->
402405
</Target>
@@ -439,12 +442,12 @@
439442
</MSBuild.ExtensionPack.Framework.Guid>
440443
<Message Text="Generated GUID '$(ProductIdGuid)'"/>
441444
<PropertyGroup>
442-
<MsiFile>$(SafeApplicationName)_$(Revision).msi</MsiFile>
445+
<MsiFile>$(SafeApplicationName)_$(PatchVersionSegment).msi</MsiFile>
443446
<BaseBuildDir>$(InstallerDir)/BaseInstallerBuild</BaseBuildDir>
444447
<BaseBuildArgs>"$(ApplicationName)" $(SafeApplicationName) $(BuildVersion) $(ProductIdGuid) $(UpgradeCodeGuid) "$(AppBuildDir)/$(BinDirSuffix)" "$(AppBuildDir)/$(DataDirSuffix)" $(CopyrightYear) "$(Manufacturer)" $(SafeManufacturer) $(Arch)</BaseBuildArgs>
445448
</PropertyGroup>
446449
<!-- Suppress ICE30 because we and Encoding Converters MM both install Geckofx, resulting in an ICE warning for double ref counting -->
447-
<Exec WorkingDirectory="$(BaseBuildDir)" Command="(set SuppressICE=-sice:ICE30) &amp; buildBaseInstaller.bat $(BaseBuildArgs)" />
450+
<Exec WorkingDirectory="$(BaseBuildDir)" Command="buildBaseInstaller.bat $(BaseBuildArgs)" EnvironmentVariables="SuppressICE=-sice:ICE30" />
448451
<ItemGroup>
449452
<InstallerFiles Include="$(BaseBuildDir)/**/$(SafeApplicationName)_*.exe"/>
450453
<InstallerFiles Include="$(BaseBuildDir)/**/$(SafeApplicationName)_*.msi"/>

Build/Localize.targets

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="Current">
33

4+
<UsingTask TaskName="CopyLocale" AssemblyFile="FwBuildTasks.dll"/>
45
<UsingTask TaskName="GoldEticToXliff" AssemblyFile="FwBuildTasks.dll"/>
56
<UsingTask TaskName="ListsToXliff" AssemblyFile="FwBuildTasks.dll"/>
67
<UsingTask TaskName="LocalizeFieldWorks" AssemblyFile="FwBuildTasks.dll"/>
@@ -13,7 +14,7 @@
1314

1415
<!-- Localize strings-en.xml, lists, and all resx files -->
1516
<Target Name="localize" DependsOnTargets="localize-source;localize-binaries"/>
16-
<Target Name="localize-source" DependsOnTargets="Initialize;downloadTranslatedFiles;copyLibL10ns;combineGOLDEtic;zipLocalizedLists;processLanguages-source" Condition="'$(DisableLocalization)'!='true'"/>
17+
<Target Name="localize-source" DependsOnTargets="Initialize;downloadTranslatedFiles;copyLibL10ns;combineGOLDEtic;zipLocalizedLists;copyLocales;processLanguages-source" Condition="'$(DisableLocalization)'!='true'"/>
1718
<Target Name="localize-binaries" DependsOnTargets="Initialize;processLanguages-binaries" Condition="'$(DisableLocalization)'!='true'"/>
1819

1920
<PropertyGroup>
@@ -34,6 +35,9 @@
3435
<!-- Install overcrowdin, or update if already installed. -->
3536
<Exec WorkingDirectory="$(fwrt)" Command="dotnet tool update -g overcrowdin || dotnet tool install -g overcrowdin"/>
3637
</Target>
38+
<Target Name="copyLocales"> <!-- Copy locales to alternate ws identifiers -->
39+
<CopyLocale SourceL10n="$(L10nsDirectory)/ms" DestL10n="$(L10nsDirectory)/zlm" LcmDir="$(LcmSrcDir)" />
40+
</Target>
3741

3842
<!-- Update localizable files in Crowdin -->
3943
<Target Name="uploadUpdatesForTranslation" DependsOnTargets="CopyLcmResxFiles;InstallOvercrowdin">
@@ -69,7 +73,7 @@
6973
<Target Name="downloadTranslatedFiles" Condition="'$(disableDownloads)'!='true'" DependsOnTargets="InstallOvercrowdin">
7074
<ForceDelete Files="$(L10nsDirectory)"/>
7175
<MakeDir Directories="$(DownloadsDir)"/>
72-
<Exec WorkingDirectory="$(fwrt)" Command="overcrowdin download -v -r2 -f $(CrowdinZip)" ContinueOnError="$(OnFailedCrowdinDownload)"/>
76+
<Exec WorkingDirectory="$(fwrt)" Command="overcrowdin download -v -f $(CrowdinZip)" ContinueOnError="$(OnFailedCrowdinDownload)"/>
7377
<Unzip ZipFilename="$(CrowdinZip)" ToDir="$(L10nsDirectory)"/>
7478
<NormalizeLocales L10nsDirectory="$(L10nsDirectory)"/>
7579
<ItemGroup>

Build/Src/FwBuildTasks/FwBuildTasks.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
<RootNamespace>SIL.FieldWorks.Build.Tasks</RootNamespace>
44
<Description>Additional msbuild tasks for FieldWorks</Description>
55
<Product>FwBuildTasks</Product>
6-
<TargetFramework>net461</TargetFramework>
6+
<TargetFramework>net462</TargetFramework>
77
<OutputPath>../..</OutputPath>
88
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
99
</PropertyGroup>
10-
1110
<ItemGroup>
1211
<PackageReference Include="NUnit" Version="3.13.3" PrivateAssets="All" />
12+
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
1313
<PackageReference Include="SIL.TestUtilities" Version="12.0.0-*" PrivateAssets="All" />
14+
<Reference Include="netstandard" />
1415
<Reference Include="Microsoft.Build.Framework" />
1516
<Reference Include="Microsoft.Build.Utilities.v4.0" />
1617
<Reference Include="System.IO.Compression" />

Build/Src/FwBuildTasks/FwBuildTasksTests/NormalizeLocalesTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020 SIL International
1+
// Copyright (c) 2020 SIL International
22
// This software is licensed under the LGPL, version 2.1 or later
33
// (http://www.gnu.org/licenses/lgpl-2.1.html)
44

@@ -60,6 +60,19 @@ public void Works()
6060
VerifyLocale("zh-CN", "zh");
6161
}
6262

63+
[Test]
64+
public void CopyMalay()
65+
{
66+
FileSystemSetup(new[] { "ms" });
67+
68+
VerifyLocale("ms", "zlm");
69+
70+
_task.Execute();
71+
72+
VerifyLocale("ms", "zzz");
73+
VerifyLocale("zlm", "zzz");
74+
}
75+
6376
private void FileSystemSetup(string[] locales)
6477
{
6578
foreach (var locale in locales)
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Copyright (c) 2024 SIL International
2+
// This software is licensed under the LGPL, version 2.1 or later
3+
// (http://www.gnu.org/licenses/lgpl-2.1.html)
4+
5+
using System;
6+
using System.IO;
7+
using Microsoft.Build.Framework;
8+
using Microsoft.Build.Utilities;
9+
10+
11+
namespace SIL.FieldWorks.Build.Tasks.Localization
12+
{
13+
public class CopyLocale : Task
14+
{
15+
[Required]
16+
public string SourceL10n { get; set; }
17+
18+
[Required]
19+
public string DestL10n { get; set; }
20+
21+
[Required]
22+
public string LcmDir { get; set; }
23+
24+
public override bool Execute()
25+
{
26+
var srcLangCode = Path.GetFileName(SourceL10n);
27+
var destLangCode = Path.GetFileName(DestL10n);
28+
if (!Directory.Exists(SourceL10n))
29+
{
30+
Log.LogError($"Source directory '{SourceL10n}' does not exist.");
31+
return false;
32+
}
33+
if (Directory.Exists(DestL10n))
34+
{
35+
Log.LogError($"Destination directory '{DestL10n}' already exists.");
36+
return false;
37+
}
38+
// Create the destination directory
39+
Directory.CreateDirectory(DestL10n);
40+
41+
// Get the files in the source directory and copy to the destination directory
42+
CopyDirectory(SourceL10n, DestL10n, true);
43+
44+
NormalizeLocales.RenameLocaleFiles(DestL10n, srcLangCode, destLangCode);
45+
// Get the files in the source directory and copy to the destination directory
46+
foreach (var file in Directory.GetFiles(LcmDir, "*.resx", SearchOption.AllDirectories))
47+
{
48+
var relativePath = GetRelativePath(LcmDir, file);
49+
Log.LogMessage(MessageImportance.Normal, "CopyLocale: relpath - " + relativePath);
50+
var newFileName = Path.GetFileNameWithoutExtension(file) + $".{destLangCode}.resx";
51+
var newFilePath = Path.Combine(DestL10n, Path.Combine("Src", Path.GetDirectoryName(relativePath)));
52+
53+
// Create the directory for the new file if it doesn't exist
54+
Directory.CreateDirectory(newFilePath);
55+
56+
Log.LogMessage(MessageImportance.Normal, $"CopyLocale: {newFilePath}, {newFileName}");
57+
// Copy the file to the new location
58+
File.Move(file, Path.Combine(newFilePath, newFileName));
59+
}
60+
61+
return true;
62+
}
63+
64+
static void CopyDirectory(string sourceDir, string destinationDir, bool recursive)
65+
{
66+
// From: https://learn.microsoft.com/en-us/dotnet/standard/io/how-to-copy-directories
67+
// Get information about the source directory
68+
var dir = new DirectoryInfo(sourceDir);
69+
70+
// Check if the source directory exists
71+
if (!dir.Exists)
72+
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");
73+
74+
// Cache directories before we start copying
75+
DirectoryInfo[] dirs = dir.GetDirectories();
76+
77+
// Create the destination directory
78+
Directory.CreateDirectory(destinationDir);
79+
80+
// Get the files in the source directory and copy to the destination directory
81+
foreach (FileInfo file in dir.GetFiles())
82+
{
83+
string targetFilePath = Path.Combine(destinationDir, file.Name);
84+
file.CopyTo(targetFilePath);
85+
}
86+
87+
// If recursive and copying subdirectories, recursively call this method
88+
if (recursive)
89+
{
90+
foreach (DirectoryInfo subDir in dirs)
91+
{
92+
string newDestinationDir = Path.Combine(destinationDir, subDir.Name);
93+
CopyDirectory(subDir.FullName, newDestinationDir, true);
94+
}
95+
}
96+
}
97+
98+
static string GetRelativePath(string baseDir, string filePath)
99+
{
100+
Uri baseUri = new Uri(baseDir);
101+
Uri fileUri = new Uri(filePath);
102+
return Uri.UnescapeDataString(baseUri.MakeRelativeUri(fileUri).ToString().Replace('/', Path.DirectorySeparatorChar));
103+
}
104+
}
105+
}

0 commit comments

Comments
 (0)