This patch adds functionality for fetching global language settings for
translations.
This patch adds:
* The Operation `FETCH_AUTOMATIC_LANGUAGE_SETTINGS` for fetching the global language
settings from the translation engine.
* `SetLanguageSettingsAction` to set the `languageSettings` on `TranslationsBrowserState`.
*Initialization occurs in `initializeBrowserStore'
* Updates page settings to call `FETCH_AUTOMATIC_LANGUAGE_SETTINGS` after a page level
language update. (These settings coordinate both globally and on a page level.)
This bug adds:
* When `TranslateExpectedAction` occurs, then calculate the expected
translations model download size.
More background: `TranslateExpectedAction` indicates we have a default
`from` (page language) and a default `to` (user preferred) language
to initialize the translations dialog with expected values.
This queries how large of a download the translation
pair will be eagerly, so we have an initial value for the default recommendation.
This bugs shifts around the initialization for the global store in translations.
Revised Flow:
* `InitAction` -> `InitTranslationsBrowserState`
* `InitTranslationsBrowserState`:
* Checks the engine support, if everything is in order, then finishes initialization on `initializeBrowserStore`.
* A subtle bug was introduced when page settings were moved from `val` to
`var` for updating page settings.
* Everything works as expected with the reducer updating etc., however
changes on page settings are not observed in compose.
This patch refactors Translations `supportedLanguages` from `[SessionState.translationsState]`
to `[BrowserState.translationEngine]` in AC.
* Additionally adds `InitTranslationsBrowserState` to signal populating `[BrowserState.translationEngine]`.
* This patch also makes adjustments to migrates Fenix's `TranslationsDialogBinding` and `TranslationsBinding`
to also monitor this new store location.
This bug updates the logic for "never translate this language" and
"always translate this language" to ensure they are mutually exclusive
when one is true, but also allows them both to be false.
This patch fixes an issue where `isExpectedTranslate` is not cleared
between navigations. It adds logic in `TranslationsStateReducer` to
check if the criteria is met and clears the state, if applicable.
This patch adds a helper for converting BCP 47 codes to translations
supported languages.
Adds:
* `toLanguageMap` - maps a map of BCP 47 code (key) to Language (value)
* `findLanguage` - finds a language using the `toLanguageMap`
* `mapLanguageSettings` - makes a new display ready map for converting
the language settings from Map<String, LanguageSetting>?) to Map<Language?, LanguageSetting>
This patch adds a flow for determining the download size that would
occur for a given translation. Expected use case is for low-data modes.
* New `FetchTranslationDownloadSizeAction`
* New `SetTranslationDownloadSizeAction`
* New `CouldNotDetermineDownloadSizeError`
* New `TranslationDownloadSize` object and `translationDownloadSize` on the
session `TranslationsState`
This patch supports the workflow for checking if the device architecture supports translations.
This patch adds:
* New `TranslationsBrowserState` to hold global translations engine state
* New `SetEngineSupportedAction` to set the isEngineSupported value on `TranslationsBrowserState`
* New `EngineExceptionAction` to set errors on `TranslationsBrowserState`
The goal of this bug is to have a way to update page settings.
It adds:
* A new action, `UpdatePageSettingAction`
* This action has four options:
* `UPDATE_ALWAYS_OFFER_POPUP`
* `UPDATE_ALWAYS_TRANSLATE_LANGUAGE`
* `UPDATE_NEVER_TRANSLATE_LANGUAGE`
* `UPDATE_NEVER_TRANSLATE_SITE`
* Each operation eagerly sets the new setting on the browser store, then
sends the request to the engine. If setting on the engine fails, then
they will re-request the page settings in order to remain in-sync.
This patch updates:
* `requestTranslationPageSettings` is refactored to `requestPageSettings`
to match new naming conventions
* A missing dispatch in `TranslationsMiddleware` for
fetching page settings in `requestPageSettings`
* Corrects the test that was not blocking correctly that resulted in the
missing dispatch going unnoticed.
* Resets the error to null on `SetPageSettingsAction`
This patch refactors a few things for fetching supported languages:
* `TranslateExpectedAction` is decoupled from fetching languages
* Now use `OperationRequestedAction` w/ `FETCH_SUPPORTED_LANGUAGES`
* Refactors the Fenix fragment to send `OperationRequestedAction` as a
placeholder for data initialization
* `TranslateSetLanguagesAction` is now `SetSupportedLanguagesAction`
This patch adds two new Actions:
* `OperationRequestedAction` - for requesting to fetch data
* `SetSettingsAction` - for setting that data on the browser store
`TranslationsMiddleware` reacts to these Actions by fetching and setting
the appropriate data.
The patch to update data will be bug 1877203.
This patch corrects an issue where `isTranslateProcessing` and
`isRestoreProcessing` states were not updating due to not sending along
pre-process actions in `EngineDelegateMiddleware`.
This patch adds the additional state information of `supportedLanguages` and `translationError` to `TranslationsState`. The `supportedLanguages` are the languages the translation engine supports for translating for use in UI dropdowns. `translationError` is any error that occurred relating to translating.
`supportedLanguages` is currently set via an action that indicates the intention to translate on the new `EngineMiddleware` addition of `TranslationsMiddleware`. This patch also adds a new `TranslationOperation` of `FETCH_TO_AND_FROM_LANGUAGES` to indicate the process of getting `supportedLanguages`.
`translationError` is added to the `TranslationsState` to store errors as they arise. `TranslateExceptionAction` is also refactored from using the generic `Throwable` to the new `TranslationError` to accommodate `supportedLanguages` and better general error handling.O_AND_FROM_LANGUAGES` to indicate the process of getting `supportedLanguages`.
This bug adds a few options for translations preferences on the engine,
including:
* (Runtime Setting) Option to get/set translations offer popup
* (Runtime Request) Option to get/set translation language preference
* (Session Request) Option to get/set a site's translation preference
This bug adds a translation session delegate for receiving information
from GeckoView on the state of the toolkit translation engine and also
when to expect and offer translations on a given page.
It also updates reference browser to use auto-detected defaults for
translating.
This patch adds engine support for translate and restoring the page after
a translation. `requestTranslate` and `requestTranslationRestore` are
the Gecko engine session functions.
This corresponding actions for these functions are `TranslateAction`,
and `TranslateRestoreAction`. The success and failure correspond to the
actions `TranslateSuccessAction` and `TranslateExceptionAction`.
Sample usage is provided on reference browser. The sample is currently
hardcoded to support Spanish to English page translations until the next
API is introduced.
This commit adds:
* An `AwesomeBarState` class to hold the currently visible suggestions
and last clicked suggestion.
* `VisibilityStateUpdated` and `SuggestionClicked` `AwesomeBarAction`s
to update the state, and an `EngagementFinished` action to reset the
state. Consumers will dispatch these actions on the `BrowserStore`
in response to user interactions with the awesomebar and toolbar.
* A `metadata` map to `AwesomeBar.Suggestion`, allowing providers to
attach opaque data to each suggestion.