bergamot-translator/wasm
dependabot[bot] 620c8b00ec
Bump qs and express in /wasm/test_page (#444)
Bumps [qs](https://github.com/ljharb/qs) to 6.11.0 and updates ancestor dependency [express](https://github.com/expressjs/express). These dependencies need to be updated together.


Updates `qs` from 6.7.0 to 6.11.0
- [Release notes](https://github.com/ljharb/qs/releases)
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.7.0...v6.11.0)

Updates `express` from 4.17.1 to 4.18.2
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.17.1...4.18.2)

---
updated-dependencies:
- dependency-name: qs
  dependency-type: indirect
- dependency-name: express
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-18 15:30:58 +00:00
..
bindings JS: Using supervised QE models for available language pairs (#378) 2022-03-15 15:55:28 +01:00
test_page Bump qs and express in /wasm/test_page (#444) 2023-01-18 15:30:58 +00:00
CMakeLists.txt Upgrade emsdk to 3.1.8 (#414) 2022-04-20 00:39:32 +01:00
import-gemm-module.js JS/WASM: Re-enable importing optimized gemm module for (#336) 2022-02-07 16:55:31 +01:00
node-test.js Basic HTML property testing for WebAssembly (#425) 2022-06-21 14:07:17 +01:00
patch-artifacts-enable-wormhole.sh Improved wasm scripts and README (#128) 2021-05-04 10:18:45 +01:00
patch-artifacts-import-gemm-module.sh Import optimized gemm implementation (when available) for wasm target (#265) 2021-11-17 09:18:55 +01:00
project_version.js.in Modified wasm cmake file to include version information in built artifacts 2021-05-17 19:34:58 +02:00
README.md JS: Reuse Model registry from firefox-translation-models for test page (#377) 2022-03-14 18:05:22 +01:00

Using Bergamot Translator in JavaScript

All the instructions below are meant to run from the current directory.

Using JS APIs

Please refer to the file test_page/js/worker.js that demonstrates how to use the bergamot translator in JavaScript via a <script> tag.

Demo

  • Download bergamot model files required for translation

    Use following instructions to download model files (make sure that git-lfs is installed and initialized before running these instructions):

    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/*/*
    
  • Start the test webserver (ensure you have the latest nodejs installed)

    cd test_page
    bash start_server.sh ../../build-wasm
    

    Provide the folder containing the wasm artifacts as the first argument of start_server.sh script (../../build-wasm in this case).

  • Open any of the browsers below

    • Firefox Nightly +87: make sure the following prefs are on (about:config)

      dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled = true
      javascript.options.wasm_simd = true
      javascript.options.wasm_simd_wormhole = true
      
    • Chrome Canary +90: start with the following argument

      --js-flags="--experimental-wasm-simd"
      
  • Browse to the following page:

    http://localhost:80
    
  • Perform translations:

    • Choose the source and target languages using From and To dropdowns.
    • Type a sentence to be translated in the From textbox.
    • See the result in the To textbox.