Skip to content

Commit 8e326d9

Browse files
committed
Merge branch 'main' into hishamco/carriage-return
# Conflicts: # src/OrchardCoreContrib.PoExtractor/PoWriter.cs # test/OrchardCoreContrib.PoExtractor.Tests/PoWriterTests.cs
2 parents 7314c52 + f13a0b3 commit 8e326d9

File tree

72 files changed

+1946
-1959
lines changed

Some content is hidden

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

72 files changed

+1946
-1959
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
name: Build windows-latest
1414
runs-on: windows-latest
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717
- name: Setup .NET Core
1818
uses: actions/setup-dotnet@v1
1919
with:
20-
dotnet-version: 6.0.*
20+
dotnet-version: 8.0.*
2121
- name: Install Dependencies
2222
run: dotnet restore
2323
- name: Build

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>disable</Nullable>
6+
<IsPackable>false</IsPackable>
7+
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
8+
</PropertyGroup>
9+
</Project>

Directory.Packages.props

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
7+
<PackageVersion Include="Fluid.Core" Version="2.25.0" />
8+
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
9+
<PackageVersion Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.36" />
10+
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.14.0" />
11+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.14.0" />
12+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
13+
<PackageVersion Include="OrchardCore.DisplayManagement.Liquid" Version="2.2.0" />
14+
<PackageVersion Include="xunit" Version="2.9.3" />
15+
<PackageVersion Include="xunit.analyzers" Version="1.24.0" />
16+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.4" />
17+
</ItemGroup>
18+
</Project>

NuGet.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
4+
<!-- Ignore global configuration -->
45
<clear />
56
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
6-
<add key="OrchardCore" value="https://nuget.cloudsmith.io/orchardcore/preview/v3/index.json" />
77
</packageSources>
88
</configuration>

OrchardCoreContrib.PoExtractor.sln

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCoreContrib.PoExtrac
2727
EndProject
2828
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCoreContrib.PoExtractor.Tests", "test\OrchardCoreContrib.PoExtractor.Tests\OrchardCoreContrib.PoExtractor.Tests.csproj", "{7989E10F-A776-44FE-B3CF-1EB377EFD665}"
2929
EndProject
30-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrchardCoreContrib.PoExtractor.DotNet.CS.Tests", "test\OrchardCoreContrib.PoExtractor.DotNet.CS.Tests\OrchardCoreContrib.PoExtractor.DotNet.CS.Tests.csproj", "{8BD3C4A9-2778-4B2F-8709-79FDC027CA01}"
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCoreContrib.PoExtractor.DotNet.CS.Tests", "test\OrchardCoreContrib.PoExtractor.DotNet.CS.Tests\OrchardCoreContrib.PoExtractor.DotNet.CS.Tests.csproj", "{8BD3C4A9-2778-4B2F-8709-79FDC027CA01}"
3131
EndProject
32-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrchardCoreContrib.PoExtractor.DotNet.VB.Tests", "test\OrchardCoreContrib.PoExtractor.DotNet.VB.Tests\OrchardCoreContrib.PoExtractor.DotNet.VB.Tests.csproj", "{A5885141-EDF9-4C6C-AFF7-B0BE92079E31}"
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCoreContrib.PoExtractor.DotNet.VB.Tests", "test\OrchardCoreContrib.PoExtractor.DotNet.VB.Tests\OrchardCoreContrib.PoExtractor.DotNet.VB.Tests.csproj", "{A5885141-EDF9-4C6C-AFF7-B0BE92079E31}"
33+
EndProject
34+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DDD306EA-9B35-4984-9E96-CBE0450B82DC}"
35+
ProjectSection(SolutionItems) = preProject
36+
Directory.Build.props = Directory.Build.props
37+
Directory.Packages.props = Directory.Packages.props
38+
README.md = README.md
39+
NuGet.config = NuGet.config
40+
EndProjectSection
3341
EndProject
3442
Global
3543
GlobalSection(SolutionConfigurationPlatforms) = preSolution

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# OrchardCoreContrib.PoExtractor
22

3+
![Orchard Core Contrib](images/OCC.png)
4+
35
`OrchardCoreContrib.PoExtractor` is distributed as a dotnet global tool to extracts translatable strings from the C# and VB code, Razor templates and Liquid templates to POT (portable object template) files. It is designed to follow conventions used in the [OrchardCore](https://github.com/OrchardCMS/OrchardCore) project.
46

57
## Installation
@@ -40,6 +42,24 @@ Specifies the code language to extracts translatable strings from. Default: `C#`
4042

4143
Specifies the template engine to extract the translatable strings from. Default: `Razor` & `Liquid` templates.
4244

45+
- **`-p|--plugin {path or URL to CSX file}`**
46+
47+
Specifies a path to a C# script file that can define further project processors. (You can find an example script [here](test/OrchardCoreContrib.PoExtractor.Tests/PluginTestFiles/BasicJsonLocalizationProcessor.csx).) This can be used to process localization from code languages or template engines not supported by the above options. You can have multiple of these switches in one call to load several plugins simultaneously. If the argument starts with `https://` then it's treated as a web URL and the script at that address is downloaded into memory and executed instead of a local file.
48+
49+
When executing the plugins, all _OrchardCoreContrib.PoExtractor_ assemblies are automatically loaded, and two globals are defined:
50+
51+
- `List<IProjectProcessor> ProjectProcessors`: Add an instance of your custom `IProjectProcessor` implementation type to this list.
52+
- `List<string> ProjectFiles`: In the unlikely case that you have to add a new project file type (such as _.fsproj_) add the project file paths to this list.
53+
54+
> [!TIP]
55+
> You can't import NuGet packages in your script file, but you can import local DLL files using the `#r "path/to/package.dll"` directive. The path can be relative to the script file's location so you can import packages from the build directory of the project you are extracting from. This can be especially useful if you launch the tool as using MSBuild as a post-build action. (For remote scripts loaded with a URL, the path can be relative to the current working directory.) For example:
56+
>
57+
> ```csharp
58+
> #r "src/Modules/OrchardCore.Commerce/bin/Debug/net8.0/OrchardCore.Commerce.dll"
59+
> using OrchardCore.Commerce.Constants;
60+
> Console.WriteLine("Imported resource name: {0}", ResourceNames.ShoppingCart);
61+
> ```
62+
4363
## Uninstallation
4464
4565
```powershell

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.0",
3+
"version": "8.0.0",
44
"rollForward": "latestMinor"
55
}
66
}

images/OCC.png

19.7 KB
Loading

images/icon.png

-30.4 KB
Loading
Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
using System;
22

3-
namespace OrchardCoreContrib.PoExtractor
3+
namespace OrchardCoreContrib.PoExtractor;
4+
5+
/// <summary>
6+
/// Extension methods for <see cref="string"/>.
7+
/// </summary>
8+
public static class StringExtensions
49
{
510
/// <summary>
6-
/// Extension methods for <see cref="string"/>.
11+
/// Removes the given value from the start of the text.
712
/// </summary>
8-
public static class StringExtensions
13+
/// <param name="text">The source text.</param>
14+
/// <param name="trimText">The value to be trimmed.</param>
15+
public static string TrimStart(this string text, string trimText)
916
{
10-
/// <summary>
11-
/// Removes the given value from the start of the text.
12-
/// </summary>
13-
/// <param name="text">The source text.</param>
14-
/// <param name="trimText">The value to be trimmed.</param>
15-
public static string TrimStart(this string text, string trimText)
17+
if (string.IsNullOrEmpty(text))
1618
{
17-
if (string.IsNullOrEmpty(text))
18-
{
19-
throw new ArgumentException($"'{nameof(text)}' cannot be null or empty.", nameof(text));
20-
}
19+
throw new ArgumentException($"'{nameof(text)}' cannot be null or empty.", nameof(text));
20+
}
2121

22-
if (string.IsNullOrEmpty(trimText))
23-
{
24-
throw new ArgumentException($"'{nameof(trimText)}' cannot be null or empty.", nameof(trimText));
25-
}
22+
if (string.IsNullOrEmpty(trimText))
23+
{
24+
throw new ArgumentException($"'{nameof(trimText)}' cannot be null or empty.", nameof(trimText));
25+
}
2626

27-
var index = text.IndexOf(trimText);
27+
var index = text.IndexOf(trimText);
2828

29-
return index < 0
30-
? text
31-
: text.Remove(index, trimText.Length);
32-
}
29+
return index < 0
30+
? text
31+
: text.Remove(index, trimText.Length);
3332
}
3433
}

0 commit comments

Comments
 (0)