From 5fd8ac481b4ef9a6a558f985da9f111c3063f34e Mon Sep 17 00:00:00 2001 From: Jo-Be-Co Date: Tue, 14 Apr 2026 01:14:45 +0200 Subject: [PATCH] review fixes --- .../Templates/CultureInfoDto.cs | 2 +- .../Templates/RegionInfoDto.cs | 8 ++++---- docs/features/naming-templates.md | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/LibationFileManager/Templates/CultureInfoDto.cs b/Source/LibationFileManager/Templates/CultureInfoDto.cs index 0b06b9cd..27d7d56c 100644 --- a/Source/LibationFileManager/Templates/CultureInfoDto.cs +++ b/Source/LibationFileManager/Templates/CultureInfoDto.cs @@ -30,7 +30,7 @@ public record CultureInfoDto : IFormattable { } - public CultureInfoDto(CultureInfo value, string hint, string defaultFormat) + public CultureInfoDto(CultureInfo? value, string hint, string defaultFormat) { Original = hint; DefaultFormat = defaultFormat; diff --git a/Source/LibationFileManager/Templates/RegionInfoDto.cs b/Source/LibationFileManager/Templates/RegionInfoDto.cs index a2f8699e..3a64b9d7 100644 --- a/Source/LibationFileManager/Templates/RegionInfoDto.cs +++ b/Source/LibationFileManager/Templates/RegionInfoDto.cs @@ -22,12 +22,12 @@ public partial record RegionInfoDto : IFormattable { } - public RegionInfoDto(RegionInfo value, string hint, string defaultFormat) + public RegionInfoDto(RegionInfo? value, string hint, string defaultFormat) { Original = hint; DefaultFormat = defaultFormat; Value = value; - Culture = GetCultureInfo(value); + Culture = value is null ? null : GetCultureInfo(value); } private static RegionInfo? GetRegion(string input) @@ -60,11 +60,11 @@ public partial record RegionInfoDto : IFormattable [GeneratedRegex(@"\((?.+)\)")] private static partial Regex ExtractRegionName(); - private static CultureInfo GetCultureInfo(RegionInfo region) + private static CultureInfo? GetCultureInfo(RegionInfo region) { // find culture for region return CultureInfo.GetCultures(CultureTypes.SpecificCultures) - .First(c => Equals(new RegionInfo(c.Name), region)); + .FirstOrDefault(c => Equals(new RegionInfo(c.Name), region)); } diff --git a/docs/features/naming-templates.md b/docs/features/naming-templates.md index 2e447932..c3338738 100644 --- a/docs/features/naming-templates.md +++ b/docs/features/naming-templates.md @@ -224,10 +224,10 @@ You can use custom formatters to construct customized DateTime string. For more You can specify which part of a region you are interested in. -| Formatter | Description | Example Usage | Example Result | -|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|--------------------| -| \{O \| I \| I2 \| I3 \| E \| N \| W \| ID\} | Formats the region using
the region part tags.
\{O:[Text_Formatter](#text-formatters)\} = Region as provided by audible
\{I:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{I2:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{I3:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{E:[Text_Formatter](#text-formatters)\} = English name
\{N:[Text_Formatter](#text-formatters)\} = Native name - OS dependant
\{W:[Text_Formatter](#number-formatters)\} = Unique Windows code
\{ID:[Text_Formatter](#text-formatters)\} = Lang code

Formatter parts are optional and introduced by the colon. If specified the string will be used to format the part using the corresponding formatter.

Default is \{O\} | `` | US (United States) | -| \{D\} **†** | Display name interpreted by the current language settings.
To ensure output in a specific language the lang-code to use might be spcified with a leading '@'.
Formatter part is also optional and introduced by the colon.
\{D@LANG:[Text_Formatter](#text-formatters)\} | `` | ESTADOS UNIDOS | +| Formatter | Description | Example Usage | Example Result | +|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|--------------------| +| \{O \| I \| I2 \| I3 \| E \| N \| W \| ID\} | Formats the region using
the region part tags.
\{O:[Text_Formatter](#text-formatters)\} = Region as provided by audible
\{I:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{I2:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{I3:[Text_Formatter](#text-formatters)\} = Three letter ISO code
\{E:[Text_Formatter](#text-formatters)\} = English name
\{N:[Text_Formatter](#text-formatters)\} = Native name - OS dependent
\{W:[Text_Formatter](#number-formatters)\} = Unique Windows code
\{ID:[Text_Formatter](#text-formatters)\} = Region code

Formatter parts are optional and introduced by the colon. If specified the string will be used to format the part using the corresponding formatter.

Default is \{O\} | `` | US (United States) | +| \{D\} **†** | Display name interpreted by the current language settings.
To ensure output in a specific language the lang-code to use might be specified with a leading '@'.
Formatter part is also optional and introduced by the colon.
\{D@LANG:[Text_Formatter](#text-formatters)\} | `` | ESTADOS UNIDOS | **†** LANG may be any code from the [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) standard like `es` for Spanish, `en` for English, `de` for German, etc. or even a [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) like 'fr-CA'. @@ -235,10 +235,10 @@ You can specify which part of a region you are interested in. You can specify which part of a language you are interested in. -| Formatter | Description | Example Usage | Example Result | -|---------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|----------------| -| \{O \| I \| I2 \| I3 \| E \| N \| W \| ID\} | Formats the language using
the language part tags.
\{O:[Text_Formatter](#text-formatters)\} = Language as provided by audible
\{I:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{I2:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{I3:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{E:[Text_Formatter](#text-formatters)\} = English name
\{N:[Text_Formatter](#text-formatters)\} = Native name - OS dependant
\{W:[Text_Formatter](#number-formatters)\} = Unique Windows code
\{ID:[Text_Formatter](#text-formatters)\} = Lang code

Formatter parts are optional and introduced by the colon. If specified the string will be used to format the part using the corresponding formatter.

Default is \{O\} | `` | fra (French) | -| \{D\} | Display name interpreted by the current language settings.
To ensure output in a specific language the lang-code to use might be spcified with a leading '@'.
Formatter part is also optional and introduced by the colon.
\{D@LANG:[Text_Formatter](#text-formatters)\} | `` | francés | +| Formatter | Description | Example Usage | Example Result | +|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|----------------| +| \{O \| I \| I2 \| I3 \| E \| N \| W \| ID\} | Formats the language using
the language part tags.
\{O:[Text_Formatter](#text-formatters)\} = Language as provided by audible
\{I:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{I2:[Text_Formatter](#text-formatters)\} = Two letter ISO code
\{I3:[Text_Formatter](#text-formatters)\} = Three letter ISO code
\{E:[Text_Formatter](#text-formatters)\} = English name
\{N:[Text_Formatter](#text-formatters)\} = Native name - OS dependent
\{W:[Text_Formatter](#number-formatters)\} = Unique Windows code
\{ID:[Text_Formatter](#text-formatters)\} = Lang code

Formatter parts are optional and introduced by the colon. If specified the string will be used to format the part using the corresponding formatter.

Default is \{O\} | `` | fra (French) | +| \{D\} | Display name interpreted by the current language settings.
To ensure output in a specific language the lang-code to use might be specified with a leading '@'.
Formatter part is also optional and introduced by the colon.
\{D@LANG:[Text_Formatter](#text-formatters)\} | `` | francés | ### Checks