diff --git a/Directory.Build.props b/Directory.Build.props
index 9c8767b..edea4cd 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,7 +3,7 @@
net8.0
enable
disable
- false
true
+ true
diff --git a/src/OrchardCoreContrib.PoExtractor/OrchardCoreContrib.PoExtractor.csproj b/src/OrchardCoreContrib.PoExtractor/OrchardCoreContrib.PoExtractor.csproj
index 60e7fb2..41f9dbe 100644
--- a/src/OrchardCoreContrib.PoExtractor/OrchardCoreContrib.PoExtractor.csproj
+++ b/src/OrchardCoreContrib.PoExtractor/OrchardCoreContrib.PoExtractor.csproj
@@ -5,7 +5,7 @@
OrchardCoreContrib.PoExtractor
extractpo
true
- 1.3.0
+ 1.3.1
The Orchard Core Contrib Team
.NET Core global tool for extracting translatable strings from the OrchardCore source files.
diff --git a/src/OrchardCoreContrib.PoExtractor/Program.cs b/src/OrchardCoreContrib.PoExtractor/Program.cs
index a20204b..b5d98d6 100644
--- a/src/OrchardCoreContrib.PoExtractor/Program.cs
+++ b/src/OrchardCoreContrib.PoExtractor/Program.cs
@@ -30,8 +30,10 @@ public static void Main(string[] args)
option.DefaultValue = "C#";
});
var template = app.Option("-t|--template ", "Specifies the template engine to extract the translatable strings from.", CommandOptionType.SingleValue, option =>
- option.Accepts(cfg => cfg.Values("Razor", "Liquid"))
- );
+ {
+ option.Accepts(cfg => cfg.Values(TemplateEngine.Both, TemplateEngine.Razor, TemplateEngine.Liquid));
+ option.DefaultValue = TemplateEngine.Both;
+ });
var ignoredProjects = app.Option("-i|--ignore ", "Ignores extracting PO files from a given project(s).", CommandOptionType.MultipleValue);
var localizers = app.Option("--localizer ", "Specifies the name of the localizer(s) that will be used during the extraction process.", CommandOptionType.MultipleValue);
var single = app.Option("-s|--single ", "Specifies the single output file.", CommandOptionType.SingleValue);
@@ -112,7 +114,7 @@ public static void Main(string[] args)
var projectBasePath = Path.GetDirectoryName(projectPath) + Path.DirectorySeparatorChar;
var projectRelativePath = projectPath[projectBasePath.Length..];
var rootedProject = projectPath == inputPath.Value
- ? projectPath
+ ? projectPath
: projectPath[(projectPath.IndexOf(inputPath.Value, StringComparison.Ordinal) + inputPath.Value.Length + 1)..];
if (IgnoredProject.ToList().Any(p => rootedProject.StartsWith(p)))
{
diff --git a/test/OrchardCoreContrib.PoExtractor.Tests/ProgramTests.cs b/test/OrchardCoreContrib.PoExtractor.Tests/ProgramTests.cs
new file mode 100644
index 0000000..83b7d05
--- /dev/null
+++ b/test/OrchardCoreContrib.PoExtractor.Tests/ProgramTests.cs
@@ -0,0 +1,63 @@
+using Xunit;
+
+namespace OrchardCoreContrib.PoExtractor.Tests;
+
+public class ProgramTests
+{
+ [Fact]
+ public void Main_NoTemplateOption_UsesBothRazorAndLiquid()
+ {
+ // Arrange
+ var root = Path.Combine(Path.GetTempPath(), "PoExtractorTests", Guid.NewGuid().ToString("N"));
+ var input = Path.Combine(root, "input");
+ var output = Path.Combine(root, "output");
+ var project = Path.Combine(input, "TestModule");
+
+ Directory.CreateDirectory(project);
+ Directory.CreateDirectory(output);
+
+ File.WriteAllText(Path.Combine(project, "TestModule.csproj"), """
+
+
+ net10.0
+
+
+""");
+
+ File.WriteAllText(Path.Combine(project, "Index.cshtml"), """
+@T["Hello from Razor"]
+""");
+
+ File.WriteAllText(Path.Combine(project, "index.liquid"), """
+{{ "Hello from Liquid" | t }}
+""");
+
+ var potFileName = "all.pot";
+
+ try
+ {
+ // Act
+ Program.Main(
+ [
+ input,
+ output,
+ "--single", potFileName
+ ]);
+
+ // Assert
+ var potPath = Path.Combine(output, potFileName);
+ Assert.True(File.Exists(potPath));
+
+ var pot = File.ReadAllText(potPath);
+ Assert.Contains("Hello from Razor", pot);
+ Assert.Contains("Hello from Liquid", pot);
+ }
+ finally
+ {
+ if (Directory.Exists(root))
+ {
+ Directory.Delete(root, recursive: true);
+ }
+ }
+ }
+}