From a35b0378e7b06cc4eb257c5ae5ae838aef63bfcf Mon Sep 17 00:00:00 2001 From: nd Date: Sun, 17 Mar 2024 19:39:30 +0100 Subject: [PATCH] Update (#3) --- src/wan24-I8NTool CLI/README.md | 48 +++++++++++++++---- .../wan24-I8NTool CLI.csproj | 2 +- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/wan24-I8NTool CLI/README.md b/src/wan24-I8NTool CLI/README.md index 966fd49..378afb1 100644 --- a/src/wan24-I8NTool CLI/README.md +++ b/src/wan24-I8NTool CLI/README.md @@ -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("..."` @@ -89,6 +89,10 @@ 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: @@ -96,9 +100,15 @@ simply add a comment `wan24I8NTool:include` at the end of the line - example: 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 @@ -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 @@ -165,11 +179,29 @@ 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 @@ -177,7 +209,7 @@ wan24I8NTool i8n -compress --poInput /path/to/input.po --output /path/to/output. 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 @@ -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 diff --git a/src/wan24-I8NTool CLI/wan24-I8NTool CLI.csproj b/src/wan24-I8NTool CLI/wan24-I8NTool CLI.csproj index 58787dd..fb23bea 100644 --- a/src/wan24-I8NTool CLI/wan24-I8NTool CLI.csproj +++ b/src/wan24-I8NTool CLI/wan24-I8NTool CLI.csproj @@ -10,7 +10,7 @@ Debug;Release;Trunk wan24-I8NTool wan24-I8NTool - 1.1.0 + 1.2.0 nd1012 Andreas Zimmermann, wan24.de wan24-I8NTool