Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
+ Updated factory patterns to support `GetTerm` and `__` keyword matching
  • Loading branch information
nd1012 committed Mar 10, 2024
1 parent 57efb9c commit 2366e8c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ folder tree.

Per default keywords will be found by these regular expressions:

- `^.*((Description|DisplayText)\(\s*(\"".*[^\\]\"")\s*\)).*$` (`$3`)
- `^.*((_|gettextn?|Translate(Plural)?)\(\s*(\"".*[^\\]\"")).*$` (`$4`)
- `^.*(CliApi[^\s]*\([^\)]*Example\s*\=\s*(\"".*[^\\]\"")).*$` (`$2`)
- `^.*((Description|DisplayText)\(\s*(\".*[^\\]\")\s*\)).*$` (`$3`)
- `^.*((__?|gettextn?|Translate(Plural)?|GetTerm)\(\s*(\".*[^\\]\")).*$` (`$4`)
- `^.*(CliApi[^\s]*\([^\)]*Example\s*\=\s*(\".*[^\\]\")).*$` (`$2`)

**NOTE**: (Multiline) concatenated string value definitions (like
`"Part a" + "Part b"`) or interpolations can't be parsed. The matched keyword
Expand Down
2 changes: 1 addition & 1 deletion src/wan24-PoeditParser CLI/ParserConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static ParserConfig()
},
new ParserPattern()
{
Pattern= @"^.*((_|gettextn?|Translate(Plural)?)\(\s*(\"".*[^\\]\"")).*$",
Pattern= @"^.*((__?|gettextn?|Translate(Plural)?|GetTerm)\(\s*(\"".*[^\\]\"")).*$",
Options = RegexOptions.Compiled,
Replacement = "$4"
},
Expand Down
6 changes: 2 additions & 4 deletions src/wan24-PoeditParser CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
CliConfig.Apply(new(args));
#if DEBUG
Settings.LogLevel = LogLevel.Trace;
Logging.Logger = new VividConsoleLogger(LogLevel.Trace, await FileLogger.CreateAsync(Path.Combine(ENV.AppFolder, "wan24PoeditParser.log"), LogLevel.Trace));
File.WriteAllText(Path.Combine(ENV.AppFolder, "wan24PoeditParser.CLI.log"), string.Join(' ', Environment.GetCommandLineArgs()));
throw new Exception(ENV.AppFolder);
Logging.Logger = new VividConsoleLogger(LogLevel.Trace, await FileLogger.CreateAsync(Path.Combine(ENV.AppFolder, "wan24PoeditParser.log"), LogLevel.Trace).DynamicContext());
#endif
Translation.Current = Translation.Dummy;
Translation.Current ??= Translation.Dummy;
CliApi.CommandLine = "wan24PoeditParser";
return await CliApi.RunAsync(args, exportedApis: [typeof(CliHelpApi), typeof(ParserApi)]);
10 changes: 7 additions & 3 deletions src/wan24-PoeditParser CLI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This is a small dotnet tool for parsing source code for gettext strings and
writing the result in the PO format to a file or STDOUT.

**CAUTION**: It can create a PO file from the command line, but using it as
Poedit extractor didn't work yet (Poedit discards the custom extractor
configuration, which may be a bug - not sure yet).

It's pre-configured for use with the
[`wan24-Core`](https://github.com/WAN-Solutions/wan24-Core) translation
helpers for C#, but it can be customized easily for any environment and any
Expand Down Expand Up @@ -39,9 +43,9 @@ folder tree.

Per default keywords will be found by these regular expressions:

- `^.*((Description|DisplayText)\(\s*(\"".*[^\\]\"")\s*\)).*$` (`$3`)
- `^.*((_|gettextn?|Translate(Plural)?)\(\s*(\"".*[^\\]\"")).*$` (`$4`)
- `^.*(CliApi[^\s]*\([^\)]*Example\s*\=\s*(\"".*[^\\]\"")).*$` (`$2`)
- `^.*((Description|DisplayText)\(\s*(\".*[^\\]\")\s*\)).*$` (`$3`)
- `^.*((__?|gettextn?|Translate(Plural)?|GetTerm)\(\s*(\".*[^\\]\")).*$` (`$4`)
- `^.*(CliApi[^\s]*\([^\)]*Example\s*\=\s*(\".*[^\\]\")).*$` (`$2`)

**NOTE**: (Multiline) concatenated string value definitions (like
`"Part a" + "Part b"`) or interpolations can't be parsed. The matched keyword
Expand Down
4 changes: 2 additions & 2 deletions src/wan24-PoeditParser CLI/wan24-PoeditParser CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
</Target>

<ItemGroup>
<PackageReference Include="wan24-CLI" Version="1.2.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-Core" Version="2.10.1" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-CLI" Version="1.3.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-Core" Version="2.11.0" Condition="'$(Configuration)' != 'Trunk'" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 2366e8c

Please sign in to comment.