Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
+ Updated references
  • Loading branch information
nd1012 committed Jul 6, 2024
1 parent 6156e83 commit 8ad3658
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
48 changes: 40 additions & 8 deletions src/wan24-I8N/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ expressions, until the final quoted keyword was extracted from a line.
These default translation method names can be parsed from source code:

- `_`
- `gettext(n)("..."`
- `gettext(n|d)("..."`
- `Translate(Plural)("..."`
- `GetTerm("..."`

Expand All @@ -89,16 +89,26 @@ argument after a numeric argument:

- `ExitCode(N, "..."`

**NOTE**: (Multiline) concatenated string value definitions (like
`@"Part \ a" + $"Part b {variable}"`) or interpolations can't be parsed. The
matched string literal must be JSON style escaped.

To force including any string (from a constant definition, for example),
simply add a comment `wan24I8NTool:include` at the end of the line - example:

```cs
public const string NAME = "Any PO included keyword";// wan24I8NTool:include
```

**NOTE**: (Multiline) concatenated string value definitions (like
`@"Part \ a" + $"Part b {variable}"`) or interpolations can't be parsed. The
matched string literal must be JSON style escaped.
To force excluding any line, simply add a comment `wan24I8NTool:exclude` to
that line - example:

```cs
string text = gettext("Text file keyword");// wan24I8NTool:exclude
```

This will avoid including the text file ID `Text file keyword` (see below)
as an additional term to translate into the catalog.

### Custom parser configuration

Expand Down Expand Up @@ -137,6 +147,10 @@ Example parser JSON configuration:
".ext",
...
],
"TextFileExtensions": [// (optional) Text file extensions to include when walking through a folder tree (may be overridden by --textFileExt)
".ext.txt",
...
],
"MergeOutput": true,// (optional) Merge the extracted keywords to the existing output PO file
"FailOnError": true,// (optional) To fail thewhole process on any error
"Merge": false// (optional) Set to true to merge your custom configuration with the default configuration
Expand Down Expand Up @@ -165,19 +179,37 @@ configuration using a `AppConfig` structure
- `CLI`: [`wan24-CLI`](https://github.com/nd1012/wan24-CLI) configuration
using a `CliAppConfig` structure

### About including text files

The extractor API does also incude text files - per default filtered by:

- `*.translate.txt` (for simple text)
- `*.translate.md` (for MarkDown text)

When doing so, you can address the translation using the filename without
extensions as keyword - example for `Info text.translate.txt`:

```cs
string text = _("Info text");// wan24I8NTool:exclude
```

The `wan24I8NTool:exclude` does tell the extractor to skip adding `Info text`
as keyword to translate, because what you want to translate, is the text file
content, but not the keyword used to load the translation in that case.

### Build, extract, display and use an i8n file

i8n files contain optional compressed translation terms. They can be created
from PO/MO and/or JSON dictionary (keyword as key, translation as an array of
strings as value) input files like this:
strings as value) or wan24-I8NKws input files like this:

```bash
wan24I8NTool i8n -compress --poInput /path/to/input.po --output /path/to/output.i8n
```

An i8n file can be embedded into an app, for example.

To convert all `*.json|po|mo` files in the current folder to `*.i8n` files:
To convert all `*.json|po|mo|kws` files in the current folder to `*.i8n` files:

```bash
wan24I8NTool i8n buildmany -compress -verbose
Expand All @@ -201,10 +233,10 @@ To extract some i8n file to a PO file:
wan24I8NTool i8n extract --input /path/to/input.i8n --poOutput /path/to/output.po
```

To extract some i8n file to a wan24-I8NLws file:
To extract some i8n file to a wan24-I8NKws file:

```bash
wan24I8NTool i8n extract --input /path/to/input.i8n --kwsOutput /path/to/output.po
wan24I8NTool i8n extract --input /path/to/input.i8n --kwsOutput /path/to/output.kws
```

**NOTE**: For more options and usage instructions please use the CLI API help
Expand Down
2 changes: 1 addition & 1 deletion src/wan24-I8NTool CLI/wan24-I8NTool CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<PackageReference Include="wan24-CLI" Version="1.4.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-Compression" Version="2.9.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-Core" Version="2.31.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-I8NKws" Version="1.1.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-I8NKws" Version="1.2.0" Condition="'$(Configuration)' != 'Trunk'" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 8ad3658

Please sign in to comment.