Slang.Net
1.1.0-preview1
dotnet add package Slang.Net --version 1.1.0-preview1
NuGet\Install-Package Slang.Net -Version 1.1.0-preview1
<PackageReference Include="Slang.Net" Version="1.1.0-preview1" />
paket add Slang.Net --version 1.1.0-preview1
#r "nuget: Slang.Net, 1.1.0-preview1"
// Install Slang.Net as a Cake Addin #addin nuget:?package=Slang.Net&version=1.1.0-preview1&prerelease // Install Slang.Net as a Cake Tool #tool nuget:?package=Slang.Net&version=1.1.0-preview1&prerelease
Slang.NET
Type-safe i18n for .NET
Slang.NET is a .NET port of the slang from the Dart/Flutter community.
Getting Started:
Install the library as a NuGet package:
Install-Package dotnet add package Slang.Net
Add JSON files:
Important file must end with ".i18n.json". This is necessary so that the SourceGenerator does not track changes to other AdditionalFiles.
i18n/strings_en.i18n.json
{
"screen": {
"locale1": "Locale 1"
}
}
i18n/strings_ru.i18n.json
{
"screen": {
"locale1": "Локаль 1"
}
}
slang.json
{
"base_culture": "ru"
}
Include JSON files as AdditionalFiles:
<ItemGroup>
<AdditionalFiles Include="i18n\*.i18n.json" />
<AdditionalFiles Include="slang.json" />
</ItemGroup>
Add a partial class:
[Translations(InputFileName = "strings")]
public partial class Strings;
Done!
Strings.SetCulture(new CultureInfo("ru-RU"));
Console.WriteLine(Strings.Translations.Screen.Locale1); // Локаль 1
Strings.SetCulture(new CultureInfo("en-US"));
Console.WriteLine(Strings.Translations.Screen.Locale1); // Locale 1
Features
- String Interpolation
- Pluralization
- Linked Translations
- Maps
- Lists
- Typed Parameters
- Comments
Tools
Translate with GPT
Take advantage of GPT to internationalize your app with context-aware translations.
Download slang-gpt.
Then add the following configuration in your slang.json:
{
"base_culture": "ru",
"gpt": {
"model": "gpt-4o-mini",
"description": "Showcase for Slang.Net.Gpt"
}
}
Then use slang-gpt:
<Dir with slang-gpt CLI>/slang-gpt <csproj Path> --target=ru --api-key=<open-ai-gpt-api-key>
See more: Documentation
Roadmap
- String Formatting (double, dates and etc)
- Performance improvements
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
-
net6.0
- No dependencies.
-
net8.0
- 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.
Version | Downloads | Last updated |
---|---|---|
1.1.0-preview1 | 46 | 10/7/2024 |
1.0.0-preview9 | 46 | 10/5/2024 |
1.0.0-preview8 | 48 | 10/2/2024 |
1.0.0-preview7 | 43 | 9/29/2024 |
1.0.0-preview6 | 46 | 9/29/2024 |
1.0.0-preview5 | 50 | 9/29/2024 |
1.0.0-preview4 | 48 | 9/29/2024 |
1.0.0-preview3 | 43 | 9/27/2024 |
1.0.0-preview1 | 50 | 9/25/2024 |