SourceGenerator.Fluent
0.2.0
See the version list below for details.
dotnet add package SourceGenerator.Fluent --version 0.2.0
NuGet\Install-Package SourceGenerator.Fluent -Version 0.2.0
<PackageReference Include="SourceGenerator.Fluent" Version="0.2.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="SourceGenerator.Fluent" Version="0.2.0" />
<PackageReference Include="SourceGenerator.Fluent"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add SourceGenerator.Fluent --version 0.2.0
#r "nuget: SourceGenerator.Fluent, 0.2.0"
#addin nuget:?package=SourceGenerator.Fluent&version=0.2.0
#tool nuget:?package=SourceGenerator.Fluent&version=0.2.0
Fluent.Generator
This tool generates design classes of ftl files. It creates boilerplate code to use with Fluent.Net
Getting Started
Install the nuget package, add an FTL file to your project, set it as additonal file.
<ItemGroup>
<AdditionalFiles Include="**/*.ftl" />
</ItemGroup>
Having a file like this named TestFtl.ftl:
# Simple things are simple.
hello-world = Hello, world!
# Complex things are possible.
shared-photos =
{$userName} {$photoCount ->
[one] added a new photo
*[other] added {$photoCount} new photos
} to {$userGender ->
[male] his stream
[female] her stream
*[other] their stream
}.
And you can access the translations in code using
var firstString = TestFtl.HelloWorld;
var seccondString = TestFtl.SharedPhotos[userName:"Bob", photoCount:3, userGender:"male"];
Parameter Type
Fluent.Generator trys to guess the type of parameters.
# $duration (Number) - The duration in seconds.
time-elapsed = Time elapsed: { $duration }s.
will result in
public string this[System.Double duration]
{
get
{
return this.messageContext.Format(this.messageContext.GetMessage("time-elapsed"), new Dictionary<string, object>{{"duration", duration}});
}
}
In order to get correct types, you need to document those in the comments. If a line in the comments start with $<variable name>
followed by the type in round parenthise ()
followed by a dash -
and the variable exists
we'll set the parameter type to the provided. You can use .Net types and the string Number
which will interpreted as double.
You can ommit the type and the parethisees. In that case the object type is used.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.