BergamotTranslatorSharp 0.3.3

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

BergamotTranslatorSharp

App Build GitHub Release NuGet Version NuGet Downloads

BergamotTranslatorSharp is a C# wrapper for Bergamot Translator. It allows easy integration of an offline machine translation engine into .NET applications.

| EN | JA |

Overview

Bergamot Translator is an offline translation engine. The official website is https://browser.mt/. This library wraps its functionality for use from C#.

Features

  • Offline translation capability
  • Multi-language support
  • Fast processing
  • Easy integration with .NET applications

Installation

Installation from NuGet

Install-Package BergamotTranslatorSharp

Or

dotnet add package BergamotTranslatorSharp

Requirements

  • .NET 6.0 or later
  • .NET Standard 2.1 or later
  • Windows x64 or Linux x64

Usage

Downloading Models and Creating Configuration Files

  1. Download and extract models from the Firefox Translations models official website.
    cd test_page
    git clone --depth 1 --branch main --single-branch https://github.com/mozilla/firefox-translations-models/
    mkdir models
    cp -rf firefox-translations-models/registry.json models
    cp -rf firefox-translations-models/models/prod/* models
    cp -rf firefox-translations-models/models/dev/* models
    gunzip models/*/*
    
  2. Create a configuration file in the same location as the binary file.
    relative-paths: true
    models:
    - model.enja.intgemm.alphas.bin // model path
    vocabs:
    - vocab.enja.spm // source vocabulary path
    - vocab.enja.spm // target vocabulary path
    shortlist:
    - lex.50.50.enja.s2t.bin // shortlist path
    - false
    beam-size: 1
    normalize: 1.0
    word-penalty: 0
    max-length-break: 128
    mini-batch-words: 1024
    workspace: 128
    max-length-factor: 2.0
    skip-cost: true
    cpu-threads: 0
    quiet: true
    quiet-translation: true
    gemm-precision: int8shiftAlphaAll // specify 'int8shiftAlphaAll' if the model name contains 'alphas', otherwise specify 'int8shiftAll'
    

Initializing the Translation Service and Translating

using BergamotTranslatorSharp;

// Create an instance of BergamotTranslator
using var translator = new BergamotTranslator(configPath);

// Execute translation
string sourceText = "Hello, world!";
string translatedText = translator.Translate(sourceText);

Console.WriteLine(translatedText); // こんにちは、世界!

License

This project is released under the MPL-2.0 license.

Contribution

Please report bugs and feature requests to the GitHub Issue Tracker. Pull requests are also welcome.

Acknowledgments

This project is based on browsermt/bergamot-translator.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  net9.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • 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
0.3.3 274 3/29/2025
0.3.1 121 3/29/2025
0.3.0 462 3/26/2025
0.2.1 79 3/22/2025
0.1.1 79 3/22/2025
0.1.0 82 3/21/2025
0.0.1 144 3/20/2025