PvWay.ExcelTranslationProvider.Abstractions.nc8 2.0.0

dotnet add package PvWay.ExcelTranslationProvider.Abstractions.nc8 --version 2.0.0
NuGet\Install-Package PvWay.ExcelTranslationProvider.Abstractions.nc8 -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PvWay.ExcelTranslationProvider.Abstractions.nc8" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PvWay.ExcelTranslationProvider.Abstractions.nc8 --version 2.0.0
#r "nuget: PvWay.ExcelTranslationProvider.Abstractions.nc8, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PvWay.ExcelTranslationProvider.Abstractions.nc8 as a Cake Addin
#addin nuget:?package=PvWay.ExcelTranslationProvider.Abstractions.nc8&version=2.0.0

// Install PvWay.ExcelTranslationProvider.Abstractions.nc8 as a Cake Tool
#tool nuget:?package=PvWay.ExcelTranslationProvider.Abstractions.nc8&version=2.0.0

pvWay Excel Translations Provider for dotNet Core 8

Description

This package provide the abstraction layer for the pvWayExcelTranslationProvider package.

Content

Cache

Usually implemented as a singleton it maintains the array of translations in cache.

namespace PvWay.ExcelTranslationProvider.Abstractions.nc8
{
    public interface IPvWayExcelTranslationCache
    {
        /// <summary>
        /// With this date any data consumer can verify
        /// whether or not its cached copy of the dictionary
        /// is still up to date and if needed refresh the
        /// cache by getting the Translation property.
        /// </summary>
        /// <returns></returns>
        DateTime LastUpdateDateUtc { get; }

        /// <summary>
        /// The key is build from the concatenation of
        /// up to 4 key parts separated by dots. Example: 'components.buttons.save').
        /// The associated value is dictionary languageCode:string
        /// </summary>
        IDictionary<string, IDictionary<string, string>> Translations { get; }

        /// <summary>
        /// Stop re-scanning the folder
        /// </summary>
        void StopRescan();
        
        /// <summary>
        /// Re-scan the folder for updated Excel files
        /// </summary>
        void RefreshNow();

        /// <summary>
        /// key string should contain the keys separated by dots. example : 'enum.size'
        /// </summary>
        /// <param name="languageCode"></param>
        /// <param name="keysString"></param>
        /// <returns></returns>
        string GetTranslation(string languageCode, string keysString);
    }

}```
### Cache loading

For loading the cache you need to inject an implementation of the IPvWayExcelTranslationService.

```csharp
namespace PvWay.ExcelTranslationProvider.Abstractions.nc8
{
    /// <summary>
    /// This service provides the mechanism for managing a cached
    /// translation dictionary at data consumer side
    /// </summary>
    public interface IPvWayExcelTranslationService : IDisposable
    {
        /// <summary>
        /// With this date any data consumer can verify
        /// whether or not its cached copy of the dictionary
        /// is still up to date and if needed refresh the
        /// cache by getting the Translation property.
        /// </summary>
        /// <returns></returns>
        DateTime LastUpdateDateUtc { get; }

        /// <summary>
        /// The key is build from the concatenation of
        /// up to 4 key parts separated by dots. Example: 'components.buttons.save').
        /// The associated value is dictionary languageCode:string
        /// </summary>
        IDictionary<string, IDictionary<string, string>> ReadTranslations();
    }
}

There are two flavour for this service:

  • Assembly based
  • File system based

ExcelTranslationService using Excel as embedded resources in a given assembly

using System.Reflection;
using System.Text.RegularExpressions;

namespace PvWay.ExcelTranslationProvider.Abstractions.nc8;


public interface IPvWayAssemblyBasedExcelTranslationServiceConfig
{
    /// <summary>
    /// This will be used for selecting Excel resources from
    /// the collection of resource names
    /// Example: "tr.+\\.xlsx$" for getting all resources
    /// where the name starts with "tr." and ends with ".xlsx"
    /// </summary>
    Regex ResourceNameMatcher { get; }
    /// <summary>
    /// The assembly containing the Excel resources
    /// </summary>
    Assembly Assembly { get; }
    
    Action<Exception> LogException { get; } 
}

ExcelTranslationService using Excel files on file system

namespace PvWay.ExcelTranslationProvider.Abstractions.nc8;

public interface IPvWayFolderBasedExcelTranslationServiceConfig
{
    /// <summary>
    /// The external folder containing the translation Excel 
    /// </summary>
    string ExcelFolderPath { get; }
    /// <summary>
    /// A wildcard such as "tr_*.xls?"
    /// </summary>
    string FileWildCard { get; }
    /// <summary>
    /// A delegate for logging exceptions
    /// </summary>
    Action<Exception> LogException { get; }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PvWay.ExcelTranslationProvider.Abstractions.nc8:

Package Downloads
PvWay.ExcelTranslationProvider.nc8

Provides Excel based translations in cache

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 94 5/14/2024
1.0.0 79 5/13/2024

Some updates in config contracts