< Summary

Information
Class: MyNet.Globalization.Localization.Translation.KeyResolving.TranslationFallbackPolicy
Assembly: MyNet.Globalization
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Globalization/Localization/Translation/KeyResolving/ITranslationKeyResolver.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 72
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Strict()100%11100%
get_Flexible()100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Globalization/Localization/Translation/KeyResolving/ITranslationKeyResolver.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="ITranslationKeyResolver.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System.Collections.Generic;
 8using System.Globalization;
 9
 10namespace MyNet.Globalization.Localization.Translation.KeyResolving;
 11
 12/// <summary>
 13/// Resolves candidate translation keys based on translation options.
 14/// </summary>
 15public interface ITranslationKeyResolver
 16{
 17    /// <summary>
 18    /// Resolves a list of candidate translation keys based on the base key, translation options, and culture.
 19    /// </summary>
 20    /// <param name="baseKey">The base translation key.</param>
 21    /// <param name="options">Translation options.</param>
 22    /// <param name="culture">Culture used for pluralization rules.</param>
 23    /// <returns>A collection of <see cref="TranslationKeyCandidate"/> representing the resolved keys and inflection fal
 24    IReadOnlyCollection<TranslationKeyCandidate> Resolve(string baseKey, TranslationOptions options, CultureInfo culture
 25
 26    /// <summary>
 27    /// Resolves a pluralized translation key based on the count and culture.
 28    /// </summary>
 29    /// <param name="baseKey">The base translation key.</param>
 30    /// <param name="count">The count used for pluralization.</param>
 31    /// <param name="culture">The culture used for pluralization rules.</param>
 32    /// <returns>The pluralized translation key.</returns>
 33    string ResolvePluralizedKey(string baseKey, decimal count, CultureInfo culture);
 34
 35    /// <summary>
 36    /// Resolves a styled translation key based on the display style.
 37    /// </summary>
 38    /// <param name="baseKey">The base translation key.</param>
 39    /// <param name="style">The display style.</param>
 40    /// <param name="culture">The culture used for pluralization rules.</param>
 41    /// <returns>The styled translation key.</returns>
 42    string ResolveStyledKey(string baseKey, DisplayStyle style, CultureInfo culture);
 43}
 44
 45/// <summary>
 46/// Represents a candidate translation key along with its associated fallback policy. This record encapsulates the trans
 47/// </summary>
 48/// <param name="Key">The translation key.</param>
 49/// <param name="Policy">The fallback policy associated with the translation key.</param>
 50public sealed record TranslationKeyCandidate(string Key, TranslationFallbackPolicy Policy);
 51
 52/// <summary>
 53/// Represents the policy for translation fallback, specifically whether inflection fallback is allowed when resolving t
 54/// </summary>
 55public sealed record TranslationFallbackPolicy
 56{
 57    /// <summary>
 58    /// Gets a value indicating whether to allow inflection fallback when resolving translation keys. If true, inflectio
 59    /// </summary>
 60    public bool AllowInflectionFallback { get; init; }
 61
 62    /// <summary>
 63    /// Gets a translation fallback policy that does not allow inflection fallback. When this policy is used, the transl
 64    /// </summary>
 51965    public static TranslationFallbackPolicy Strict => new() { AllowInflectionFallback = false };
 66
 67    /// <summary>
 68    /// Gets a translation fallback policy that allows inflection fallback. When this policy is used, the translation ke
 69    /// </summary>
 819070    public static TranslationFallbackPolicy Flexible => new() { AllowInflectionFallback = true };
 71}
 72

Methods/Properties

get_Strict()
get_Flexible()