diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a813a96..cca4a4c5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,9 @@ version: 2.1 jobs: - build_and_test_extension: + ########################################################################### + # Ordinary "build and test" CI flow + build-and-test-extension: docker: - image: circleci/node:latest-browsers @@ -109,8 +111,124 @@ jobs: path: "test/e2e/results" destination: "test/e2e/results" -workflows: + ########################################################################### + # Docs + generate-docs: + docker: + - image: circleci/node:latest-browsers + steps: + - checkout + - restore_cache: + keys: + - dependencies-{{ checksum "docs/package.json" }} + - run: + name: Install npm deps + command: cd docs && yarn install --immutable + - save_cache: + paths: + - node_modules + key: dependencies-{{ checksum "docs/package.json" }} + - run: + name: Upgrade packages + command: sudo apt update + - run: + name: Install Aspell and Rust + command: sudo apt install aspell aspell-en rustc + - run: + name: Version information + command: rustc --version; cargo --version; aspell --version; yarn --version + - run: + name: Install mdbook-dtmo + command: | + MDBOOK_VERSION=0.8.1 + MDBOOK="mdbook-dtmo-${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz" + MDBOOK_SHA256=5b8fc7444816c685ae6a3018e6168844a2fcde73e681a9bfbe4775f361dec64c + curl -sfSL --retry 5 -O "https://github.com/badboy/mdbook-dtmo/releases/download/${MDBOOK_VERSION}/${MDBOOK}" + echo "${MDBOOK_SHA256} *${MDBOOK}" | shasum -a 256 -c - + tar -xvf "${MDBOOK}" + # We rename it to mdbook here, so other tools keep working as expected + mkdir -p ~/.local/bin/ + mv mdbook-dtmo ~/.local/bin/mdbook + mdbook --version + - run: + name: Generate API docs + command: cd docs && yarn generate-api-docs + - run: + name: Build documentation + command: cd docs && yarn build + - run: + name: Check documentation links + command: cd docs && yarn linkcheck + - persist_to_workspace: + root: build/ + paths: + - docs/user + - docs/dev + - docs/shared + - docs/index.html + + docs-spellcheck: + docker: + # This is a separate job so that we can use Ubuntu Focal (20.04) and that + # way get aspell 0.60.8 or later (which contains markdown support) + - image: circleci/buildpack-deps:focal + steps: + - checkout + - run: + name: Upgrade packages + command: sudo apt update + - run: + name: Install aspell + command: sudo apt install aspell aspell-en + - run: + name: Check documentation spelling + command: cd docs && bin/spellcheck.sh list - build-and-test: + # via https://circleci.com/blog/deploying-documentation-to-github-pages-with-continuous-integration/ + docs-deploy: + docker: + - image: node:8.10.0 + steps: + - checkout + - attach_workspace: + at: build/ + - run: + name: Disable jekyll builds + command: touch build/docs/.nojekyll + - run: + name: Show contents + command: ls -R + # Needed for write access to the GitHub repository; + # see https://circleci.com/docs/2.0/gh-bb-integration/#deployment-keys-and-user-keys + - add_ssh_keys: + fingerprints: + - "15:15:41:db:aa:14:12:c6:a5:53:e1:06:e9:e6:a1:57" + # The gh-pages npm package can be used to push a directory to a git branch; + # see https://www.npmjs.com/package/gh-pages + - run: + name: Deploy docs to gh-pages branch + command: | + git config user.email "ci-docs-deploy@firefox-translations" + git config user.name "CircleCI docs-deploy job" + npm install -g --silent gh-pages@2.0.1 + gh-pages --dotfiles --message "[skip ci] Updates" --dist build/docs + + +########################################################################### +# Workflows + +workflows: + version: 2 + ci: jobs: - - build_and_test_extension + - build-and-test-extension + - generate-docs + - docs-spellcheck: + requires: + - generate-docs + - docs-deploy: + requires: + - docs-spellcheck + filters: + branches: + only: main diff --git a/.eslintignore b/.eslintignore index 06e803ef..a46e5a77 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,7 @@ # do not lint/format generated artifacts dist/ build/ +debug/ test/e2e/results/ stats.json yarn-error.log @@ -20,7 +21,7 @@ test/locally-hosted-files/ .venv venv bergamot-translator/ -bergamot-models/ +firefox-translations-models/ emsdk/ node_modules/ test/in-browser/static/test-runner/inc/ @@ -28,3 +29,5 @@ firefox-nightly-linux downloaded-bergamot-translator-wasm-artifacts* # don't lint ci configuration .circleci/ +# formatted/linted separately +docs diff --git a/.gitignore b/.gitignore index fcf1ddab..5d8a98b2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ *.pyc dist/ build/ -test/build/ -test/results/coverage/ +debug/ +test/e2e/results/ stats.json yarn-error.log *.map diff --git a/README.md b/README.md index c1bfd5ad..14973432 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ -# Bergamot Translate Browser Extension +``` +This repo has been archived and the work on Firefox Translations will continue here: +https://github.com/mozilla/firefox-translations +``` +# Firefox Translations Web Extension -[![CircleCI badge](https://img.shields.io/circleci/project/github/mozilla-extensions/bergamot-browser-extension/main.svg?label=CircleCI)](https://circleci.com/gh/mozilla-extensions/bergamot-browser-extension/) +[![CircleCI badge](https://img.shields.io/circleci/project/github/mozilla-extensions/firefox-translations/main.svg?label=CircleCI)](https://circleci.com/gh/mozilla-extensions/firefox-translations/) For more information see [The Bergamot Project website](https://browser.mt/). -## Installation instructions +## Installation and usage instructions -See [docs/INSTALL.md](./docs/INSTALL.md) for instructions on how to get a pre-released version of the extension running locally. +See [this document](https://mozilla-extensions.github.io/firefox-translations/user/index.html) for instructions on how to get a pre-released version of the extension running locally. ## Developer documentation -See [docs/DEV.md](./docs/DEV.md) for details on how to work with this extension as a developer. +See [this document](https://mozilla-extensions.github.io/firefox-translations/dev/index.html) for details on how to work with this extension as a developer. diff --git a/build-config.js b/build-config.js index d83ee025..aba38a12 100644 --- a/build-config.js +++ b/build-config.js @@ -14,7 +14,9 @@ const targetBrowser = process.env.TARGET_BROWSER; const ui = process.env.UI; let extensionBuildEnvironment; -if (process.env.CIRCLECI === "true") { +if (process.env.MC === "1") { + extensionBuildEnvironment = "mozilla"; +} else if (process.env.CIRCLECI === "true") { extensionBuildEnvironment = "circleci"; } else if (process.env.CI === "true") { extensionBuildEnvironment = "ci"; @@ -27,7 +29,11 @@ if (targetEnvironment !== "production") { const extensionId = ui === "firefox-infobar-ui" - ? "firefox-translations@mozilla.org" + ? `${ + process.env.MC === "1" + ? "firefox-translations@mozilla.org" + : "firefox-infobar-ui-bergamot-browser-extension@browser.mt" + }` : "bergamot-browser-extension@browser.mt"; const buildPath = path.join( diff --git a/docs/.dictionary b/docs/.dictionary new file mode 100644 index 00000000..73c238c8 --- /dev/null +++ b/docs/.dictionary @@ -0,0 +1,37 @@ +personal_ws-1.1 en 36 utf-8 +BERGAMOT +Bergamot +CircleCI +Geckodriver +Github +MPL +PRs +README +TypeDoc +UI +WASM +Webpage +XQuartz +aspell +bergamot +cli +codebase +config +deps +eg +env +erDiagram +geckodriver +infobar +js +mdBook +mitmproxy +monolingually +pre +programme +repo +submodule +submodules +typedoc +ui +webpack diff --git a/docs/.eslintignore b/docs/.eslintignore new file mode 100644 index 00000000..30b31950 --- /dev/null +++ b/docs/.eslintignore @@ -0,0 +1,9 @@ +# don't lint/format generated files +dev/api-docs/ +dev/api-docs-summary.md +# don't lint/format package.json since npm install formats it differently by default +package.json +# don't lint/format third party modules +node_modules/ +user/*.js +shared/mermaid.min.js diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 00000000..69333490 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,2 @@ +dev/api-docs/ +dev/api-docs-summary.md diff --git a/docs/DEV.md b/docs/DEV.md deleted file mode 100644 index a7668a4b..00000000 --- a/docs/DEV.md +++ /dev/null @@ -1,269 +0,0 @@ - - - -**Contents** - -- [Developing this extension](#developing-this-extension) - - [First time setup](#first-time-setup) - - [Using known-to-work Bergamot Translator WASM artifacts and importing them to the extension](#using-known-to-work-bergamot-translator-wasm-artifacts-and-importing-them-to-the-extension) - - [Building Bergamot Translator WASM artifacts and importing them to the extension](#building-bergamot-translator-wasm-artifacts-and-importing-them-to-the-extension) - - [Creating extension builds for distribution](#creating-extension-builds-for-distribution) - - [Development mode](#development-mode) - - [Firefox - Infobar UI](#firefox---infobar-ui) - - [Chrome - Cross-browser UI](#chrome---cross-browser-ui) - - [Firefox - Cross-browser UI](#firefox---cross-browser-ui) - - [Creating a signed build of the extension for self-distribution](#creating-a-signed-build-of-the-extension-for-self-distribution) - - [Run end-to-end tests](#run-end-to-end-tests) - - [Locally](#locally) - - [Continuous Integration](#continuous-integration) - - [Troubleshooting functional tests](#troubleshooting-functional-tests) - - [Troubleshooting the extension when it is running](#troubleshooting-the-extension-when-it-is-running) - - [Firefox - Infobar UI](#firefox---infobar-ui-1) - - [Firefox - Cross-browser UI](#firefox---cross-browser-ui-1) - - [Upgrading Glean.js](#upgrading-gleanjs) - - [Analyze webpack bundle size](#analyze-webpack-bundle-size) - - [Firefox - Infobar UI](#firefox---infobar-ui-2) - - [Chrome - Cross-browser UI](#chrome---cross-browser-ui-1) - - [Firefox - Cross-browser UI](#firefox---cross-browser-ui-2) - - [Opening up specific extension pages](#opening-up-specific-extension-pages) - - [Enabling error reporting via Sentry](#enabling-error-reporting-via-sentry) - - - -# Developing this extension - -The commands in these instructions are meant to be run in the root folder in this repo. - -## First time setup - -Install dependencies using [yarn v1](https://classic.yarnpkg.com/en/docs/install/): - -```bash -yarn install -``` - -## Using known-to-work Bergamot Translator WASM artifacts and importing them to the extension - -To use artifacts that are known to work (built by bergamot-translator's CI): - -```bash -yarn bergamot-translator:download-and-import -``` - -Note: Once this command has run, it will create a folder called `downloaded-bergamot-translator-wasm-artifacts` and if this folder exists, it will not re-download the artifacts again. Thus, to make sure that you are using the most up to date WASM artifacts, remove the `downloaded-bergamot-translator-wasm-artifacts` folder, then re-run the command. - -## Building Bergamot Translator WASM artifacts and importing them to the extension - -If you want to try out custom changes to [bergamot-translator](../bergamot-translator/README.md), first make sure that you have checked out the submodules: - -``` -git submodule update --init --recursive -``` - -Then, follow the upstream instructions ([bergamot-translator/README](../bergamot-translator/README.md) for setting up an environment that successfully builds bergamot-translator. - -When all is properly set-up, you should be able to run the following to build and import the custom WASM artifacts into the extension: - -```bash -./bergamot-translator/build-wasm.sh -./import-bergamot-translator.sh ./bergamot-translator/build-wasm/ -``` - -Re-run this command any time there has been an update in the bergamot-translator submodule. - -## Creating extension builds for distribution - -To build for Firefox: - -```bash -yarn build:cross-browser-ui:firefox -``` - -The build artifact will be created under `dist/production/firefox/cross-browser-ui`. - -For Chrome: - -```bash -yarn build:cross-browser-ui:chrome -``` - -The build artifact will be created under `dist/production/chrome/cross-browser-ui`. - -To build the Firefox native UI variant: - -```bash -yarn build:firefox-infobar-ui -``` - -The build artifact will be created under `dist/production/firefox/firefox-infobar-ui`. - -## Development mode - -First, import bergamot models locally, since the extension downloads the models from a local endpoint when running in development mode: - -```bash -yarn bergamot-models:import -``` - -If you haven't already, download and install Firefox Nightly from [here](https://www.mozilla.org/en-US/firefox/channel/desktop/) before running the below commands. - -Finally, use the commands below to build the extension, launch the browser, install the extension and start Webpack in watch mode, which repeats the build process and reloads the extension when source files are changed. - -### Firefox - Infobar UI - -```bash -yarn watch:firefox-infobar-ui -``` - -### Chrome - Cross-browser UI - -```bash -yarn watch:cross-browser-ui:chrome -``` - -### Firefox - Cross-browser UI - -```bash -yarn watch:cross-browser-ui:firefox -``` - -## Creating a signed build of the extension for self-distribution - -After version bumping and setting the API_KEY and API_SECRET env vars: - -```bash -yarn build:cross-browser-ui:firefox && npx web-ext sign --api-key $API_KEY --api-secret $API_SECRET -``` - -Note: This is for Firefox version with the cross-browser UI only. Chrome Web Store does not offer signed builds for self-distribution and the Firefox infobar UI version gets signed via a separate process. - -## Run end-to-end tests - -### Locally - -Before running the tests locally for the first time, install [mitmproxy](https://mitmproxy.org). Example installation command for Mac: - -```bash -brew install mitmproxy -``` - -To run the end-to-end tests, run: - -```bash -yarn e2e-tests -``` - -Note, to modify the `test/e2e/intercept-telemetry-requests.py` script, it may be useful to have the Python deps installed: - -```bash -test/e2e/setup-python-venv.sh -``` - -### Continuous Integration - -End-to-end tests are run against each new commits/PRs. Read more about the current CI setup [here](./CI.md). - -### Troubleshooting functional tests - -**Basic principles** - -End-to-end tests are run using the built extension artifacts found in `dist/production/`. To test new non-test-related code changes, remember to re-run the relevant build command. - -**Intervening** - -If you want to intervene in a test (eg. to double-check something), follow this pattern: - -1. Add a long delay, eg `await driver.sleep(60 * 60 * 1000);` to the test at the place you want to intervene. -2. Make sure to temporarily also increase the timeout for the test you are running. -3. Run the tests and intervene manually as desired. - -**Obtaining Geckodriver logs** - -To troubleshoot issues with failing tests when only cryptic error messages are available, check the geckodriver logs, located in `test/e2e/results/logs/`. - -## Troubleshooting the extension when it is running - -Hint: To produce a clean log output for forwarding to developers / attaching to issues, first click the Trash can icon in the top left before repeating the steps that leads to the erroneous behavior. - -### Firefox - Infobar UI - -1. Go to `about:devtools-toolbox?type=extension&id=firefox-translations%40mozilla.org` -2. Click Console - -### Firefox - Cross-browser UI - -1. Go to `about:devtools-toolbox?type=extension&id=bergamot-browser-extension%40browser.mt` -2. Click Console - -## Upgrading Glean.js - -1. Bump the `@mozilla/glean` version in `package.json` -2. `yarn` -3. `yarn generate-glean` -4. Commit all changes. Use a commit message in the format of `Upgrade Glean.js to vx.y.z` - -## Analyze webpack bundle size - -### Firefox - Infobar UI - -```bash -yarn build:firefox-infobar-ui -npx webpack-bundle-analyzer build/production/firefox/firefox-infobar-ui.stats.json build/production/firefox/firefox-infobar-ui -``` - -### Chrome - Cross-browser UI - -```bash -yarn build:cross-browser-ui:chrome -npx webpack-bundle-analyzer build/production/chrome/cross-browser-ui.stats.json build/production/chrome/cross-browser-ui -``` - -### Firefox - Cross-browser UI - -```bash -yarn build:cross-browser-ui:firefox -npx webpack-bundle-analyzer build/production/firefox/cross-browser-ui.stats.json build/production/firefox/cross-browser-ui -``` - -## Opening up specific extension pages - -(Only relevant when developing the Cross-browser UI) - -From the background context: - -```javascript -(typeof browser !== "undefined" ? browser : chrome).runtime.getURL( - `main-interface/popup.html`, -); -``` - -```javascript -(typeof browser !== "undefined" ? browser : chrome).runtime.getURL( - `main-interface/popup.html#/components`, -); -``` - -```javascript -(typeof browser !== "undefined" ? browser : chrome).runtime.getURL( - `get-started/get-started.html`, -); -``` - -```javascript -(typeof browser !== "undefined" ? browser : chrome).runtime.getURL( - `options-ui/options-ui.html`, -); -``` - -## Enabling error reporting via Sentry - -Configure `.env.development` and `.env.production` with values as per https://docs.sentry.io/cli/configuration/. - -Hint: You can verify that the Sentry configuration is working using: - -```bash -cp .env.development .env -npx sentry-cli info -cp .env.production .env -npx sentry-cli info -``` diff --git a/docs/INSTALL.md b/docs/INSTALL.md deleted file mode 100644 index d46e302f..00000000 --- a/docs/INSTALL.md +++ /dev/null @@ -1,87 +0,0 @@ - - - -**Contents** - -- [Installation instructions](#installation-instructions) - - [Firefox - Infobar UI](#firefox---infobar-ui) - - [Preparations](#preparations) - - [Configuring Nightly to enable the extension](#configuring-nightly-to-enable-the-extension) - - [Demo](#demo) - - - -# Installation instructions - -This document outlines how to get the v0.4.2 pre-release version of the extension running locally. - -Before installing, please take a minute to read [the release notes](https://github.com/mozilla-extensions/bergamot-browser-extension/releases/tag/v0.4.2). - - - -## Firefox - Infobar UI - -### Preparations - -- The current release requires bleeding edge browser capabilities. If you haven't already, download and install Firefox Nightly (English or German edition) from [https://www.mozilla.org/en-US/firefox/all/#product-desktop-nightly](https://www.mozilla.org/en-US/firefox/all/#product-desktop-nightly). -- If you have tried any previous version of the Firefox extension, please make sure to remove/uninstall it before installing the new version. You will find it named "Firefox Translations" or "Bergamot Translate" in `about:addons`. - -### Configuring Nightly to enable the extension - -- Change the following preferences `false` in `about:config`: - - `extensions.translations.disabled` -- The extension is now enabled - -### Demo - -- To try it out, visit a page in a language combination that is supported for translation, eg one of: - - With Firefox Nightly English edition, visit a page in either Spanish or Estonian, eg https://www.mozilla.org/es-ES/ or https://www.mozilla.org/et/ - - With Firefox Nightly German edition, visit a page in English, eg https://www.mozilla.org/en-US/ -- Press Translate in the translation infobar that pops up - - Note: For non-english editions of Nightly, one must eliminate EN and EN-US from the accepted languages (from the Language section of about:preferences, more precisely from the Webpage Language Settings) for the infobar to show - - diff --git a/docs/bin/build-docs.sh b/docs/bin/build-docs.sh new file mode 100755 index 00000000..7ee66312 --- /dev/null +++ b/docs/bin/build-docs.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Build all docs with one command +# Documentation will be placed in `build/docs`. + +set -xe + +DEST_PATH=../build/docs + +# To cleanly apply some preprocessing, we copy all src files to an +# intermediate path before running mdbook +INTERMEDIATE_SRC_PATH=../build/tmp-docs + +# Clean +rm -rf $INTERMEDIATE_SRC_PATH +mkdir -p $INTERMEDIATE_SRC_PATH +rm -rf $DEST_PATH +mkdir -p $DEST_PATH + +# Copy src files to the intermediate source dir +cp -r dev shared user $INTERMEDIATE_SRC_PATH/ + +# Add npm assets necessary at build time +cp ../node_modules/mermaid/dist/mermaid.min.js $INTERMEDIATE_SRC_PATH/shared/ + +# TODO: Add telemetry docs +# TODO: Add data-review docs? + +# Build the docs +cat dev/SUMMARY.tpl.md dev/api-docs-summary.md > $INTERMEDIATE_SRC_PATH/dev/SUMMARY.md +cd $INTERMEDIATE_SRC_PATH +output=$(mdbook build user/ 2>&1) +if echo "$output" | grep -q "\[ERROR\]" ; then + exit 1 +fi +output=$(mdbook build dev/ 2>&1) +if echo "$output" | grep -q "\[ERROR\]" ; then + exit 1 +fi +cd - + +# Clean up intermediate src files +rm -rf $INTERMEDIATE_SRC_PATH + +# Add redirect from the root page to the user docs +echo '' > $DEST_PATH/index.html diff --git a/docs/bin/generate-api-docs.sh b/docs/bin/generate-api-docs.sh new file mode 100755 index 00000000..c576a934 --- /dev/null +++ b/docs/bin/generate-api-docs.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Build API docs +# Documentation will be placed in `dev/api-docs` for inclusion in the +# developer documentation. + +set -e + +REPO_PACKAGE_VERSION=$(node -p "require('../package.json').version") + +typedoc --options typedoc.json --gitRevision "v$REPO_PACKAGE_VERSION" + +cd dev + +# Remove the first line (includes breadcrumbs) from the individual pages +# since it is superfluous when results are rendered in mdBook and the +# links in the breadcrumbs cause some linkchecking warnings +for FILE in api-docs/**/*.md; do + tail -n +2 "$FILE" > "$FILE.tmp" && mv "$FILE.tmp" "$FILE" +done + +# Create links to all the individual pages in a file that eventually +# ends up in SUMMARY.md (an mdBook requirement is that all files +# are linked in SUMMARY.md) +rm api-docs-summary.md || true +touch api-docs-summary.md +for f in api-docs/**/*.md; do + b=$(basename $f) + echo " - [$b](./$f)" >> api-docs-summary.md +done diff --git a/docs/bin/spellcheck.sh b/docs/bin/spellcheck.sh new file mode 100755 index 00000000..caf02b46 --- /dev/null +++ b/docs/bin/spellcheck.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# Copied, and modified, from the Rust Cookbook. +# https://github.com/rust-lang-nursery/rust-cookbook/blob/HEAD/ci/spellcheck.sh + +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +aspell --version + +# Checks project markdown files for spell errors + +# Notes: + +# This script needs dictionary file ($dict_filename) with project-specific +# valid words. If this file is missing, first invocation of a script generates +# a file of words considered typos at the moment. User should remove real typos +# from this file and leave only valid words. When script generates false +# positive after source modification, new valid word should be added +# to dictionary file. + +# Default mode of this script is interactive. Each source file is scanned for +# typos. aspell opens window, suggesting fixes for each found typo. Original +# files with errors will be backed up to files with format "filename.md.bak". + +# When running in CI, this script should be run in "list" mode (pass "list" +# as first argument). In this mode script scans all files and reports found +# errors. Exit code in this case depends on scan result: +# 1 if any errors found, +# 0 if all is clear. + +# Script skips words with length less than or equal to 3. This helps to avoid +# some false positives. + +# We can consider skipping source code in markdown files (```code```) to reduce +# rate of false positives, but then we lose ability to detect typos in code +# comments/strings etc. + +shopt -s nullglob + +dict_filename=./.dictionary +markdown_sources="$(git ls-files | grep '\.md$')" +mode="check" +aspell_args="--lang en_US --mode=markdown" + +# aspell repeatedly modifies personal dictionary for some purpose, +# so we should use a copy of our dictionary +mkdir -p "/tmp/ci" +dict_path="/tmp/$dict_filename" + +if [[ "$1" == "list" ]]; then + mode="list" +fi + +if [[ ! -f "$dict_filename" ]]; then + # Pre-check mode: generates dictionary of words aspell consider typos. + # After user validates that this file contains only valid words, we can + # look for typos using this dictionary and some default aspell dictionary. + echo "Scanning files to generate dictionary file '$dict_filename'." + echo "Please check that it doesn't contain any misspellings." + + echo "personal_ws-1.1 en 0 utf-8" > "$dict_filename" + cat ${markdown_sources} | aspell ${aspell_args} list | sort -u >> "$dict_filename" +elif [[ "$mode" == "list" ]]; then + # List (default) mode: scan all files, report errors + declare -i retval=0 + + cp "$dict_filename" "$dict_path" + + if [ ! -f $dict_path ]; then + retval=1 + exit "$retval" + fi + + for fname in $markdown_sources; do + command=$(aspell ${aspell_args} --personal="$dict_path" "$mode" < "$fname") + if [[ -n "$command" ]]; then + for error in $command; do + # FIXME: Find more correct way to get line number + # (ideally from aspell). Now it can make some false positives, + # because it is just a grep + grep --with-filename --line-number -o --color=always "$error" "$fname" + done + retval=1 + fi + done + exit "$retval" +elif [[ "$mode" == "check" ]]; then + for fname in $markdown_sources; do + aspell --mode=markdown ${aspell_args} --dont-backup --personal="$dict_filename" "$mode" "$fname" + done +fi diff --git a/docs/dev/README.md b/docs/dev/README.md new file mode 100644 index 00000000..be62e6bc --- /dev/null +++ b/docs/dev/README.md @@ -0,0 +1,47 @@ +# Introduction + +The **Firefox Translations Web Extension** ties together the various components that together form the **Firefox Translations** feature. + +The source code is available at [https://github.com/mozilla-extensions/firefox-translations/](). + +## About this guide + +This guide is meant for developers of the **Firefox Translations Web Extension**. + +For developer documentation related to any other part than the Web Extension (and what those parts may be), check the section called `Related repositories` below. + +For user documentation on the **Firefox Translations** feature, refer to [Firefox Translations User Guide](../user/index.html). + +## The main sections of this guide + +- **[Engineering](./engineering/overview.md)** - Details how to get your hands dirty and contribute to the codebase +- **[Maintenance](./maintenance/overview.md)** - Shorter tutorials on how to achieve specific maintenance tasks + +## Reporting bugs/issues + +To report engineering-related issues or request changes specific to the **Firefox Translations Web Extension**, [file a bug on GitHub](https://github.com/mozilla-extensions/firefox-translations/issues/). + +## Related repositories + +The other repositories that together build up the **Firefox Translations** feature are: + +- **Bergamot Translator** - The translation engine ([Source code](https://github.com/mozilla/bergamot-translator)) +- **Language Models** - The files that the translation engine uses to translate between languages ([Source code](https://github.com/mozilla/firefox-translations-models)) +- **Training pipeline** - The scripts to train language models ([Source code](https://github.com/mozilla/firefox-translations-training)) +- **Firefox** - Contains UI elements and optimizations specific to the translations feature ([Firefox source code documentation](https://firefox-source-docs.mozilla.org/)) + +### The relationship between the repositories + +
erDiagram
+    BROWSER ||--|| THIS-WEB-EXTENSION : bundles-or-installs
+    THIS-WEB-EXTENSION ||..|{ LANGUAGE-MODELS : downloads
+    THIS-WEB-EXTENSION ||..|| BERGAMOT-TRANSLATOR : downloads
+    THIS-WEB-EXTENSION ||--|| BERGAMOT-TRANSLATOR : consumes
+    BERGAMOT-TRANSLATOR ||--|{ LANGUAGE-MODELS : loads
+    TRAINING-PIPELINE ||--|{ LANGUAGE-MODELS : produces
+
+ +## License + +Firefox Translations Source Code is subject to the terms of the Mozilla Public License v2.0. +You can obtain a copy of the MPL at . diff --git a/docs/dev/SUMMARY.tpl.md b/docs/dev/SUMMARY.tpl.md new file mode 100644 index 00000000..e2a39c24 --- /dev/null +++ b/docs/dev/SUMMARY.tpl.md @@ -0,0 +1,22 @@ +[Introduction](README.md) + +# Developer's Guide + +- [Engineering](./engineering/overview.md) + + - [Getting started](./engineering/getting-started.md) + - [Local development](./engineering/local-development.md) + - [Building and installing the extension](./engineering/building-and-installing-the-extension.md) + - [Debugging](./engineering/debugging.md) + - [Improving the documentation](./engineering/improving-the-documentation.md) + - [Automated tests](./engineering/automated-web-extension-testing.md) + - [Continuous integration](./engineering/ci.md) + - [Contributing](./engineering/contributing.md) + +- [Maintenance](./maintenance/overview.md) + + - [Upgrading Glean.js](./maintenance/upgrading-glean-js.md) + +# Appendix + +- [Generated API Docs](./api-docs/README.md) diff --git a/docs/dev/architecture/overview.md b/docs/dev/architecture/overview.md new file mode 100644 index 00000000..e484b6e7 --- /dev/null +++ b/docs/dev/architecture/overview.md @@ -0,0 +1,3 @@ +# Architecture + +This section contains a description of the main components and how they interact with each other. diff --git a/docs/dev/book.toml b/docs/dev/book.toml new file mode 100644 index 00000000..2cf9bc43 --- /dev/null +++ b/docs/dev/book.toml @@ -0,0 +1,25 @@ +[book] +title = "Firefox Translations Web Extension - Developer's Guide" +authors = ["Bergamot Team @ Mozilla"] +src = "." + +[build] +build-dir = "../../docs/dev" +create-missing = true + +[output.html] +additional-css = ["../shared/custom.css"] +additional-js = ["../shared/tabs.js", "../shared/mermaid.min.js", "../shared/mermaid-init.js"] +git-repository-url = "https://github.com/mozilla-extensions/firefox-translations" +git-branch = "main" +mathjax-support = true + +[output.html.fold] +enable = true +level = 0 + +[preprocessor.open-on-gh] +command = "mdbook-open-on-gh" + +[preprocessor.mermaid] +command = "mdbook-mermaid" diff --git a/docs/dev/engineering/automated-web-extension-testing.md b/docs/dev/engineering/automated-web-extension-testing.md new file mode 100644 index 00000000..4befca46 --- /dev/null +++ b/docs/dev/engineering/automated-web-extension-testing.md @@ -0,0 +1,57 @@ +# Automated web extension testing + +## In-browser tests + +These tests run inside an extension page to be able to have access to the same privileges that web extension background script has. + +## End-to-end (e2e) tests + +These are based on Selenium because of only that allows access to the privileged parts of the UI. + +## Run end-to-end tests + +### Locally + +Before running the tests locally for the first time, install [mitmproxy](https://mitmproxy.org). Example installation command for Mac: + +```bash +brew install mitmproxy +``` + +To run the end-to-end tests, run: + +```bash +yarn e2e-tests +``` + +Note, to modify the `test/e2e/intercept-telemetry-requests.py` script, it may be useful to have the Python deps installed: + +```bash +test/e2e/setup-python-venv.sh +``` + +### Troubleshooting functional tests + +**Basic principles** + +End-to-end tests are run using the built extension artifacts found in `dist/production/`. To test new non-test-related code changes, remember to re-run the relevant build command. + +**Intervening** + +If you want to intervene in a test (eg. to double-check something), follow this pattern: + +1. Add a long delay, eg `await driver.sleep(60 * 60 * 1000);` to the test at the place you want to intervene. +2. Make sure to temporarily also increase the timeout for the test you are running. +3. Run the tests and intervene manually as desired. + +**Obtaining Geckodriver logs** + +To troubleshoot issues with failing tests when only cryptic error messages are available, check the geckodriver logs, located in `test/e2e/results/logs/`. + +## Relevant engineering background + +Maintenance and development of this component requires experience in: + +- Web extension regression tests +- Selenium +- CircleCI diff --git a/docs/dev/engineering/building-and-installing-the-extension.md b/docs/dev/engineering/building-and-installing-the-extension.md new file mode 100644 index 00000000..3ec52d06 --- /dev/null +++ b/docs/dev/engineering/building-and-installing-the-extension.md @@ -0,0 +1,28 @@ +# Building and installing the extension + +## Creating extension builds + +```bash +yarn build:firefox-infobar-ui +``` + +The build artifact will be created under `dist/production/firefox/firefox-infobar-ui`. + +### Installing locally built versions of the extension + +Artifacts built locally or via CircleCI are unsigned, and additional config preferences are necessary to get them to work as expected. + +- Make sure that the following preferences are set to `true` in `about:config`: + - `extensions.experiments.enabled` + - `javascript.options.wasm_simd` + - `javascript.options.wasm_simd_wormhole` + - `dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled` +- Make sure that the following preferences are set to `false` in `about:config`: + - `xpinstall.signatures.required` + +## Analyze webpack bundle size + +```bash +yarn build:firefox-infobar-ui +npx webpack-bundle-analyzer build/production/firefox/firefox-infobar-ui.stats.json build/production/firefox/firefox-infobar-ui +``` diff --git a/docs/CI.md b/docs/dev/engineering/ci.md similarity index 56% rename from docs/CI.md rename to docs/dev/engineering/ci.md index 4c430d47..e695a225 100644 --- a/docs/CI.md +++ b/docs/dev/engineering/ci.md @@ -1,15 +1,3 @@ - - - -**Contents** - -- [Continuous Integration](#continuous-integration) - - [CircleCI](#circleci) - - [Run Circle CI locally (requires Docker)](#run-circle-ci-locally-requires-docker) - - [Installing artifacts created by CircleCI](#installing-artifacts-created-by-circleci) - - - # Continuous Integration [Circle CI](https://circleci.com/) is used for continuous integration. @@ -54,15 +42,3 @@ To forward the GUI to you local Mac workstation, start XQuartz and replace the d xhost + 127.0.0.1 docker run -v "$PWD:/home/circleci/checkout" -e DISPLAY=host.docker.internal:0 -it circleci/node:latest-browsers /bin/bash ``` - -### Installing artifacts created by CircleCI - -Artifacts built via CircleCI are unsigned (just like developer-created local builds), and additional config preferences are necessary to get them to work as expected. First enable the preferences outlined in the [general installation instructions](./INSTALL.md), then: - -- Make sure that the following preferences are set to `true` in `about:config`: - - `extensions.experiments.enabled` - - `javascript.options.wasm_simd` - - `javascript.options.wasm_simd_wormhole` - - `dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled` -- Make sure that the following preferences are set to `false` in `about:config`: - - `xpinstall.signatures.required` diff --git a/docs/dev/engineering/contributing.md b/docs/dev/engineering/contributing.md new file mode 100644 index 00000000..0ead0537 --- /dev/null +++ b/docs/dev/engineering/contributing.md @@ -0,0 +1,5 @@ +# Contributing + +We follow the ordinary Github workflow. Clone the repo, create a PR and get approval from a team member to get it merged. + +End-to-end tests are run against each new commits/PRs. Read more about the current CI setup [here](./ci.md). diff --git a/docs/dev/engineering/cross-browser-development.md b/docs/dev/engineering/cross-browser-development.md new file mode 100644 index 00000000..3f15efe1 --- /dev/null +++ b/docs/dev/engineering/cross-browser-development.md @@ -0,0 +1,107 @@ +## Start development mode + +### Chrome - Cross-browser UI + +```bash +yarn watch:cross-browser-ui:chrome +``` + +### Firefox - Cross-browser UI + +```bash +yarn watch:cross-browser-ui:firefox +``` + +## Creating extension builds + +To build for Firefox: + +```bash +yarn build:cross-browser-ui:firefox +``` + +The build artifact will be created under `dist/production/firefox/cross-browser-ui`. + +For Chrome: + +```bash +yarn build:cross-browser-ui:chrome +``` + +The build artifact will be created under `dist/production/chrome/cross-browser-ui`. + +## Creating a signed build of the extension for self-distribution + +After version bumping and setting the API_KEY and API_SECRET env vars: + +```bash +yarn build:cross-browser-ui:firefox && npx web-ext sign --api-key $API_KEY --api-secret $API_SECRET +``` + +Note: This is for Firefox version with the cross-browser UI only. Chrome Web Store does not offer signed builds for self-distribution and the Firefox infobar UI version gets signed via a separate process. + +## Troubleshooting the extension when it is running + +1. Go to `about:devtools-toolbox?type=extension&id=bergamot-browser-extension%40browser.mt` +2. Click Console + +## Analyze webpack bundle size + +### Chrome - Cross-browser UI + +```bash +yarn build:cross-browser-ui:chrome +npx webpack-bundle-analyzer build/production/chrome/cross-browser-ui.stats.json build/production/chrome/cross-browser-ui +``` + +### Firefox - Cross-browser UI + +```bash +yarn build:cross-browser-ui:firefox +npx webpack-bundle-analyzer build/production/firefox/cross-browser-ui.stats.json build/production/firefox/cross-browser-ui +``` + +## Opening up specific extension pages + +From the background context: + +```javascript +(typeof browser !== "undefined" ? browser : chrome).runtime.getURL( + `main-interface/popup.html`, +); +``` + +```javascript +(typeof browser !== "undefined" ? browser : chrome).runtime.getURL( + `main-interface/popup.html#/components`, +); +``` + +```javascript +(typeof browser !== "undefined" ? browser : chrome).runtime.getURL( + `get-started/get-started.html`, +); +``` + +```javascript +(typeof browser !== "undefined" ? browser : chrome).runtime.getURL( + `options-ui/options-ui.html`, +); +``` + + diff --git a/docs/dev/engineering/debugging.md b/docs/dev/engineering/debugging.md new file mode 100644 index 00000000..6791a5a7 --- /dev/null +++ b/docs/dev/engineering/debugging.md @@ -0,0 +1,13 @@ +## Troubleshooting the extension when it is running + +Hint: To produce a clean log output for forwarding to developers / attaching to issues, first click the Trash can icon in the top left before repeating the steps that leads to the erroneous behavior. + +### Bundled version + +1. Go to `about:devtools-toolbox?type=extension&id=firefox-translations%40mozilla.org` +2. Click Console + +### Self-built version + +1. Go to `about:devtools-toolbox?type=extension&id=TODO` +2. Click Console diff --git a/docs/dev/engineering/getting-started.md b/docs/dev/engineering/getting-started.md new file mode 100644 index 00000000..3289348c --- /dev/null +++ b/docs/dev/engineering/getting-started.md @@ -0,0 +1,13 @@ +# Getting started + +## First time setup + +If you haven't already, download and install Firefox Nightly from [here](https://www.mozilla.org/en-US/firefox/channel/desktop/) before running the below commands. + +Install dependencies using [yarn v1](https://classic.yarnpkg.com/en/docs/install/): + +```bash +yarn install +``` + +Now either continue with [Local development](./local-development.md) or [Building and installing the extension](./building-and-installing-the-extension.md) diff --git a/docs/dev/engineering/improving-the-documentation.md b/docs/dev/engineering/improving-the-documentation.md new file mode 100644 index 00000000..8dd43de8 --- /dev/null +++ b/docs/dev/engineering/improving-the-documentation.md @@ -0,0 +1,85 @@ +# Improving the documentation + +The documentation in this repository pertains to the client-side code for the Firefox Translations feature. + +The human-written documentation is written in Markdown and converted to static HTML using [mdBook](https://rust-lang.github.io/mdBook/). + +API docs are generated using [TypeDoc](https://typedoc.org/) using the [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown). + +## Building documentation + +### Generating the API documentation + +```sh +yarn workspace docs generate-api-docs +``` + +### Building the human-written documentation + +Rust and [mdBook](https://rust-lang.github.io/mdBook/) is required in order to build the documentation. Installation instructions for Mac: + +```sh +xcode-select --install +brew install rust +cargo install mdbook mdbook-mermaid mdbook-open-on-gh +``` + +Add `~/.cargo/bin` to your PATH, eg: + +```sh +echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bash_profile +``` + +Open up a new terminal. + +Now the docs can be built with: + +```sh +yarn workspace docs build +``` + +The built documentation is saved in `build/docs/`. + +## Developer/watch mode + +```sh +yarn workspace docs watch +``` + +This makes the user documentation available locally on http://0.0.0.0:3000/user/index.html and http://0.0.0.0:3000/dev/index.html. Changes made in the `docs/` directory will result in a rebuild and client reload. + +### Checking links + +Internal links within the documentation can be checked using the [`link-checker`](https://www.npmjs.com/package/link-checker) tool. +External links are currently not checked, since this takes considerable time and frequently fails in CI due to networking restrictions or issues. + +Link checking runs automatically in CI, and requires building the human-written documentation as well the generated API documentation first. To run link checking locally, run: + +```sh +yarn workspace docs linkcheck +``` + +### Spell checking + +The human-written documentation (but not the generated API documentation) is spell checked using [aspell](http://aspell.net/). + +On Unix-like platforms, it can be installed using your system's package manager: + +```sh +sudo apt install aspell-en +# ...or... +sudo dnf install aspell-en +# ...or... +brew install aspell +``` + +Note that aspell 0.60.8 or later is required, as that is the first release with markdown support. + +Spell checking runs automatically in CI. You can the spell check the documentation using the following: + +```sh +yarn workspace docs spellcheck +``` + +This will bring up an interactive spell-checking environment in the console. +Pressing `a` to add a word will add it to the project's local `.dictionary` file, and the changes should be committed to `git`. diff --git a/docs/dev/engineering/local-development.md b/docs/dev/engineering/local-development.md new file mode 100644 index 00000000..227e591d --- /dev/null +++ b/docs/dev/engineering/local-development.md @@ -0,0 +1,56 @@ +# Local development + +The commands in these instructions are meant to be run in the root folder in this repo. + +## First time setup + +1. Follow the [Getting started](./getting-started.md) instructions + +2. Install [Git Large File Storage](https://docs.github.com/en/repositories/working-with-files/managing-large-files/installing-git-large-file-storage) + +3. Import bergamot models locally, since the extension downloads the models from a local endpoint when running in development mode: + +```bash +yarn models:import +``` + +4. Import Bergamot translator using one of the two methods below. + +### Using known-to-work Bergamot Translator WASM artifacts and importing them to the extension + +To use artifacts that are known to work (built by bergamot-translator's CI): + +```bash +yarn bergamot-translator:download-and-import +``` + +Note: Once this command has run, it will create a folder called `downloaded-bergamot-translator-wasm-artifacts` and if this folder exists, it will not re-download the artifacts again. Thus, to make sure that you are using the most up to date WASM artifacts, remove the `downloaded-bergamot-translator-wasm-artifacts` folder, then re-run the command. + +### Building Bergamot Translator WASM artifacts and importing them to the extension + +If you want to try out custom changes to [bergamot-translator](https://github.com/mozilla/bergamot-translator/README.md), first make sure that you have checked out the submodules: + +``` +git submodule update --init --recursive +``` + +Then, follow the upstream instructions ([bergamot-translator/README](https://github.com/mozilla/bergamot-translator/README.md) for setting up an environment that successfully builds bergamot-translator. + +When all is properly set-up, you should be able to run the following to build and import the custom WASM artifacts into the extension: + +```bash +./bergamot-translator/build-wasm.sh +./import-bergamot-translator.sh ./bergamot-translator/build-wasm/ +``` + +Re-run this command any time there has been an update in the bergamot-translator submodule. + +## Start development/watch mode + +When the above commands have finished, run: + +```bash +yarn watch:firefox-infobar-ui +``` + +This will build the extension, launch the browser, install the extension and start Webpack in watch mode, which repeats the build process and reloads the extension when source files are changed: diff --git a/docs/dev/engineering/overview.md b/docs/dev/engineering/overview.md new file mode 100644 index 00000000..f51b312f --- /dev/null +++ b/docs/dev/engineering/overview.md @@ -0,0 +1,5 @@ +# Engineering + +This section details how to get your hands dirty and contribute to the codebase. + +Use the navigation to the left to continue. diff --git a/docs/dev/maintenance/overview.md b/docs/dev/maintenance/overview.md new file mode 100644 index 00000000..a7f84b00 --- /dev/null +++ b/docs/dev/maintenance/overview.md @@ -0,0 +1,5 @@ +# Maintenance + +This section contains shorter tutorials on how to achieve specific maintenance tasks. + +Use the navigation to the left to continue. diff --git a/docs/dev/maintenance/upgrading-glean-js.md b/docs/dev/maintenance/upgrading-glean-js.md new file mode 100644 index 00000000..558b20af --- /dev/null +++ b/docs/dev/maintenance/upgrading-glean-js.md @@ -0,0 +1,6 @@ +## Upgrading Glean.js + +1. Bump the `@mozilla/glean` version in `package.json` +2. `yarn` +3. `yarn generate-glean` +4. Commit all changes. Use a commit message in the format of `Upgrade Glean.js to vx.y.z` diff --git a/docs/package.json b/docs/package.json new file mode 100644 index 00000000..84704c03 --- /dev/null +++ b/docs/package.json @@ -0,0 +1,27 @@ +{ + "name": "docs", + "description": "docs", + "version": "0.0.0", + "dependencies": { + "core": "0.0.0", + "cross-browser-ui": "0.0.0", + "firefox-infobar-ui": "0.0.0", + "mermaid": "^8.10.2" + }, + "devDependencies": { + "light-server": "^2.9.1", + "link-checker": "^1.4.2", + "typedoc": "^0.20.36", + "typedoc-plugin-markdown": "^3.9.0" + }, + "private": true, + "scripts": { + "build": "bin/build-docs.sh", + "generate-api-docs": "bin/generate-api-docs.sh", + "format": "prettier '**/*.{md,css,js,json,html}' --ignore-path=.eslintignore --write", + "linkcheck": "link-checker ../build/docs --disable-external true --allow-hash-href true", + "spellcheck": "bin/spellcheck.sh check", + "serve": "light-server -s ../build/docs -p 3000", + "watch": "yarn build && yarn serve -w \"** # yarn build\"" + } +} diff --git a/docs/shared/blockquote-info.html b/docs/shared/blockquote-info.html new file mode 100644 index 00000000..8eb68c47 --- /dev/null +++ b/docs/shared/blockquote-info.html @@ -0,0 +1 @@ +
diff --git a/docs/shared/blockquote-stop.html b/docs/shared/blockquote-stop.html new file mode 100644 index 00000000..dfa47986 --- /dev/null +++ b/docs/shared/blockquote-stop.html @@ -0,0 +1 @@ +
diff --git a/docs/shared/blockquote-warning.html b/docs/shared/blockquote-warning.html new file mode 100644 index 00000000..0726c5bc --- /dev/null +++ b/docs/shared/blockquote-warning.html @@ -0,0 +1,3 @@ +
diff --git a/docs/shared/custom.css b/docs/shared/custom.css new file mode 100644 index 00000000..99d44e6f --- /dev/null +++ b/docs/shared/custom.css @@ -0,0 +1,334 @@ +/* API Reference Titles */ + +a.header code { + background-color: rgba(230, 230, 230, 0.8); + display: inline-block; + padding: 0 5px; + border-radius: 3px; + color: black; + font-weight: bold; + transition: all 150ms ease-in-out; +} + +a.header code:hover { + background-color: rgba(230, 230, 230, 1); +} + +/* Style the tab */ +.tabs { + display: flex; + flex-direction: column; + margin-bottom: 40px; +} + +.tabbar { + border: 1px solid #ccc; + background-color: #f1f1f1; + width: 100%; + box-sizing: border-box; +} + +/* Style the buttons that are used to open the tab content */ +.tabbar button { + background-color: inherit; + float: left; + border: none; + outline: none; + cursor: pointer; + padding: 14px 16px; + transition: 0.3s; +} + +/* Change background color of buttons on hover */ +.tabbar button:hover { + background-color: #ddd; +} + +.tabbar button.disabled:hover { + background-color: inherit; +} + +/* Create an active/current tablink class */ +.tabbar button.active { + background-color: #ccc; +} + +.tabbar button.disabled { + color: #ccc; + cursor: default; +} + +/* The container that holds all of the tab contents */ +.tabcontents { + display: flex; +} + +/* The container for each individual language */ +.tab { + display: none; + width: 100%; + border: 1px solid #ccc; + border-top: none; + padding: 6px 12px; + box-sizing: border-box; +} + +.tab.active { + display: block; +} + +/* The footer with the "Open on GitHub" link */ +footer#open-on-gh { + font-size: 0.8em; + text-align: center; + border-top: 1px solid black; + padding: 5px 0; +} + +/* Distribution simulator styles */ + +#simulator-container { + display: flex; + flex-wrap: wrap; + overflow: hidden; +} + +#simulator-container h3 { + margin-top: 20px; +} + +#simulator-container .input-group { + width: 100%; +} + +#simulator-container .input-group label { + display: block; + font-weight: bold; + font-size: 14px; + margin-bottom: 7px; +} + +#simulator-container .input-group input, +#simulator-container .input-group select, +#custom-data-modal textarea { + display: block; + width: 100%; + padding: 5px; + margin-bottom: 10px; + border-radius: 3px; + border: 1px solid #e0e0e0; + box-sizing: border-box; +} + +#histogram-props, +#data-options { + width: 50%; + box-sizing: border-box; +} + +#data-options { + padding-right: 50px; +} + +#data-options .input-group { + margin-bottom: 10px; +} + +#data-options .input-group:first-of-type { + margin-top: 20px; +} + +#data-options .input-group:last-of-type { + margin-bottom: 0; +} + +#data-options .input-group label { + display: inline-block; +} + +#data-options .input-group input { + display: inline; + width: auto; +} + +#histogram-chart-container { + width: 100%; + padding: 30px; + border: 1px solid #e0e0e0; + margin: 30px 0; + overflow: hidden; + position: relative; +} + +#histogram-chart { + margin-top: 50px; + width: 100%; +} + +#histogram-chart-legend { + font-size: 14px; + text-align: center; + width: 100%; +} + +#histogram-functional-props, +#histogram-non-functional-props { + display: none; +} + +#custom-data-modal-overlay { + background-color: rgba(0, 0, 0, 0.5); + position: fixed; + width: 100vw; + height: 100vh; + top: 0; + left: 0; + z-index: 999; + display: none; +} + +#custom-data-modal { + width: 50%; + background-color: white; + border-radius: 5px; + position: relative; + top: 15%; + left: 25%; + padding: 50px; +} + +.hide { + display: none !important; +} + +/* Special block quotes */ + +.special-quote { + font-size: 20px; + padding: 20px 20px 20px; + border-top: 3px solid rgba(200, 200, 200, 0.3); + border-left: 3px solid rgba(200, 200, 200, 0.3); + border-right: 3px solid rgba(200, 200, 200, 0.3); + display: block; + border-top-left-radius: 5px; + border-top-right-radius: 5px; + margin-top: 40px; +} + +.special-quote + h1, +.special-quote + h2, +.special-quote + h3, +.special-quote + h4, +.special-quote + h5 { + margin: -40px 0 17px; + margin-top: -40px; + padding-left: 55px; + font-size: 1.6rem; +} + +.special-quote + h1::before, +.special-quote + h2::before, +.special-quote + h3::before, +.special-quote + h4::before, +.special-quote + h5::before { + display: none; +} + +.special-quote + blockquote, +.special-quote + h1 + blockquote, +.special-quote + h2 + blockquote, +.special-quote + h3 + blockquote, +.special-quote + h4 + blockquote, +.special-quote + h5 + blockquote { + margin-top: 0; + background-color: transparent !important; + border-bottom: 3px solid rgba(200, 200, 200, 0.3) !important; + border-left: 3px solid rgba(200, 200, 200, 0.3) !important; + border-right: 3px solid rgba(200, 200, 200, 0.3) !important; + border-top: none !important; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; + padding-bottom: 7px; + margin-bottom: 40px; +} + +.special-quote + blockquote *:first-child, +.special-quote + h1 + blockquote *:first-child, +.special-quote + h2 + blockquote *:first-child, +.special-quote + h3 + blockquote *:first-child, +.special-quote + h4 + blockquote *:first-child, +.special-quote + h5 + blockquote *:first-child { + margin-top: 0 !important; +} + +.special-quote + h3 + blockquote { + margin-top: 17px; +} + +.special-quote.special-quote-info { + color: #005aa8; +} + +.special-quote.special-quote-warning { + color: #fdc008; +} + +.special-quote.special-quote-stop { + color: #fd0808; +} + +.special-quote.special-quote-stop, +.special-quote.special-quote-stop + blockquote, +.special-quote.special-quote-stop + h1 + blockquote, +.special-quote.special-quote-stop + h2 + blockquote, +.special-quote.special-quote-stop + h3 + blockquote, +.special-quote.special-quote-stop + h4 + blockquote, +.special-quote.special-quote-stop + h5 + blockquote { + border-color: #fd0808 !important; +} + +/* Tab tooltips */ + +.tablinks { + position: relative; +} + +.tablinks .tooltip { + display: none; + position: absolute; + padding: 7px; + border-radius: 3px; + z-index: 999; + background-color: #333; + color: #eee; + font-size: 0.9em; + width: 200px; + top: 40px; + left: calc(50% - 100px); + box-sizing: border-box; + user-select: text; +} + +.tablinks .tooltip a { + color: #048dc2 !important; +} + +.tablinks .tooltip::after { + bottom: 100%; + left: 50%; + border: solid transparent; + content: ""; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-color: rgba(240, 240, 240, 0); + border-bottom-color: #333; + border-width: 7px; + margin-left: -7px; +} + +.tablinks:hover .tooltip, +.tablinks .tooltip:hover { + display: block; +} diff --git a/docs/shared/mermaid-init.js b/docs/shared/mermaid-init.js new file mode 100644 index 00000000..5ce9923b --- /dev/null +++ b/docs/shared/mermaid-init.js @@ -0,0 +1,4 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +mermaid.initialize({ startOnLoad: true }); diff --git a/docs/shared/tab_footer.md b/docs/shared/tab_footer.md new file mode 100644 index 00000000..bdd6bc96 --- /dev/null +++ b/docs/shared/tab_footer.md @@ -0,0 +1,2 @@ + + diff --git a/docs/shared/tab_header.md b/docs/shared/tab_header.md new file mode 100644 index 00000000..3adf4ed9 --- /dev/null +++ b/docs/shared/tab_header.md @@ -0,0 +1,3 @@ +
+
+
diff --git a/docs/shared/tabs.js b/docs/shared/tabs.js new file mode 100644 index 00000000..ef5b34f2 --- /dev/null +++ b/docs/shared/tabs.js @@ -0,0 +1,111 @@ +/** + * Returns true if browser supports HTML5 localStorage. + */ +function supportsHTML5Storage() { + try { + return "localStorage" in window && window.localStorage !== null; + } catch (e) { + return false; + } +} + +/** + * Event handler for when a tab is clicked. + */ +function onClickTab(event) { + const target = event.currentTarget; + const language = target.dataset.lang; + + const initialTargetOffset = target.offsetTop; + const initialScrollPosition = window.scrollY; + switchAllTabs(language); + + // Keep initial perceived scroll position after resizing + // that may happen due to activation of multiple tabs in the same page. + const finalTargetOffset = target.offsetTop; + window.scrollTo({ + top: initialScrollPosition + (finalTargetOffset - initialTargetOffset), + }); +} + +/** + * Switches the displayed tab for the given container. + * + * :param container: The div containing both the tab bar and the individual tabs + * as direct children. + * :param language: The language to switch to. + */ +function switchTab(container, language) { + const previouslyActiveTab = container.querySelector(".tabcontents .active"); + previouslyActiveTab && previouslyActiveTab.classList.remove("active"); + const tab = container.querySelector(`.tabcontents [data-lang="${language}"]`); + tab && tab.innerText && tab.classList.add("active"); + + const previouslyActiveButton = container.querySelector(".tabbar .active"); + previouslyActiveButton && previouslyActiveButton.classList.remove("active"); + const button = container.querySelector(`.tabbar [data-lang="${language}"]`); + button && tab.innerText && button.classList.add("active"); +} + +/** + * Switches all tabs on the page to the given language. + * + * :param language: The language to switch to. + */ +function switchAllTabs(language) { + const containers = document.getElementsByClassName("tabs"); + for (let i = 0; i < containers.length; ++i) { + switchTab(containers[i], language); + } + + if (supportsHTML5Storage()) { + localStorage.setItem("glean-preferred-language", language); + } +} + +/** + * Opens all tabs on the page to the given language on page load. + */ +(function openTabs() { + if (!supportsHTML5Storage()) { + return; + } + + const containers = document.getElementsByClassName("tabs"); + for (let i = 0; i < containers.length; ++i) { + // Create tabs for every language that has content + const tabs = containers[i].children[0]; + const tabcontents = containers[i].children[1]; + for (const tabcontent of tabcontents.children) { + const button = document.createElement("button"); + button.dataset.lang = tabcontent.dataset.lang; + button.innerText = tabcontent.dataset.lang; + button.classList.add("tablinks"); + if (!tabcontent.innerHTML) { + button.classList.add("disabled"); + const tooltip = document.createElement("span"); + tooltip.classList.add("tooltip"); + + if (tabcontent.dataset.bug) { + tooltip.innerHTML += `${tabcontent.dataset.lang} does not provide this API yet. \nFollow Bug ${tabcontent.dataset.bug} for updates.`; + } else if (tabcontent.dataset.info) { + // Note: it is safe to use .innerHTML since we have full control over `tabcontent.dataset.info`. + tooltip.innerHTML += `${tabcontent.dataset.info}`; + } else { + tooltip.innerHTML += `${tabcontent.dataset.lang} does not provide this API.`; + } + button.appendChild(tooltip); + } else { + button.onclick = onClickTab; + } + tabs.appendChild(button); + } + } + + let language = localStorage.getItem("glean-preferred-language"); + if (language == null) { + language = "Kotlin"; + } + + switchAllTabs(language); +})(); diff --git a/docs/typedoc.json b/docs/typedoc.json new file mode 100644 index 00000000..dfda0c12 --- /dev/null +++ b/docs/typedoc.json @@ -0,0 +1,13 @@ +{ + "entryPoints": [ + "../src/core/ts", + "../src/cross-browser-ui/ts", + "../src/firefox-infobar-ui/ts" + ], + "theme": "markdown", + "exclude": ["**/*.tsx", "**/*+(index|.spec).ts"], + "excludeExternals": true, + "readme": "none", + "externalPattern": ["**/node_modules/**"], + "out": "dev/api-docs" +} diff --git a/docs/user/README.md b/docs/user/README.md new file mode 100644 index 00000000..6cd03298 --- /dev/null +++ b/docs/user/README.md @@ -0,0 +1,42 @@ +# Introduction + +Firefox Translations allows neural machine translation to happen directly in the browser, without having any content sent to an external server. + +The current version allows translation from Spanish, Estonian and Czech in and out of English, as well as English into German. + +Installation instructions are found [here](./install.md). + +> **Note** Firefox Translations is an experimental feature. + +## Release notes + +The release notes can be found on Github: [https://github.com/mozilla-extensions/firefox-translations/releases]() + +## Reporting bugs/issues + +To report issues or request changes on Firefox Translations, file a bug in [Bugzilla in Firefox :: Translation](https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox&component=Translation). Check current list of reported bugs [here](https://bugzilla.mozilla.org/buglist.cgi?product=Firefox&component=Translation&bug_status=__open__&list_id=15731344). + +## About this guide + +This is the user documentation for the **Firefox Translations** feature. + +For developer documentation on the **Firefox Translations Web Extension**, refer to [Firefox Translations Developer's Guide](../dev/index.html). + +## Acknowledgments + +### The Bergamot project + +This project was made possible through the combined effort of [all researchers and partners in the Bergamot project](https://browser.mt/partners/). The translation models are prepared as part of the Bergamot project ([https://github.com/browsermt/students]()). The translation engine used is [Bergamot Translator](https://github.com/browsermt/bergamot-translator) which is based on [Marian](https://github.com/marian-nmt/marian-dev). + +The Bergamot project adds and improves client-side machine translation in the web browser. + +Unlike current cloud-based options, running directly on users’ machines empowers citizens to preserve their privacy and increases the uptake of language technologies in Europe in various sectors that require confidentiality. Free software integrated with open-source web browsers, such as Mozilla Firefox, enables bottom-up adoption by non-experts, resulting in cost savings for private and public sector users who would otherwise procure translation or operate monolingually. + + + +The Bergamot project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 825303. + +## License + +Firefox Translations and Firefox Translations Source Code is subject to the terms of the Mozilla Public License v2.0. +You can obtain a copy of the MPL at . diff --git a/docs/user/SUMMARY.md b/docs/user/SUMMARY.md new file mode 100644 index 00000000..fcd77640 --- /dev/null +++ b/docs/user/SUMMARY.md @@ -0,0 +1,5 @@ +[Introduction](README.md) + +- [Installation instructions](install.md) +- [Usage instructions](usage.md) +- [Cross-browser version](cross-browser-version.md) diff --git a/docs/user/book.toml b/docs/user/book.toml new file mode 100644 index 00000000..23ed4016 --- /dev/null +++ b/docs/user/book.toml @@ -0,0 +1,25 @@ +[book] +title = "Firefox Translations Web Extension - User Guide" +authors = ["Bergamot Team @ Mozilla"] +src = "." + +[build] +build-dir = "../../docs/user" +create-missing = true + +[output.html] +additional-css = ["../shared/custom.css"] +additional-js = ["../shared/tabs.js", "../shared/mermaid.min.js", "../shared/mermaid-init.js"] +git-repository-url = "https://github.com/mozilla-extensions/firefox-translations" +git-branch = "main" +mathjax-support = true + +[output.html.fold] +enable = true +level = 0 + +[preprocessor.open-on-gh] +command = "mdbook-open-on-gh" + +[preprocessor.mermaid] +command = "mdbook-mermaid" diff --git a/docs/user/cross-browser-version.md b/docs/user/cross-browser-version.md new file mode 100644 index 00000000..6e50bb88 --- /dev/null +++ b/docs/user/cross-browser-version.md @@ -0,0 +1,45 @@ +# Cross-browser version + +Firefox Translations is currently a Firefox-only feature since it uses native browser UI elements and takes advantage of Firefox-specific optimizations. + +In the past, and possibly sometime in the future, there was/will be releases of cross-browser versions of the feature. The cross-browser version uses no Firefox-specific UI or optimizations. + + diff --git a/docs/user/eu-logo.png b/docs/user/eu-logo.png new file mode 100644 index 00000000..4e39200a Binary files /dev/null and b/docs/user/eu-logo.png differ diff --git a/docs/user/install.md b/docs/user/install.md new file mode 100644 index 00000000..20d44818 --- /dev/null +++ b/docs/user/install.md @@ -0,0 +1,15 @@ +# Installation instructions + +This document outlines how to enable the pre-released version of Firefox Translations which comes bundled with Firefox Nightly. + +### Configuring Nightly to enable the extension + +- Download and install Firefox Nightly (English or German edition) from [https://www.mozilla.org/en-US/firefox/all/#product-desktop-nightly](https://www.mozilla.org/en-US/firefox/all/#product-desktop-nightly). +- Start Firefox Nightly +- [Create a new Firefox profile](https://support.mozilla.org/kb/profile-manager-create-remove-switch-firefox-profiles). A new profile isolates this testing from your normal browsing profile, and protects your normal browser. +- Activate the new translation user interface by going to `about:config`, clicking the “Accept the Risk and Continue” button, searching for the `extensions.translations.disabled` Boolean preference, and toggling the preference to `false` by clicking the toggle button +- Firefox Translations is now enabled + +### Notes for returning testers + +- If you have manually installed any previous version of the extension, please make sure to remove/uninstall it and restarting your browser. You will find it named "Firefox Translations" or "Bergamot Translate" in `about:addons`. diff --git a/docs/user/usage.md b/docs/user/usage.md new file mode 100644 index 00000000..77b2e14e --- /dev/null +++ b/docs/user/usage.md @@ -0,0 +1,7 @@ +# Usage instructions + +- To try out Firefox Translations after installation, visit a page in a language combination that is supported for translation, eg one of: + - With Firefox Nightly English edition, visit a page in either Spanish or Estonian, eg https://www.mozilla.org/es-ES/ or https://www.mozilla.org/et/ + - With a non-English edition, visit a page in English, eg https://www.mozilla.org/en-US/ +- Press Translate in the translation infobar that pops up + - Note: For non-English editions of Nightly, you must remove EN and EN-US from the accepted languages (from the Language section of about:preferences, more precisely from the Webpage Language Settings) for the infobar to show automatically. If it doesn't show automatically, click the small translation icon to the right in the URL bar for the translation infobar to show. diff --git a/generate-model-registry.js b/generate-model-registry.js index 285c58ac..f3f5ff96 100644 --- a/generate-model-registry.js +++ b/generate-model-registry.js @@ -40,7 +40,7 @@ async function generateModelRegistry() { const modelRegistry = {}; await Promise.all( - glob.sync("bergamot-models/prod/*").map(async directory => { + glob.sync("firefox-translations-models/models/*/*").map(async directory => { const languagePair = path.basename(directory); modelRegistry[languagePair] = {}; return Promise.all( diff --git a/import-bergamot-models.sh b/import-models.sh similarity index 55% rename from import-bergamot-models.sh rename to import-models.sh index 350dd6d9..87bb2a60 100755 --- a/import-bergamot-models.sh +++ b/import-models.sh @@ -1,18 +1,18 @@ #!/usr/bin/env bash -# Usage: ./import-bergamot-models.sh +# Usage: ./import-models.sh set -e # set -x -echo "* Checkout out the relevant revision of the bergamot-models repo" +echo "* Checkout out the relevant revision of the firefox-translations-models repo" MODELS_UPDATED=0 -MODELS_GIT_REV="3e8993bdf05b7294a99747675954e9166304592f" # v0.2.1 -if [ ! -d "bergamot-models" ]; then - git clone --branch main --single-branch https://github.com/mozilla-applied-ml/bergamot-models +MODELS_GIT_REV="b22ca725bb102c034dabf3871d7349f2aca8d73d" # v0.2.10 +if [ ! -d "firefox-translations-models" ]; then + git clone --branch main --single-branch https://github.com/mozilla/firefox-translations-models MODELS_UPDATED=1 fi -cd bergamot-models +cd firefox-translations-models if [ $(git rev-parse HEAD) != "$MODELS_GIT_REV" ]; then git fetch git checkout $MODELS_GIT_REV @@ -20,11 +20,11 @@ if [ $(git rev-parse HEAD) != "$MODELS_GIT_REV" ]; then fi cd - if [ "$MODELS_UPDATED" == "1" ]; then - echo "* Importing model files from bergamot-models repo" + echo "* Importing model files from firefox-translations-models repo" mkdir -p test/locally-hosted-files/models mv test/locally-hosted-files/models/dummy tmp rm -rf test/locally-hosted-files/models/* - cp -rf bergamot-models/prod/* test/locally-hosted-files/models + cp -rf firefox-translations-models/models/*/* test/locally-hosted-files/models ls -l test/locally-hosted-files/models/* mv tmp test/locally-hosted-files/models/dummy fi diff --git a/package.json b/package.json index 7ff93df8..70e86b87 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "bergamot-browser-extension", - "description": "bergamot-browser-extension", - "version": "0.4.2", + "name": "firefox-translations", + "description": "Firefox Translations", + "version": "0.4.4", "author": "Mozilla", "engines": { "npm": "please-use-yarn", @@ -53,7 +53,6 @@ "addons-linter:cross-browser-ui:chrome": "addons-linter build/production/chrome/cross-browser-ui", "addons-linter:cross-browser-ui:firefox": "addons-linter build/production/firefox/cross-browser-ui", "addons-linter:firefox-infobar-ui": "addons-linter build/production/firefox/firefox-infobar-ui", - "bergamot-models:import": "./import-bergamot-models.sh", "bergamot-translator:download-and-import": "./download-bergamot-translator-wasm-artifacts.sh && ./import-bergamot-translator.sh ./downloaded-bergamot-translator-wasm-artifacts", "build:cross-browser-ui:chrome": "export TARGET_BROWSER=chrome UI=cross-browser-ui NODE_ENV=${NODE_ENV:-production}; yarn workspace cross-browser-ui webpack:build:chrome && web-ext build", "build:cross-browser-ui:firefox": "export TARGET_BROWSER=firefox UI=cross-browser-ui NODE_ENV=${NODE_ENV:-production}; yarn workspace cross-browser-ui webpack:build:firefox && web-ext build", @@ -65,8 +64,7 @@ "e2e-tests:cross-browser-ui:firefox": "export TARGET_BROWSER=firefox UI=cross-browser-ui FIREFOX_BINARY=${FIREFOX_BINARY:-nightly} EXTENSION_ARTIFACT=./dist/production/firefox/cross-browser-ui/bergamot-browser-extension-$npm_package_version-firefox-cross-browser-ui.xpi GECKODRIVER_URL=http://127.0.0.1:4444; ts-mocha -p test/e2e/tsconfig.json test/e2e/tests/cross-browser-ui/*.spec.ts --bail --full-trace --timeout 10000", "e2e-tests:firefox-infobar-ui": "export TARGET_BROWSER=firefox UI=firefox-infobar-ui FIREFOX_BINARY=${FIREFOX_BINARY:-nightly} EXTENSION_ARTIFACT=./dist/production/firefox/firefox-infobar-ui/firefox-translations-$npm_package_version.xpi GECKODRIVER_URL=http://127.0.0.1:4444; ts-mocha -p test/e2e/tsconfig.json test/e2e/tests/firefox-infobar-ui/*.spec.ts --bail --full-trace --timeout 10000", "e2e-tests:test-infra": "export FIREFOX_BINARY=${FIREFOX_BINARY:-nightly} GECKODRIVER_URL=http://127.0.0.1:4444; ts-mocha -p test/e2e/tsconfig.json test/e2e/tests/test-infra/*.spec.ts --bail --full-trace --timeout 10000", - "format": "npm-run-all -s -n format:prettier format:docs format:eslint format:fixpack", - "format:docs": "doctoc --title '**Contents**' docs/*.md && prettier '**/*.md' --ignore-path=.eslintignore --write", + "format": "npm-run-all -s -n format:prettier format:eslint format:fixpack", "format:eslint": "npm run lint:eslint -- --fix", "format:fixpack": "fixpack && fixpack src/core/package.json && fixpack src/cross-browser-ui/package.json && fixpack src/firefox-infobar-ui/package.json", "format:prettier": "prettier '**/*.{css,scss,js,ts,tsx,json,jsm,html}' --ignore-path=.eslintignore --write", @@ -80,6 +78,7 @@ "init-dotenv-config": "./init-dotenv-config.sh", "lint": "npm-run-all lint:*", "lint:eslint": "eslint . --ext jsm,js,json,ts,tsx", + "models:import": "./import-models.sh", "prebuild:cross-browser-ui:chrome": "export TARGET_BROWSER=chrome UI=cross-browser-ui NODE_ENV=${NODE_ENV:-production}; npm-run-all init-dotenv-config clean generate-manifest", "prebuild:cross-browser-ui:firefox": "export TARGET_BROWSER=firefox UI=cross-browser-ui NODE_ENV=${NODE_ENV:-production}; npm-run-all init-dotenv-config clean generate-manifest", "prebuild:firefox-infobar-ui": "export TARGET_BROWSER=firefox UI=firefox-infobar-ui NODE_ENV=${NODE_ENV:-production}; npm-run-all init-dotenv-config clean generate-manifest", @@ -94,6 +93,7 @@ "workspaces": [ "src/core", "src/cross-browser-ui", - "src/firefox-infobar-ui" + "src/firefox-infobar-ui", + "docs" ] } diff --git a/src/core/package.json b/src/core/package.json index 12de5fff..99bd7dca 100644 --- a/src/core/package.json +++ b/src/core/package.json @@ -1,6 +1,6 @@ { "name": "core", - "description": "bergamot-browser-extension/core", + "description": "core", "version": "0.0.0", "dependencies": { "@mozilla/glean": "^0.15.0", @@ -19,6 +19,7 @@ "@types/firefox-webext-browser": "^78.0.1", "@types/mocha": "^8.2.1", "@types/selenium-webdriver": "^4.0.11", + "@types/webpack-env": "^1.16.0", "@typescript-eslint/eslint-plugin": "^4.17.0", "@typescript-eslint/parser": "^4.17.0", "addons-linter": "^3.4.0", diff --git a/src/core/ts/background-scripts/background.js/telemetry/Telemetry.ts b/src/core/ts/background-scripts/background.js/telemetry/Telemetry.ts index 2c8c22c2..f42ac437 100644 --- a/src/core/ts/background-scripts/background.js/telemetry/Telemetry.ts +++ b/src/core/ts/background-scripts/background.js/telemetry/Telemetry.ts @@ -69,7 +69,7 @@ export interface TranslationRelevantFxTelemetryMetrics { * * Synchronous methods here is important, since it is the only way to guarantee that multiple Glean API calls are * executed sequentially and not interleaved with other asynchronous Telemetry recording. - * For more information, see: https://github.com/mozilla-extensions/bergamot-browser-extension/pull/76#discussion_r602128568 + * For more information, see: https://github.com/mozilla-extensions/firefox-translations/pull/76#discussion_r602128568 * * Glean.js guarantees zero exceptions, but our glue code or specific way of invoking Glean.js may result in exceptions. * For this reason we surround all code invoking Glean.js in try/catch blocks. diff --git a/src/core/ts/background-scripts/background.js/telemetry/generated/metadata.ts b/src/core/ts/background-scripts/background.js/telemetry/generated/metadata.ts index 624bec0c..7ce800c4 100644 --- a/src/core/ts/background-scripts/background.js/telemetry/generated/metadata.ts +++ b/src/core/ts/background-scripts/background.js/telemetry/generated/metadata.ts @@ -4,8 +4,8 @@ // AUTOGENERATED BY glean_parser. DO NOT EDIT. DO NOT COMMIT. -import StringMetricType from "@mozilla/glean/webext/private/metrics/string"; import QuantityMetricType from "@mozilla/glean/webext/private/metrics/quantity"; +import StringMetricType from "@mozilla/glean/webext/private/metrics/string"; /** * Translation source language. * diff --git a/src/core/ts/background-scripts/background.js/telemetry/generated/metrics.md b/src/core/ts/background-scripts/background.js/telemetry/generated/metrics.md index 8bf07490..fc71462d 100644 --- a/src/core/ts/background-scripts/background.js/telemetry/generated/metrics.md +++ b/src/core/ts/background-scripts/background.js/telemetry/generated/metrics.md @@ -14,6 +14,7 @@ This means you might have to go searching through the dependency tree to get a f A custom ping, sending time is fully controlled by the application. + This ping includes the [client id](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section). **Data reviews for this ping:** @@ -22,57 +23,58 @@ This ping includes the [client id](https://mozilla.github.io/glean/book/user/pin **Bugs related to this ping:** -- +- All Glean pings contain built-in metrics in the [`ping_info`](https://mozilla.github.io/glean/book/user/pings/index.html#the-ping_info-section) and [`client_info`](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section) sections. In addition to those built-in metrics, the following metrics are added to the ping: -| Name | Type | Description | Data reviews | Extras | Expiration | [Data Sensitivity](https://wiki.mozilla.org/Firefox/Data_Collection) | -| ------------------------------------------ | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ---------------------------------------- | ---------- | -------------------------------------------------------------------- | -| errors.marian | [counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) | Marian code related error. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| errors.memory | [counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) | Memory allocation error. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| errors.model_download | [counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) | Failed to download a model for a supported language pair. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| errors.translation | [counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) | The translation procedure has failed. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| infobar.change_lang | [event](https://mozilla.github.io/glean/book/user/metrics/event.html) | "This page is in" language was changed manually. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| infobar.closed | [event](https://mozilla.github.io/glean/book/user/metrics/event.html) | The translation infobar was closed. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| infobar.displayed | [event](https://mozilla.github.io/glean/book/user/metrics/event.html) | The translation infobar was automatically displayed in a browser. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| infobar.never_translate_lang | [event](https://mozilla.github.io/glean/book/user/metrics/event.html) | "Never translate language" button in the infobar options was pressed. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| infobar.never_translate_site | [event](https://mozilla.github.io/glean/book/user/metrics/event.html) | "Never translate site" button in the infobar options was pressed. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| infobar.not_now | [event](https://mozilla.github.io/glean/book/user/metrics/event.html) | "Not now" button on the infobar was pressed. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| infobar.translate | [event](https://mozilla.github.io/glean/book/user/metrics/event.html) | The "Translate" button was pressed on translation infobar. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| metadata.bergamot_translator_version | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Bergamot translator engine version | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| metadata.cpu_cores_count | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Telemetry Environment `system.cpu.cores` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: cores
| 2021-08-10 | 1 | -| metadata.cpu_count | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Telemetry Environment `system.cpu.count` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: cpus
| 2021-08-10 | 1 | -| metadata.cpu_extensions | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Telemetry Environment `system.cpu.extensions` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| metadata.cpu_family | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Telemetry Environment `system.cpu.family` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: enum
| 2021-08-10 | 1 | -| metadata.cpu_l2_cache | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Telemetry Environment `system.cpu.l2cacheKB` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: kb
| 2021-08-10 | 1 | -| metadata.cpu_l3_cache | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Telemetry Environment `system.cpu.l3cacheKB` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: kb
| 2021-08-10 | 1 | -| metadata.cpu_model | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Telemetry Environment `system.cpu.model` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: enum
| 2021-08-10 | 1 | -| metadata.cpu_speed | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Telemetry Environment `system.cpu.speedMHz` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: mhz
| 2021-08-10 | 1 | -| metadata.cpu_stepping | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Telemetry Environment `system.cpu.stepping` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: enum
| 2021-08-10 | 1 | -| metadata.cpu_vendor | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Telemetry Environment `system.cpu.vendor` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| metadata.extension_build_id | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Extension build id, indicating which git revision and build config was used to produce this build | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| metadata.extension_version | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Extension version | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| metadata.firefox_client_id | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Firefox Telemetry client id. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| metadata.from_lang | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Translation source language. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| metadata.system_memory | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Telemetry Environment `system.memoryMB` metric | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: mb
| 2021-08-10 | 1 | -| metadata.to_lang | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Translation target language. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| performance.full_page_translated_time | [timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) | Timing from "translation button pressed" to "full page is translated". | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| performance.full_page_translated_wps | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Speed of the translation from "translation button pressed" to "full page is translated". | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: words per second
| 2021-08-10 | 1 | -| performance.model_download_time_num | [timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) | Time spent on downloading a translation model for a language pair. (Renamed from model_download_time to model_download_time_num as part of changing type from string to quantity) | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| performance.model_load_time_num | [timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) | Time spent on loading a model into memory to start translation. (Renamed from model_load_time to model_load_time_num as part of changing type from string to quantity) | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| performance.translation_engine_time | [timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) | Time spent on translation by the translation engine. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| performance.translation_engine_wps | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Speed of translation as measured by the translation engine. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: words per second
| 2021-08-10 | 1 | -| performance.translation_quality | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Quality estimation of translation. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| performance.word_count | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Total number of words on the original web page. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: words
| 2021-08-10 | 1 | -| performance.word_count_visible_in_viewport | [quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) | Total number of visible words on the original web page that were visible in the viewport at the time of "translation button pressed". | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) |
  • unit: words
| 2021-08-10 | 1 | -| service.lang_mismatch | [counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) | The user and website languages do not match. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| service.not_supported | [counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) | Language pair of user and website languages is not supported. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 2 | -| test.counter_test | [counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) | Test counter. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| test.event_test | [event](https://mozilla.github.io/glean/book/user/metrics/event.html) | Test event. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | -| test.string_test | [string](https://mozilla.github.io/glean/book/user/metrics/string.html) | Test string. | [Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813) | | 2021-08-10 | 1 | +| Name | Type | Description | Data reviews | Extras | Expiration | [Data Sensitivity](https://wiki.mozilla.org/Firefox/Data_Collection) | +| --- | --- | --- | --- | --- | --- | --- | +| errors.marian |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Marian code related error. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| errors.memory |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Memory allocation error. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| errors.model_download |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Failed to download a model for a supported language pair. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| errors.translation |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |The translation procedure has failed. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| infobar.change_lang |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |"This page is in" language was changed manually. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| infobar.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The translation infobar was closed. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| infobar.displayed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The translation infobar was automatically displayed in a browser. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| infobar.never_translate_lang |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |"Never translate language" button in the infobar options was pressed. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| infobar.never_translate_site |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |"Never translate site" button in the infobar options was pressed. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| infobar.not_now |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |"Not now" button on the infobar was pressed. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| infobar.translate |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The "Translate" button was pressed on translation infobar. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| metadata.bergamot_translator_version |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Bergamot translator engine version |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| metadata.cpu_cores_count |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Telemetry Environment `system.cpu.cores` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: cores
|2022-02-10 |1 | +| metadata.cpu_count |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Telemetry Environment `system.cpu.count` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: cpus
|2022-02-10 |1 | +| metadata.cpu_extensions |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Telemetry Environment `system.cpu.extensions` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| metadata.cpu_family |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Telemetry Environment `system.cpu.family` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: enum
|2022-02-10 |1 | +| metadata.cpu_l2_cache |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Telemetry Environment `system.cpu.l2cacheKB` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: kb
|2022-02-10 |1 | +| metadata.cpu_l3_cache |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Telemetry Environment `system.cpu.l3cacheKB` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: kb
|2022-02-10 |1 | +| metadata.cpu_model |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Telemetry Environment `system.cpu.model` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: enum
|2022-02-10 |1 | +| metadata.cpu_speed |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Telemetry Environment `system.cpu.speedMHz` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: mhz
|2022-02-10 |1 | +| metadata.cpu_stepping |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Telemetry Environment `system.cpu.stepping` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: enum
|2022-02-10 |1 | +| metadata.cpu_vendor |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Telemetry Environment `system.cpu.vendor` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| metadata.extension_build_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Extension build id, indicating which git revision and build config was used to produce this build |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| metadata.extension_version |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Extension version |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| metadata.firefox_client_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Firefox Telemetry client id. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| metadata.from_lang |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Translation source language. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| metadata.system_memory |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Telemetry Environment `system.memoryMB` metric |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: mb
|2022-02-10 |1 | +| metadata.to_lang |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Translation target language. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| performance.full_page_translated_time |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Timing from "translation button pressed" to "full page is translated". |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| performance.full_page_translated_wps |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Speed of the translation from "translation button pressed" to "full page is translated". |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: words per second
|2022-02-10 |1 | +| performance.model_download_time_num |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Time spent on downloading a translation model for a language pair. (Renamed from model_download_time to model_download_time_num as part of changing type from string to quantity) |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| performance.model_load_time_num |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Time spent on loading a model into memory to start translation. (Renamed from model_load_time to model_load_time_num as part of changing type from string to quantity) |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| performance.translation_engine_time |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Time spent on translation by the translation engine. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| performance.translation_engine_wps |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Speed of translation as measured by the translation engine. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: words per second
|2022-02-10 |1 | +| performance.translation_quality |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Quality estimation of translation. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| performance.word_count |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Total number of words on the original web page. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: words
|2022-02-10 |1 | +| performance.word_count_visible_in_viewport |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Total number of visible words on the original web page that were visible in the viewport at the time of "translation button pressed". |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)|
  • unit: words
|2022-02-10 |1 | +| service.lang_mismatch |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |The user and website languages do not match. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| service.not_supported |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Language pair of user and website languages is not supported. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |2 | +| test.counter_test |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Test counter. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| test.event_test |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Test event. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | +| test.string_test |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Test string. |[Bug 1694813](https://bugzilla.mozilla.org/show_bug.cgi?id=1694813)||2022-02-10 |1 | Data categories are [defined here](https://wiki.mozilla.org/Firefox/Data_Collection). + diff --git a/src/core/ts/background-scripts/background.js/telemetry/generated/performance.ts b/src/core/ts/background-scripts/background.js/telemetry/generated/performance.ts index 02e77176..9d0d38fa 100644 --- a/src/core/ts/background-scripts/background.js/telemetry/generated/performance.ts +++ b/src/core/ts/background-scripts/background.js/telemetry/generated/performance.ts @@ -4,9 +4,9 @@ // AUTOGENERATED BY glean_parser. DO NOT EDIT. DO NOT COMMIT. -import StringMetricType from "@mozilla/glean/webext/private/metrics/string"; -import TimespanMetricType from "@mozilla/glean/webext/private/metrics/timespan"; import QuantityMetricType from "@mozilla/glean/webext/private/metrics/quantity"; +import TimespanMetricType from "@mozilla/glean/webext/private/metrics/timespan"; +import StringMetricType from "@mozilla/glean/webext/private/metrics/string"; /** * Timing from "translation button pressed" * to "full page is translated". diff --git a/src/core/ts/background-scripts/background.js/telemetry/generated/test.ts b/src/core/ts/background-scripts/background.js/telemetry/generated/test.ts index ed92a49a..2101b104 100644 --- a/src/core/ts/background-scripts/background.js/telemetry/generated/test.ts +++ b/src/core/ts/background-scripts/background.js/telemetry/generated/test.ts @@ -5,8 +5,8 @@ // AUTOGENERATED BY glean_parser. DO NOT EDIT. DO NOT COMMIT. import EventMetricType from "@mozilla/glean/webext/private/metrics/event"; -import StringMetricType from "@mozilla/glean/webext/private/metrics/string"; import CounterMetricType from "@mozilla/glean/webext/private/metrics/counter"; +import StringMetricType from "@mozilla/glean/webext/private/metrics/string"; /** * Test counter. * diff --git a/src/core/ts/background-scripts/background.js/telemetry/metrics.yaml b/src/core/ts/background-scripts/background.js/telemetry/metrics.yaml index 43545127..6bccdfc3 100644 --- a/src/core/ts/background-scripts/background.js/telemetry/metrics.yaml +++ b/src/core/ts/background-scripts/background.js/telemetry/metrics.yaml @@ -22,14 +22,14 @@ metadata: description: | Translation source language. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 to_lang: type: string lifetime: ping @@ -38,14 +38,14 @@ metadata: description: | Translation target language. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 firefox_client_id: type: string lifetime: ping @@ -54,14 +54,14 @@ metadata: description: | Firefox Telemetry client id. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/92 + - https://github.com/mozilla-extensions/firefox-translations/issues/92 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 extension_version: type: string lifetime: ping @@ -70,14 +70,14 @@ metadata: description: | Extension version bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/137 + - https://github.com/mozilla-extensions/firefox-translations/issues/137 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 extension_build_id: type: string lifetime: ping @@ -87,14 +87,14 @@ metadata: Extension build id, indicating which git revision and build config was used to produce this build bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/137 + - https://github.com/mozilla-extensions/firefox-translations/issues/137 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 bergamot_translator_version: type: string lifetime: ping @@ -103,14 +103,14 @@ metadata: description: | Bergamot translator engine version bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/137 + - https://github.com/mozilla-extensions/firefox-translations/issues/137 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 system_memory: type: quantity unit: mb @@ -120,14 +120,14 @@ metadata: description: | Telemetry Environment `system.memoryMB` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_count: type: quantity unit: cpus @@ -137,14 +137,14 @@ metadata: description: | Telemetry Environment `system.cpu.count` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_cores_count: type: quantity unit: cores @@ -154,14 +154,14 @@ metadata: description: | Telemetry Environment `system.cpu.cores` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_vendor: type: string lifetime: ping @@ -170,14 +170,14 @@ metadata: description: | Telemetry Environment `system.cpu.vendor` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_family: type: quantity unit: enum @@ -187,14 +187,14 @@ metadata: description: | Telemetry Environment `system.cpu.family` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_model: type: quantity unit: enum @@ -204,14 +204,14 @@ metadata: description: | Telemetry Environment `system.cpu.model` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_stepping: type: quantity unit: enum @@ -221,14 +221,14 @@ metadata: description: | Telemetry Environment `system.cpu.stepping` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_l2_cache: type: quantity unit: kb @@ -238,14 +238,14 @@ metadata: description: | Telemetry Environment `system.cpu.l2cacheKB` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_l3_cache: type: quantity unit: kb @@ -255,14 +255,14 @@ metadata: description: | Telemetry Environment `system.cpu.l3cacheKB` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_speed: type: quantity unit: mhz @@ -272,14 +272,14 @@ metadata: description: | Telemetry Environment `system.cpu.speedMHz` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 cpu_extensions: type: string lifetime: ping @@ -288,14 +288,14 @@ metadata: description: | Telemetry Environment `system.cpu.extensions` metric bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/147 + - https://github.com/mozilla-extensions/firefox-translations/issues/147 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 performance: full_page_translated_time: @@ -307,14 +307,14 @@ performance: Timing from "translation button pressed" to "full page is translated". bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/155 + - https://github.com/mozilla-extensions/firefox-translations/issues/155 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 full_page_translated_wps: type: quantity unit: words per second @@ -325,14 +325,14 @@ performance: Speed of the translation from "translation button pressed" to "full page is translated". bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/155 + - https://github.com/mozilla-extensions/firefox-translations/issues/155 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 model_download_time_num: type: timespan lifetime: ping @@ -343,15 +343,15 @@ performance: (Renamed from model_download_time to model_download_time_num as part of changing type from string to quantity) bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/138 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/138 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 model_load_time_num: type: timespan lifetime: ping @@ -362,15 +362,15 @@ performance: (Renamed from model_load_time to model_load_time_num as part of changing type from string to quantity) bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/138 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/138 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 translation_engine_time: type: timespan lifetime: ping @@ -379,15 +379,15 @@ performance: description: | Time spent on translation by the translation engine. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/155 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/155 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 translation_engine_wps: type: quantity unit: words per second @@ -397,15 +397,15 @@ performance: description: | Speed of translation as measured by the translation engine. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/155 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/155 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 word_count: type: quantity unit: words @@ -415,15 +415,15 @@ performance: description: | Total number of words on the original web page. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/166 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/166 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 word_count_visible_in_viewport: type: quantity unit: words @@ -434,15 +434,15 @@ performance: Total number of visible words on the original web page that were visible in the viewport at the time of "translation button pressed". bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/166 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/166 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 translation_quality: type: string lifetime: ping @@ -451,14 +451,14 @@ performance: description: | Quality estimation of translation. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 infobar: displayed: @@ -469,14 +469,14 @@ infobar: description: | The translation infobar was automatically displayed in a browser. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 closed: type: event lifetime: ping @@ -485,14 +485,14 @@ infobar: description: | The translation infobar was closed. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 translate: type: event lifetime: ping @@ -501,14 +501,14 @@ infobar: description: | The "Translate" button was pressed on translation infobar. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 never_translate_lang: type: event lifetime: ping @@ -517,14 +517,14 @@ infobar: description: | "Never translate language" button in the infobar options was pressed. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 never_translate_site: type: event lifetime: ping @@ -533,14 +533,14 @@ infobar: description: | "Never translate site" button in the infobar options was pressed. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 not_now: type: event lifetime: ping @@ -549,14 +549,14 @@ infobar: description: | "Not now" button on the infobar was pressed. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 change_lang: type: event lifetime: ping @@ -565,14 +565,14 @@ infobar: description: | "This page is in" language was changed manually. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 service: not_supported: @@ -583,14 +583,14 @@ service: description: | Language pair of user and website languages is not supported. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 lang_mismatch: type: counter lifetime: ping @@ -599,14 +599,14 @@ service: description: | The user and website languages do not match. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - interaction notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 errors: translation: @@ -617,14 +617,14 @@ errors: description: | The translation procedure has failed. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 marian: type: counter lifetime: ping @@ -633,14 +633,14 @@ errors: description: | Marian code related error. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 memory: type: counter lifetime: ping @@ -649,14 +649,14 @@ errors: description: | Memory allocation error. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 model_download: type: counter lifetime: ping @@ -665,14 +665,14 @@ errors: description: | Failed to download a model for a supported language pair. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 test: counter_test: @@ -683,14 +683,14 @@ test: description: | Test counter. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 event_test: type: event lifetime: ping @@ -699,14 +699,14 @@ test: description: | Test event. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 string_test: type: string lifetime: ping @@ -715,11 +715,11 @@ test: description: | Test string. bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 data_sensitivity: - technical notification_emails: - anatal-all@mozilla.com - expires: 2021-08-10 + expires: 2022-02-10 diff --git a/src/core/ts/background-scripts/background.js/telemetry/pings.yaml b/src/core/ts/background-scripts/background.js/telemetry/pings.yaml index 2ed60b4f..f202e39e 100644 --- a/src/core/ts/background-scripts/background.js/telemetry/pings.yaml +++ b/src/core/ts/background-scripts/background.js/telemetry/pings.yaml @@ -15,7 +15,7 @@ custom: include_client_id: true send_if_empty: false bugs: - - https://github.com/mozilla-extensions/bergamot-browser-extension/issues/42 + - https://github.com/mozilla-extensions/firefox-translations/issues/42 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1694813 notification_emails: diff --git a/src/core/ts/config.ts b/src/core/ts/config.ts index 626f3359..07c31016 100644 --- a/src/core/ts/config.ts +++ b/src/core/ts/config.ts @@ -5,7 +5,7 @@ export const config = { sentryDsn: process.env.SENTRY_DSN, bergamotModelsBaseUrl: developmentBuild ? "http://0.0.0.0:4000/models" - : "https://storage.googleapis.com/bergamot-models-sandbox/0.2.0", + : "https://storage.googleapis.com/bergamot-models-sandbox/0.2.10", wasmBinariesBaseUrl: developmentBuild ? "http://0.0.0.0:4000/wasm" : "https://storage.googleapis.com/bergamot-models-sandbox/wasm/1", @@ -16,7 +16,7 @@ export const config = { // "German, French, Spanish, Polish, Czech, and Estonian in and out of English" // ISO 639-1 codes // Language pairs that are not available are commented out - // ["de","en"], + ["de", "en"], // ["fr","en"], ["es", "en"], // ["pl","en"], @@ -28,6 +28,11 @@ export const config = { // ["en","pl"], ["en", "cs"], ["en", "et"], + ["ru", "en"], + ["en", "ru"], + ["pt", "en"], + ["en", "pt"], + ["it", "en"], ], privacyNoticeUrl: "https://example.com/privacy-notice", feedbackSurveyUrl: diff --git a/src/core/ts/content-scripts/dom-translation-content-script.js/TranslationDocument.ts b/src/core/ts/content-scripts/dom-translation-content-script.js/TranslationDocument.ts index 164fc440..0eff3810 100644 --- a/src/core/ts/content-scripts/dom-translation-content-script.js/TranslationDocument.ts +++ b/src/core/ts/content-scripts/dom-translation-content-script.js/TranslationDocument.ts @@ -284,6 +284,16 @@ export class TranslationDocument { async determineVisibilityOfTranslationRoots() { const { translationRoots } = this; + // Short-circuit this process in case the document is empty, or else + // it will hang, waiting for any visible elements + if (translationRoots.length === 0) { + return { + translationRoots: [], + translationRootsVisible: [], + translationRootsVisibleInViewport: [], + }; + } + const elements = translationRoots.map( translationRoot => translationRoot.nodeRef, ); diff --git a/src/core/ts/content-scripts/dom-translation-content-script.js/dom-translators/BaseDomTranslator.ts b/src/core/ts/content-scripts/dom-translation-content-script.js/dom-translators/BaseDomTranslator.ts index 166a0abf..ee0f271f 100644 --- a/src/core/ts/content-scripts/dom-translation-content-script.js/dom-translators/BaseDomTranslator.ts +++ b/src/core/ts/content-scripts/dom-translation-content-script.js/dom-translators/BaseDomTranslator.ts @@ -262,6 +262,16 @@ export class BaseDomTranslator extends MinimalDomTranslator { if (domTranslationChunk.isLastChunk) { break; } + + // Warn if we still have content left to translate but have reached the MAX_REQUESTS limit + if ( + !domTranslationChunk.isLastChunk && + currentRequestOrdinal === MAX_REQUESTS - 1 + ) { + console.warn( + `We have reached the MAX_REQUESTS limit of ${MAX_REQUESTS} requests. Remaining parts of the page will be left untranslated`, + ); + } } // Return early with a noop if there is nothing to translate diff --git a/src/core/ts/content-scripts/dom-translation-content-script.js/dom-translators/BergamotDomTranslator.ts b/src/core/ts/content-scripts/dom-translation-content-script.js/dom-translators/BergamotDomTranslator.ts index 6990ffe9..b287ac44 100644 --- a/src/core/ts/content-scripts/dom-translation-content-script.js/dom-translators/BergamotDomTranslator.ts +++ b/src/core/ts/content-scripts/dom-translation-content-script.js/dom-translators/BergamotDomTranslator.ts @@ -17,14 +17,18 @@ import { import { BergamotDomTranslatorRequest } from "./BergamotDomTranslatorRequest"; // The maximum amount of net data allowed per request on Bergamot's API. -export const MAX_REQUEST_DATA = 500000; +export const MAX_REQUEST_DATA = 10 * 500; // About 500-1000 words per request // The maximum number of texts allowed to be translated in a single request. -export const MAX_REQUEST_TEXTS = 100; +// Currently set to 5000 sentences per request, which should cover +// any ordinary request with max 500-1000 words per request +export const MAX_REQUEST_TEXTS = 5000; // Self-imposed limit of requests. This means that a page that would need // to be broken in more than this amount of requests won't be fully translated. -export const MAX_REQUESTS = 15; +// Currently set to 1000, which implies that any document with less +// than 0.5-1 million words will be translated - eventually. +export const MAX_REQUESTS = 1000; /** * Translates a webpage using Bergamot's Translation backend. diff --git a/src/core/ts/content-scripts/dom-translation-content-script.js/index.ts b/src/core/ts/content-scripts/dom-translation-content-script.js/index.ts index fdbac9ec..edf775d8 100644 --- a/src/core/ts/content-scripts/dom-translation-content-script.js/index.ts +++ b/src/core/ts/content-scripts/dom-translation-content-script.js/index.ts @@ -103,7 +103,9 @@ const init = async () => { if (hasChanged("translationStatus")) { if ( currentTabFrameDocumentTranslationState.translationStatus === - TranslationStatus.UNKNOWN + TranslationStatus.UNKNOWN && + // Only attempt to detect language in top frames + frameInfo.frameId === 0 ) { await domTranslationManager.attemptToDetectLanguage(); } diff --git a/src/core/ts/modelRegistry.ts b/src/core/ts/modelRegistry.ts index 8c01b514..0b4c30ee 100644 --- a/src/core/ts/modelRegistry.ts +++ b/src/core/ts/modelRegistry.ts @@ -10,6 +10,144 @@ export interface ModelRegistry { } export const modelRegistry: ModelRegistry = { + enit: { + vocab: { + name: "vocab.enit.spm", + size: 814128, + estimatedCompressedSize: 405338, + expectedSha256Hash: + "de8cbeb79e0139304bfa47e8559f2447016bf9906225a97d3df1baed4de8f3a3", + }, + lex: { + name: "lex.50.50.enit.s2t.bin", + size: 4489920, + estimatedCompressedSize: 2409986, + expectedSha256Hash: + "bb1fad3b3f6a13ebce1698cf7f39ca736c4dea4525f3dab5e1a78436f07445e6", + }, + model: { + name: "model.enit.intgemm.alphas.bin", + size: 17140836, + estimatedCompressedSize: 13283223, + expectedSha256Hash: + "a5ce3723f62ead92a0e0373b6df0ad8e3e6d22963adb1333984206e33b8b6c61", + }, + }, + enpt: { + vocab: { + name: "vocab.enpt.spm", + size: 812781, + estimatedCompressedSize: 406524, + expectedSha256Hash: + "633a3d782c79f7d5e4b94ab96848f47c2fdf8ba82dd99efd1742b8a696bbd0cc", + }, + lex: { + name: "lex.50.50.enpt.s2t.bin", + size: 4472528, + estimatedCompressedSize: 2411984, + expectedSha256Hash: + "1e96599123d275afa37353dfe84677a4070f013494fbdc9c52a28445cc9bc38d", + }, + model: { + name: "model.enpt.intgemm.alphas.bin", + size: 17140836, + estimatedCompressedSize: 13429592, + expectedSha256Hash: + "d968735704c75e33c2e183b9241f14c0b2a560d01d88a2728e5c0119a4d7fb22", + }, + }, + enru: { + vocab: { + name: "vocab.enru.spm", + size: 937157, + estimatedCompressedSize: 435776, + expectedSha256Hash: + "feca2d44f01b946c85faba3b15b5eb53344bec84cd14a1a4d4a82ddd774c5edd", + }, + lex: { + name: "lex.50.50.enru.s2t.bin", + size: 3049096, + estimatedCompressedSize: 1579779, + expectedSha256Hash: + "7bd3e2c0a72286fe1f3da65c56c49a7cd77efa5f1d1a444e2a9e769480b96ff3", + }, + model: { + name: "model.enru.intgemm.alphas.bin", + size: 17140836, + estimatedCompressedSize: 12853987, + expectedSha256Hash: + "4a45186a93b8a2dd9301c66a3b3dad580b1bcfa74aadda583ca383f9fe0dea93", + }, + }, + iten: { + vocab: { + name: "vocab.iten.spm", + size: 814151, + estimatedCompressedSize: 405416, + expectedSha256Hash: + "22d5ce6973be5360a921103acbe984a9bfca952a1f6c55c9cb5ef7de4fd58266", + }, + lex: { + name: "lex.50.50.iten.s2t.bin", + size: 5238420, + estimatedCompressedSize: 2860178, + expectedSha256Hash: + "357d362373022b029ee9965975a133e6f36fdb0fed749202ff578365cf0111f8", + }, + model: { + name: "model.iten.intgemm.alphas.bin", + size: 17140836, + estimatedCompressedSize: 13423308, + expectedSha256Hash: + "1fae546faeb9046f80b1b7e940b37b660974ce72902778181d6cd1c30b717f35", + }, + }, + pten: { + vocab: { + name: "vocab.pten.spm", + size: 812889, + estimatedCompressedSize: 406730, + expectedSha256Hash: + "8389979e3c965688b07aeb712a7e44406e5dcdb2b84087229d26fcc71448c4ed", + }, + lex: { + name: "lex.50.50.pten.s2t.bin", + size: 5001420, + estimatedCompressedSize: 2733800, + expectedSha256Hash: + "212ed0ae44a6f920cd6d17ca02f0a523ba6c4b0ef5078ae310c20bc4c51484c5", + }, + model: { + name: "model.pten.intgemm.alphas.bin", + size: 17140836, + estimatedCompressedSize: 13584764, + expectedSha256Hash: + "6c3b7af01772022a19712410c63342ba581468c2f1aac34d7488409c4043e697", + }, + }, + ruen: { + vocab: { + name: "vocab.ruen.spm", + size: 936576, + estimatedCompressedSize: 435801, + expectedSha256Hash: + "aaf9a325c0a988c507d0312cb6ba1a02bac7a370bcd879aedee626a40bfbda78", + }, + lex: { + name: "lex.50.50.ruen.s2t.bin", + size: 5090836, + estimatedCompressedSize: 2684919, + expectedSha256Hash: + "e6667e22f5f86be4872e3768b7184727f5dd8c9f2ccfb0639baabcb1176f5d11", + }, + model: { + name: "model.ruen.intgemm.alphas.bin", + size: 17140836, + estimatedCompressedSize: 13108893, + expectedSha256Hash: + "3b6a0305e3d232fadd54f5a765365b7b96ad6d8f2e818cba594b02fbd8fadb3d", + }, + }, csen: { vocab: { name: "vocab.csen.spm", @@ -33,6 +171,29 @@ export const modelRegistry: ModelRegistry = { "5b16661e2864dc50b2f4091a16bdd4ec8d8283e04271e602159ba348df5d6e2d", }, }, + deen: { + vocab: { + name: "vocab.deen.spm", + size: 784269, + estimatedCompressedSize: 410738, + expectedSha256Hash: + "417668f2ed297970febafb5b079a9d5ebc4ed0b3550ac8386d67a90473a09bd7", + }, + lex: { + name: "lex.50.50.deen.s2t.bin", + size: 5047568, + estimatedCompressedSize: 2657472, + expectedSha256Hash: + "2f7c0f7bbce97ae5b52454074a892ba7b7610fb98e3c5d341e4ca79f0850c4de", + }, + model: { + name: "model.deen.intgemm.alphas.bin", + size: 17140837, + estimatedCompressedSize: 13091214, + expectedSha256Hash: + "dda44d87ab0d8ad3b3871122fd3ee385f37878183a8b4ec139cd909531ec5009", + }, + }, encs: { vocab: { name: "vocab.csen.spm", @@ -43,10 +204,10 @@ export const modelRegistry: ModelRegistry = { }, lex: { name: "lex.50.50.encs.s2t.bin", - size: 12996877, - estimatedCompressedSize: 12976833, + size: 3556124, + estimatedCompressedSize: 1913246, expectedSha256Hash: - "9fcb2c558f39a2f276540a564f364d46a0943c85d44b0637ff1a6ee7d566b0ff", + "e19c77231bf977988e31ff8db15fe79966b5170564bd3e10613f239e7f461d97", }, model: { name: "model.encs.intgemm.alphas.bin", diff --git a/src/core/ts/shared-resources/models/BaseTranslationState.ts b/src/core/ts/shared-resources/models/BaseTranslationState.ts index eefa8020..531836a3 100644 --- a/src/core/ts/shared-resources/models/BaseTranslationState.ts +++ b/src/core/ts/shared-resources/models/BaseTranslationState.ts @@ -18,7 +18,6 @@ export enum TranslationStatus { SOURCE_LANGUAGE_UNDERSTOOD = "SOURCE_LANGUAGE_UNDERSTOOD", TRANSLATION_UNSUPPORTED = "TRANSLATION_UNSUPPORTED", OFFER = "OFFER", - DOWNLOADING_TRANSLATION_MODEL = "DOWNLOADING_TRANSLATION_MODEL", TRANSLATING = "TRANSLATING", TRANSLATED = "TRANSLATED", ERROR = "ERROR", diff --git a/src/core/ts/shared-resources/models/ExtensionState.ts b/src/core/ts/shared-resources/models/ExtensionState.ts index 786fc98c..83befed9 100644 --- a/src/core/ts/shared-resources/models/ExtensionState.ts +++ b/src/core/ts/shared-resources/models/ExtensionState.ts @@ -142,57 +142,79 @@ export class ExtensionState extends Model({ url, } = getSnapshot(tabTopFrameState); + // For most translation-related attributes, we are only interested in the frames that existed when + // the translation was requested, or else we will not get attributes that represent the state of the + // web page at that time + const translationRelevantDocumentTranslationStates = documentTranslationStates.filter( + dts => + dts.translationRequested || + dts.translationStatus === TranslationStatus.TRANSLATING || + dts.translationFinished, + ); + + const isNotUndefined = val => val !== undefined; + // Sum some state attributes - const wordCount = documentTranslationStates + const wordCount = translationRelevantDocumentTranslationStates .map(dts => dts.wordCount) + .filter(isNotUndefined) .reduce((a, b) => a + b, 0); - const wordCountVisible = documentTranslationStates + const wordCountVisible = translationRelevantDocumentTranslationStates .map(dts => dts.wordCountVisible) + .filter(isNotUndefined) .reduce((a, b) => a + b, 0); - const wordCountVisibleInViewport = documentTranslationStates + const wordCountVisibleInViewport = translationRelevantDocumentTranslationStates .map(dts => dts.wordCountVisibleInViewport) + .filter(isNotUndefined) .reduce((a, b) => a + b, 0); - const totalModelLoadWallTimeMs = documentTranslationStates + const totalModelLoadWallTimeMs = translationRelevantDocumentTranslationStates .map(dts => dts.totalModelLoadWallTimeMs) + .filter(isNotUndefined) .reduce((a, b) => a + b, 0); - const totalTranslationWallTimeMs = documentTranslationStates + const totalTranslationWallTimeMs = translationRelevantDocumentTranslationStates .map(dts => dts.totalTranslationWallTimeMs) + .filter(isNotUndefined) .reduce((a, b) => a + b, 0); - const totalTranslationEngineRequestCount = documentTranslationStates + const totalTranslationEngineRequestCount = translationRelevantDocumentTranslationStates .map(dts => dts.totalTranslationEngineRequestCount) + .filter(isNotUndefined) .reduce((a, b) => a + b, 0); - const queuedTranslationEngineRequestCount = documentTranslationStates + const queuedTranslationEngineRequestCount = translationRelevantDocumentTranslationStates .map(dts => dts.queuedTranslationEngineRequestCount) + .filter(isNotUndefined) .reduce((a, b) => a + b, 0); // Merge translation-progress-related booleans as per src/core/ts/shared-resources/state-management/DocumentTranslationStateCommunicator.ts - const translationInitiationTimestamps = documentTranslationStates.map( - (dts: DocumentTranslationState) => dts.translationInitiationTimestamp, - ); + const translationInitiationTimestamps = translationRelevantDocumentTranslationStates + .map( + (dts: DocumentTranslationState) => + dts.translationInitiationTimestamp, + ) + .filter(isNotUndefined); const translationInitiationTimestamp = Math.min( ...translationInitiationTimestamps, ); - const modelLoadNecessary = !!documentTranslationStates.filter( + const modelLoadNecessary = !!translationRelevantDocumentTranslationStates.filter( (dts: DocumentTranslationState) => dts.modelLoadNecessary, ).length; - const modelDownloadNecessary = !!documentTranslationStates.filter( + const modelDownloadNecessary = !!translationRelevantDocumentTranslationStates.filter( (dts: DocumentTranslationState) => dts.modelDownloadNecessary, ).length; - const modelDownloading = !!documentTranslationStates.filter( + const modelDownloading = !!translationRelevantDocumentTranslationStates.filter( (dts: DocumentTranslationState) => dts.modelDownloading, ).length; const modelLoading = modelLoadNecessary - ? !!documentTranslationStates.find( + ? !!translationRelevantDocumentTranslationStates.find( (dts: DocumentTranslationState) => dts.modelLoading, ) : undefined; const modelLoaded = modelLoadNecessary - ? !!documentTranslationStates.find( + ? !!translationRelevantDocumentTranslationStates.find( (dts: DocumentTranslationState) => !dts.modelLoaded, ) : undefined; const translationFinished = - documentTranslationStates.filter( + translationRelevantDocumentTranslationStates.filter( (dts: DocumentTranslationState) => !dts.translationFinished, ).length === 0; @@ -204,7 +226,7 @@ export class ExtensionState extends Model({ durationMs: 0, endTs: undefined, }; - const modelDownloadProgress = documentTranslationStates + const modelDownloadProgress = translationRelevantDocumentTranslationStates .map((dts: DocumentTranslationState) => getSnapshot(dts.modelDownloadProgress), ) @@ -223,45 +245,59 @@ export class ExtensionState extends Model({ }, emptyDownloadProgress); // Merge errorOccurred attributes - const modelLoadErrorOccurred = !!documentTranslationStates.filter( + const modelLoadErrorOccurred = !!translationRelevantDocumentTranslationStates.filter( (dts: DocumentTranslationState) => dts.modelLoadErrorOccurred, ).length; - const modelDownloadErrorOccurred = !!documentTranslationStates.filter( + const modelDownloadErrorOccurred = !!translationRelevantDocumentTranslationStates.filter( (dts: DocumentTranslationState) => dts.modelDownloadErrorOccurred, ).length; - const translationErrorOccurred = !!documentTranslationStates.filter( + const translationErrorOccurred = !!translationRelevantDocumentTranslationStates.filter( (dts: DocumentTranslationState) => dts.translationErrorOccurred, ).length; - const otherErrorOccurred = !!documentTranslationStates.filter( + const otherErrorOccurred = !!translationRelevantDocumentTranslationStates.filter( (dts: DocumentTranslationState) => dts.otherErrorOccurred, ).length; // Special merging of translation status - const anyTabHasTranslationStatus = ( + const anyFrameHasTranslationStatus = ( translationStatus: TranslationStatus, ) => documentTranslationStates.find( dts => dts.translationStatus === translationStatus, ); + const anyFrameThatExistedWhenTranslationWasRequestedHasTranslationStatus = ( + translationStatus: TranslationStatus, + ) => + translationRelevantDocumentTranslationStates.find( + dts => dts.translationStatus === translationStatus, + ); + const tabTranslationStatus = (): TranslationStatus => { + // Since we only use some attributes from the top frame, we should only consider + // top frame when considering the related statuses if ( - anyTabHasTranslationStatus(TranslationStatus.DETECTING_LANGUAGE) + [ + TranslationStatus.DETECTING_LANGUAGE, + TranslationStatus.OFFER, + ].includes(tabTopFrameState.translationStatus) ) { - return TranslationStatus.DETECTING_LANGUAGE; + return tabTopFrameState.translationStatus; } + // Translation is ongoing - only consider frames that were available when + // the translation was requested, or else new frames injected in the document + // will cause unexpected status changes if ( - anyTabHasTranslationStatus( - TranslationStatus.DOWNLOADING_TRANSLATION_MODEL, + anyFrameThatExistedWhenTranslationWasRequestedHasTranslationStatus( + TranslationStatus.TRANSLATING, ) ) { - return TranslationStatus.DOWNLOADING_TRANSLATION_MODEL; - } - if (anyTabHasTranslationStatus(TranslationStatus.TRANSLATING)) { return TranslationStatus.TRANSLATING; } - if (anyTabHasTranslationStatus(TranslationStatus.ERROR)) { + // An error in any frame makes gets promoted to tab-level + if (anyFrameHasTranslationStatus(TranslationStatus.ERROR)) { return TranslationStatus.ERROR; } + // Fallback on top frame status as the canonical status return tabTopFrameState.translationStatus; }; const translationStatus = tabTranslationStatus(); diff --git a/src/core/ts/web-worker-scripts/translation-worker.js/index.ts b/src/core/ts/web-worker-scripts/translation-worker.js/index.ts index e40aab2a..bfd4878b 100644 --- a/src/core/ts/web-worker-scripts/translation-worker.js/index.ts +++ b/src/core/ts/web-worker-scripts/translation-worker.js/index.ts @@ -33,9 +33,12 @@ interface DownloadedFilesByType { vocab: DownloadedFile; } +// https://stackoverflow.com/a/54382037 +const ctx: Worker = self as any; + const init = async () => { const log = message => { - postMessage({ + ctx.postMessage({ type: "log", message, }); @@ -305,7 +308,7 @@ gemm-precision: int8shift requestId, errorSource, }; - postMessage(message); + ctx.postMessage(message); }; onmessage = function(msg: { data: IncomingBergamotTranslatorAPIMessage }) { @@ -326,7 +329,7 @@ gemm-precision: int8shift requestId, modelDownloadProgress, }; - postMessage(message); + ctx.postMessage(message); }, ) .then(loadModelResults => { @@ -335,7 +338,7 @@ gemm-precision: int8shift requestId, loadModelResults, }; - postMessage(message); + ctx.postMessage(message); }) .catch(error => { if (error.name === "FileDownloadError") { @@ -358,7 +361,7 @@ gemm-precision: int8shift requestId, translationResults, }; - postMessage(message); + ctx.postMessage(message); } catch (error) { handleError(error, requestId, "translate"); } @@ -372,7 +375,7 @@ gemm-precision: int8shift }; // Send a message indicating that the worker is ready to receive WASM-related messages - postMessage("ready"); + ctx.postMessage("ready"); log("The worker is ready to receive translation-related messages"); }); }; diff --git a/src/cross-browser-ui/package.json b/src/cross-browser-ui/package.json index c0d4a250..6ed1cf98 100644 --- a/src/cross-browser-ui/package.json +++ b/src/cross-browser-ui/package.json @@ -1,6 +1,6 @@ { "name": "cross-browser-ui", - "description": "bergamot-browser-extension/cross-browser-ui", + "description": "cross-browser-ui", "version": "0.0.0", "dependencies": { "@ant-design/colors": "^4.0.5", diff --git a/src/cross-browser-ui/static/_locales/cs/messages.json b/src/cross-browser-ui/static/_locales/cs/messages.json new file mode 100644 index 00000000..d4311327 --- /dev/null +++ b/src/cross-browser-ui/static/_locales/cs/messages.json @@ -0,0 +1,74 @@ +{ + "extensionName": { + "message": "Bergamot", + "description": "Name of the extension" + }, + "extensionDescription": { + "message": "Neuronový strojový překlad v prohlížeči", + "description": "Description of the extension." + }, + "browserActionButtonTitle": { + "message": "Bergamot", + "description": "The browser action button title." + }, + "translationStatus_UNAVAILABLE_mainInterfaceMessage": { + "message": "Tuto stránku nelze přeložit.", + "description": "Main interface dropdown message for: When no translation is relevant (about-pages and the like)" + }, + "translationStatus_DETECTING_LANGUAGE_mainInterfaceMessage": { + "message": "Zjišťování jazyka stránky…", + "description": "Main interface dropdown message for: While language detection is being performed" + }, + "translationStatus_LANGUAGE_NOT_DETECTED_mainInterfaceMessage": { + "message": "Vyberte prosím jazyk, ve kterém je obsah této stránky.", + "description": "Main interface dropdown message for: When web page language detection does not succeed" + }, + "translationStatus_SOURCE_LANGUAGE_UNDERSTOOD_mainInterfaceMessage": { + "message": "Tato stránka je v jazyce [SOURCE_LANG], kterému rozumíte.", + "description": "Main interface dropdown message for: When web page is in the user's language(s)" + }, + "translationStatus_DETECTED_LANGUAGE_UNSUPPORTED_mainInterfaceMessage": { + "message": "Jazyk [SOURCE_LANG] bohužel není podporován.", + "description": "Main interface dropdown message for: When web page is in an unsupported language" + }, + "translationStatus_OFFER_mainInterfaceMessage": { + "message": "Tato stránka je v jazyce [SOURCE_LANG]. Chcete tuto stránku přeložit?", + "description": "Main interface dropdown message for: When language detection is ready and web page is in a language different than the user language(s)" + }, + "translationStatus_DOWNLOADING_TRANSLATION_MODEL_mainInterfaceMessage": { + "message": "Stahování jazykových souborů…", + "description": "Main interface dropdown message for: When language files are downloaded" + }, + "translationStatus_TRANSLATING_mainInterfaceMessage": { + "message": "Probíhá překlad stránky…", + "description": "Main interface dropdown message for: When translation is in progress" + }, + "translationStatus_TRANSLATED_mainInterfaceMessage": { + "message": "Tato stránka byla přeložena z jazyka [SOURCE_LANG] do jazyka [TARGET_LANG].", + "description": "Main interface dropdown message for: Page Successfully Translated" + }, + "translationStatus_ERROR_mainInterfaceMessage": { + "message": "Během překladu této stránky došlo k chybě.", + "description": "Main interface dropdown message for: Page Translation Error" + }, + "language_iso6391_en": { + "message": "angličtina", + "description": "Language name of 'en' (ISO 639-1)" + }, + "language_iso6391_de": { + "message": "němčina", + "description": "Language name of 'de' (ISO 639-1)" + }, + "language_iso6391_es": { + "message": "španělština", + "description": "Language name of 'es' (ISO 639-1)" + }, + "language_iso6391_et": { + "message": "estonština", + "description": "Language name of 'et' (ISO 639-1)" + }, + "language_iso6391_cs": { + "message": "čeština", + "description": "Language name of 'cs' (ISO 639-1)" + } +} diff --git a/src/cross-browser-ui/static/get-started/get-started.html b/src/cross-browser-ui/static/get-started/get-started.html index 04c53727..0a609d1e 100644 --- a/src/cross-browser-ui/static/get-started/get-started.html +++ b/src/cross-browser-ui/static/get-started/get-started.html @@ -6,7 +6,7 @@ Bergamot Translate: Welcome! - +
diff --git a/src/cross-browser-ui/static/main-interface/popup.html b/src/cross-browser-ui/static/main-interface/popup.html index d3ded2db..bc06ce3b 100644 --- a/src/cross-browser-ui/static/main-interface/popup.html +++ b/src/cross-browser-ui/static/main-interface/popup.html @@ -2,14 +2,16 @@ Bergamot - +
diff --git a/src/cross-browser-ui/static/main-interface/standalone.html b/src/cross-browser-ui/static/main-interface/standalone.html index e893dc6f..6975d6aa 100644 --- a/src/cross-browser-ui/static/main-interface/standalone.html +++ b/src/cross-browser-ui/static/main-interface/standalone.html @@ -1,12 +1,12 @@ - + Bergamot - +
diff --git a/src/cross-browser-ui/static/options-ui/options-ui.html b/src/cross-browser-ui/static/options-ui/options-ui.html index 5552f077..149a53ab 100644 --- a/src/cross-browser-ui/static/options-ui/options-ui.html +++ b/src/cross-browser-ui/static/options-ui/options-ui.html @@ -2,7 +2,7 @@ @@ -11,7 +11,7 @@
diff --git a/src/cross-browser-ui/ts/background-scripts/background.js/ExtensionIconTranslationState.ts b/src/cross-browser-ui/ts/background-scripts/background.js/ExtensionIconTranslationState.ts index 03007904..18d3d8e0 100644 --- a/src/cross-browser-ui/ts/background-scripts/background.js/ExtensionIconTranslationState.ts +++ b/src/cross-browser-ui/ts/background-scripts/background.js/ExtensionIconTranslationState.ts @@ -136,17 +136,6 @@ export class ExtensionIconTranslationState { tabId, ); break; - case TranslationStatus.DOWNLOADING_TRANSLATION_MODEL: - dynamicActionIcon.setBadge( - { - text: dts.detectedLanguageResults.language, - textColor: "#000000", - backgroundColor: "#ffffffAA", - }, - tabId, - ); - dynamicActionIcon.startLoadingIndication(tabId); - break; case TranslationStatus.TRANSLATING: dynamicActionIcon.setBadge( { diff --git a/src/cross-browser-ui/ts/extension-pages/main-interface.js/components/List/IItem.d.ts b/src/cross-browser-ui/ts/extension-pages/main-interface.js/components/List/IItem.d.ts index 39c75f92..8b030724 100644 --- a/src/cross-browser-ui/ts/extension-pages/main-interface.js/components/List/IItem.d.ts +++ b/src/cross-browser-ui/ts/extension-pages/main-interface.js/components/List/IItem.d.ts @@ -6,5 +6,5 @@ export interface Props { actions?: ReactNode[]; style?: CSSProperties; action?: ReactNode; - onClick?: (event: MouseEvent) => void; + onClick?: (event: React.MouseEvent) => void; } diff --git a/src/cross-browser-ui/ts/extension-pages/main-interface.js/components/Progress/interface.d.ts b/src/cross-browser-ui/ts/extension-pages/main-interface.js/components/Progress/interface.d.ts index 109c48c8..7f82655b 100644 --- a/src/cross-browser-ui/ts/extension-pages/main-interface.js/components/Progress/interface.d.ts +++ b/src/cross-browser-ui/ts/extension-pages/main-interface.js/components/Progress/interface.d.ts @@ -3,7 +3,7 @@ import { isPropertySignature } from "typescript"; interface Props { value: number; label?: boolean; - style?: CSSProperties; + style?: any; // CSSProperties; type?: "bar" | "ring"; status?: "processing" | "finished" | "paused"; onFinish?: () => void; diff --git a/src/cross-browser-ui/ts/extension-pages/main-interface.js/routes/Home.tsx b/src/cross-browser-ui/ts/extension-pages/main-interface.js/routes/Home.tsx index ffec4ad0..0bc898de 100644 --- a/src/cross-browser-ui/ts/extension-pages/main-interface.js/routes/Home.tsx +++ b/src/cross-browser-ui/ts/extension-pages/main-interface.js/routes/Home.tsx @@ -147,15 +147,6 @@ export class Home extends React.Component { break; case TranslationStatus.TRANSLATION_UNSUPPORTED: break; - case TranslationStatus.DOWNLOADING_TRANSLATION_MODEL: - action = ( -