ScriptBundleTranslator 1.0.4

dotnet add package ScriptBundleTranslator --version 1.0.4                
NuGet\Install-Package ScriptBundleTranslator -Version 1.0.4                
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="ScriptBundleTranslator" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ScriptBundleTranslator --version 1.0.4                
#r "nuget: ScriptBundleTranslator, 1.0.4"                
#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 ScriptBundleTranslator as a Cake Addin
#addin nuget:?package=ScriptBundleTranslator&version=1.0.4

// Install ScriptBundleTranslator as a Cake Tool
#tool nuget:?package=ScriptBundleTranslator&version=1.0.4                

ScriptBundleTranslator

CodeFactor NuGet Badge GPL Licence HitCount

forthebadge forthebadge forthebadge

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)
There are no supported framework assets in this package.

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.

Fixed nuget.