Skip to content

Commit

Permalink
fix l10n.proj (#1291)
Browse files Browse the repository at this point in the history
* Point to the correct Palaso.en.xlf
* Update NuGet package name
* Remove extra generated lines before each run to prevent infinite linear growth
  • Loading branch information
papeh authored Oct 18, 2023
1 parent 1d5a6bd commit 0fdfdb6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/l10n-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Download localizations
working-directory: ./l10n
run: crowdin download --all -T ${{ secrets.CROWDIN_PAT }} -i ${{ secrets.CROWDIN_PROJECT_ID }}
run: crowdin download --all -T ${{ secrets.CROWDIN_PAT }}

- name: Restore packages
run: msbuild l10n/l10n.proj /t:restore /p:Configuration=Release /p:Platform="Any CPU"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/l10n-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- name: Download Palaso.en.xlf source file # new strings will be merged into the existing file
working-directory: ./l10n
run: crowdin download sources -T ${{ secrets.CROWDIN_PAT }} -i ${{ secrets.CROWDIN_PROJECT_ID }}
run: crowdin download sources -T ${{ secrets.CROWDIN_PAT }}

- name: Update l10n strings
env:
Expand All @@ -52,4 +52,4 @@ jobs:

- name: Upload Palaso.en.xlf source file
working-directory: ./l10n
run: crowdin upload sources -T ${{ secrets.CROWDIN_PAT }} -i ${{ secrets.CROWDIN_PROJECT_ID }}
run: crowdin upload sources -T ${{ secrets.CROWDIN_PAT }}
8 changes: 4 additions & 4 deletions l10n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Using localizations in a project

1. Add a Nuget dependency on libpalaso.l10ns to the project where you initialize the L10nSharp `LocalizationManager`
1. Add a Nuget dependency on SIL.libpalaso.l10ns to the project where you initialize the L10nSharp `LocalizationManager`
2. Add a build step to copy the Palaso.%langcode%.xlf files to the correct folder in your project

### Updating Crowdin with source string changes (automatic)
Expand All @@ -18,9 +18,9 @@ See `../.github/workflows/l10n-source.yml`

It can also be run manually as follows (requires the [Crowdin CLI](https://crowdin.github.io/crowdin-cli/)):
```
crowdin download sources -i CROWDIN_PROJECT_ID -T CROWDIN_ACCESS_TOKEN
crowdin download sources -T CROWDIN_ACCESS_TOKEN
msbuild l10n.proj /t:UpdateCrowdin
crowdin upload sources -i CROWDIN_PROJECT_ID -T CROWDIN_ACCESS_TOKEN
crowdin upload sources -T CROWDIN_ACCESS_TOKEN
```

### Building a NuGet package with the latest translations
Expand All @@ -30,7 +30,7 @@ This process is run by a github action whenever a version tag is pushed and manu

It can also be run manually as follows (requires the [Crowdin CLI](https://crowdin.github.io/crowdin-cli/)):
```
crowdin download --all -i CROWDIN_PROJECT_ID -T CROWDIN_ACCESS_TOKEN
crowdin download --all -T CROWDIN_ACCESS_TOKEN
msbuild l10n.proj /t:PackageL10ns
nuget push -ApiKey TheSilNugetApiKey SIL.libpalaso.l10n.nupkg
```
3 changes: 2 additions & 1 deletion l10n/crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
base_path : "."
project_id: 393909
base_path: "."
preserve_hierarchy: true

files: [
Expand Down
18 changes: 15 additions & 3 deletions l10n/l10n.proj
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
<Version>$(GitVersion_NuGetVersion)</Version>
<Authors>Jason Naylor</Authors>
<Company>SIL International</Company>
<RestartBuild Condition="'$(PkgL10NSharp_ExtractXliff)' == '' OR $(PkgGitVersion_GitVersion_MsBuild) == ''">true</RestartBuild>
<RestartBuild Condition="'$(PkgL10NSharp_ExtractXliff)' != '' AND $(PkgGitVersion_GitVersion_MsBuild) != ''">false</RestartBuild>
<RestartBuild Condition="'$(PkgGitVersion_GitVersion_MsBuild)' == ''
OR '$(PkgL10NSharp_ExtractXliff)' == ''
OR '$(PkgMSBuild_Extension_Pack)' == ''
OR '$(PkgNuGet_CommandLine)' == ''
OR '$(PkgSIL_BuildTasks)' == ''">true</RestartBuild>
<RestartBuild Condition="'$(RestartBuild)' == ''">false</RestartBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.9.0" GeneratePathProperty="true">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="L10NSharp.ExtractXliff" Version="7.0.0-beta0011" GeneratePathProperty="true" />
<PackageReference Include="MSBuild.Extension.Pack" Version="1.9.1" GeneratePathProperty="true" />
<PackageReference Include="NuGet.CommandLine" Version="6.1.0" GeneratePathProperty="true" />
<PackageReference Include="SIL.BuildTasks" Version="2.3.0-beta.14" GeneratePathProperty="true" />
</ItemGroup>
Expand All @@ -33,8 +38,15 @@
</Target>

<Target Name="UpdateCrowdinInternal" DependsOnTargets="GetVersion">
<!-- Remove "not found" messages that are appended each run (Can't MatchWholeLine because leading spaces are trimmed from Lines).
These messages accumulate linearly and inifinitely at each ExtractXliff run and are not removed if the string is later found.
Removing these lines before running ExtractXliff ensures that only unfound strings are annotated, and only once.
See https://github.com/sillsdev/l10nsharp/issues/113 -->
<MSBuild.ExtensionPack.FileSystem.File TaskAction="RemoveLines" Files="Palaso.en.xlf" AvoidRegex="true"
Lines=" &lt;note xml:lang=&quot;en&quot;&gt;Not found in static scan of compiled code (version 0.0.0)&lt;/note&gt;"/>
<!-- Build and extract strings -->
<MSBuild Projects="..\build\Palaso.proj" Targets="Build" Properties="Configuration=Release" />
<Exec Command="&quot;$(PkgL10NSharp_ExtractXliff)\tools\ExtractXliff.exe&quot; -n SIL -o Palaso.dll -b ..\DistFiles\Palaso.en.xlf -x Palaso.en.xlf -p $(GitVersion_NuGetVersion) -m SIL.Localizer.GetString -m SIL.Localizer.Localize -g ../Output/Release/net461/SIL.*.dll" />
<Exec Command="&quot;$(PkgL10NSharp_ExtractXliff)\tools\ExtractXliff.exe&quot; -n SIL -o Palaso.dll -b Palaso.en.xlf -x Palaso.en.xlf -p $(GitVersion_NuGetVersion) -m SIL.Localizer.GetString -m SIL.Localizer.Localize -g ../Output/Release/net461/SIL.*.dll" />
</Target>

<Target Name="PackageL10ns" DependsOnTargets="restore;GetVersion">
Expand Down
2 changes: 1 addition & 1 deletion l10n/l10ns.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<authors>Jason Naylor</authors>
<license type="expression">MIT</license>
<projectUrl>https://github.com/sillsdev/libpalaso</projectUrl>
<copyright>Copyright © 2010-2020 SIL International</copyright>
<copyright>Copyright © 2010-2023 SIL International</copyright>
</metadata>
<files>
<file src="**\Palaso.*.xlf" target="content" />
Expand Down

0 comments on commit 0fdfdb6

Please sign in to comment.