ScriptBundleTranslator 1.0.1
See the version list below for details.
dotnet add package ScriptBundleTranslator --version 1.0.1
NuGet\Install-Package ScriptBundleTranslator -Version 1.0.1
<PackageReference Include="ScriptBundleTranslator" Version="1.0.1" />
paket add ScriptBundleTranslator --version 1.0.1
#r "nuget: ScriptBundleTranslator, 1.0.1"
// Install ScriptBundleTranslator as a Cake Addin #addin nuget:?package=ScriptBundleTranslator&version=1.0.1 // Install ScriptBundleTranslator as a Cake Tool #tool nuget:?package=ScriptBundleTranslator&version=1.0.1
ScriptBundleTranslator
A simple .NET Script bundling translator, created to easily communicate with the ResourceManager
class and it's made in conjuction with the Microsoft.AspNet.Web.Optimization
bundler package in order to create translated scripts eliminating the need of creating global variables with translation keyvaluepairs.
These translated bundles are also cached by language, this means they won't be regenerated again, unless they change in the source code.
How to add this to my project
Simple check the Configuration Samples and add them to your project.
Then on the MVC's BundleConfig.cs
simple call the bundler as shown down below.
bundles.AddRange(ScriptTranslationBundle.Create("~/bundles/general", "~/Scripts/General/General.js"));
This will create bundles for all the avaiable cultures inside your CultureSettings configuration.
How to use
Use in between curly brackers the name of your resource file (.resx) and with a slash (/) name the key you want to use.
public success: string = "{JSTranslator/Success}";
public failed: string = "{JSTranslator/Failed}";
public loading: string = "{JSTranslator/Loading}";
Which will be rendered as the proper translation value.
EN:
var success = "Success";
var failed = "Failed";
var loading = "Loading";
PT:
var success = "Sucesso";
var failed = "Falhou";
var loading = "A Carregar";
Call the script on a razor page via
@ScriptBundleTranslator.Mvc.HtmlHelpers.LocalizedJsBundle("~/bundles/general")
Dependencies
- Microsoft.AspNet.Web.Optimization
- Microsoft.Web.Infrastructure (>= 1.0.0)
- WebGrease (>= 1.5.2)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
- Antlr (>= 3.5.0.2)
- Microsoft.AspNet.Web.Optimization (>= 1.1.3)
- Newtonsoft.Json (>= 12.0.3)
- WebGrease (>= 1.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.