Noctilocus.SmartFormat 1.0.0-beta.5

Suggested Alternatives

Metaphrase.SmartFormat

This is a prerelease version of Noctilocus.SmartFormat.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Noctilocus.SmartFormat --version 1.0.0-beta.5
                    
NuGet\Install-Package Noctilocus.SmartFormat -Version 1.0.0-beta.5
                    
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="Noctilocus.SmartFormat" Version="1.0.0-beta.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Noctilocus.SmartFormat" Version="1.0.0-beta.5" />
                    
Directory.Packages.props
<PackageReference Include="Noctilocus.SmartFormat" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Noctilocus.SmartFormat --version 1.0.0-beta.5
                    
#r "nuget: Noctilocus.SmartFormat, 1.0.0-beta.5"
                    
#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.
#:package Noctilocus.SmartFormat@1.0.0-beta.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Noctilocus.SmartFormat&version=1.0.0-beta.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Noctilocus.SmartFormat&version=1.0.0-beta.5&prerelease
                    
Install as a Cake Tool

Noctilocus

Build Action Publish Action License .NET 8 .NET 9 Downloads

A C# port of the ngx-translate. The port is not one to one and also aims to be more C# friendly where possible.

The library provides you with a TranslateService which combined with a TranslateLoader (HttpLoader built in) enables you to load, compile and display your translations using formatting with keys. For much stronger formatting there exists a supporting package that uses the awesome SmartFormat package.

Packages

Package Stable Pre
Noctilocus Noctilocus Noctilocus
Noctilocus.SmartFormat Noctilocus.SmartFormat Noctilocus.SmartFormat

Usage

Description

  • Noctilocus
    • Contains the abstractions, defaults, primitives, http loader and the service.
  • Noctilocus.SmartFormat
    • Contains the SmartFormatParser.

Installation:

  • Noctilocus in projects that you want to use the service or any of the primitives.
  • Noctilocus.SmartFormat in projects that use the service and you want to replace the default parser.

Getting Started

The section will describe how to get started with Noctilocus in a Blazor Wasm using the HttpLoader storing the language files at wwwroot/i18n.

  1. Add the Noctilocus package.
dotnet add package Noctilocus
  1. Add the appropriate services to the service provider.
services.AddScoped(sp => new HttpClient() { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
services.AddScoped<TranslateLoader, TranslateHttpLoader>(); // This will use the default options
services.AddScoped<TranslateService>(); // This will use the default parser
  1. Use the service

TranslateService also supports a "pipe" syntax to get your translation values.

For the tanslation key: hello and value: Hello you can do:

translate.Instant("hello") // prints "Hello"
translate | "hello" // prints "Hello"

For the translation key: welcome, value: Welcome {user}! and param: user.

translate.Instant("hello", new { user = "panos" }) // prints "Welcome panos"!
translate | "hello" | new { user = "panos" } // prints "Welcome panos"!

Contributing

For general contribution information you can read the Raven Tail Contributing document.

Local Development

To develop you need:

  1. dotnet 9.0 SDK
  2. Visual Studio or VS Code with the C# extension.
  3. Configured your IDE for the TUnit library.
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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated