forked from mirrors/gecko-dev
Bug 1829687 - Prefer the LangTags type in doc comments; r=nordzilla
This cleans up some duplication, especially as I refactor the type in a following patch. Differential Revision: https://phabricator.services.mozilla.com/D179084
This commit is contained in:
parent
e7f550c5e7
commit
1164161121
3 changed files with 15 additions and 8 deletions
|
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
/* eslint-env mozilla/browser-window */
|
/* eslint-env mozilla/browser-window */
|
||||||
|
|
||||||
|
/* eslint-disable jsdoc/valid-types */
|
||||||
|
/**
|
||||||
|
* @typedef {import("../../../../toolkit/components/translations/translations").LangTags} LangTags
|
||||||
|
*/
|
||||||
|
/* eslint-enable jsdoc/valid-types */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This singleton class controls the Translations popup panel.
|
* This singleton class controls the Translations popup panel.
|
||||||
*
|
*
|
||||||
|
|
@ -293,7 +299,7 @@ var TranslationsPanel = new (class {
|
||||||
// but should be handled for the MVP. We might want design direction here, as we need
|
// but should be handled for the MVP. We might want design direction here, as we need
|
||||||
// a subview for when the language list is still being retrieved.
|
// a subview for when the language list is still being retrieved.
|
||||||
|
|
||||||
/** @type {null | { appLangTag: string, docLangTag: string }} */
|
/** @type {null | LangTags} */
|
||||||
const langTags = await actor.getLangTagsForTranslation();
|
const langTags = await actor.getLangTagsForTranslation();
|
||||||
|
|
||||||
if (langTags) {
|
if (langTags) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
* @typedef {import("../translations").TranslationsEnginePayload} TranslationsEnginePayload
|
* @typedef {import("../translations").TranslationsEnginePayload} TranslationsEnginePayload
|
||||||
* @typedef {import("../translations").LanguagePair} LanguagePair
|
* @typedef {import("../translations").LanguagePair} LanguagePair
|
||||||
* @typedef {import("../translations").SupportedLanguages} SupportedLanguages
|
* @typedef {import("../translations").SupportedLanguages} SupportedLanguages
|
||||||
|
* @typedef {import("../translations").LangTags} LangTags
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -467,7 +468,7 @@ export class TranslationsChild extends JSWindowActorChild {
|
||||||
* The matched language tags for the page. Used to find a default language pair for
|
* The matched language tags for the page. Used to find a default language pair for
|
||||||
* translations.
|
* translations.
|
||||||
*
|
*
|
||||||
* @type {null | { appLangTag: string, docLangTag: string }}
|
* @type {null | LangTags}
|
||||||
* */
|
* */
|
||||||
#langTags = null;
|
#langTags = null;
|
||||||
|
|
||||||
|
|
@ -526,7 +527,7 @@ export class TranslationsChild extends JSWindowActorChild {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used to conditionally add the translations button.
|
* This is used to conditionally add the translations button.
|
||||||
* @param {null | { appLangTag: string, docLangTag: string }} langTags
|
* @param {null | LangTags} langTags
|
||||||
*/
|
*/
|
||||||
reportDetectedLangTagsToParent(langTags) {
|
reportDetectedLangTagsToParent(langTags) {
|
||||||
this.sendAsyncMessage("Translations:ReportDetectedLangTags", {
|
this.sendAsyncMessage("Translations:ReportDetectedLangTags", {
|
||||||
|
|
@ -563,7 +564,7 @@ export class TranslationsChild extends JSWindowActorChild {
|
||||||
* comparing it to the reported language of the page. If we can translate the page,
|
* comparing it to the reported language of the page. If we can translate the page,
|
||||||
* then return the language pair.
|
* then return the language pair.
|
||||||
*
|
*
|
||||||
* @returns {Promise<null | { appLangTag: string, docLangTag: string }>}
|
* @returns {Promise<null | LangTags>}
|
||||||
*/
|
*/
|
||||||
async getLangTagsForTranslation(translationsStart = this.docShell.now()) {
|
async getLangTagsForTranslation(translationsStart = this.docShell.now()) {
|
||||||
if (this.#langTags) {
|
if (this.#langTags) {
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ const VERIFY_SIGNATURES_FROM_FS = false;
|
||||||
* @typedef {import("../translations").LanguageIdEngineMockedPayload} LanguageIdEngineMockedPayload
|
* @typedef {import("../translations").LanguageIdEngineMockedPayload} LanguageIdEngineMockedPayload
|
||||||
* @typedef {import("../translations").LanguageTranslationModelFiles} LanguageTranslationModelFiles
|
* @typedef {import("../translations").LanguageTranslationModelFiles} LanguageTranslationModelFiles
|
||||||
* @typedef {import("../translations").WasmRecord} WasmRecord
|
* @typedef {import("../translations").WasmRecord} WasmRecord
|
||||||
* @typedef {import("../translations").DetectedLanguages} DetectedLanguages
|
* @typedef {import("../translations").LangTags} LangTags
|
||||||
* @typedef {import("../translations").LanguagePair} LanguagePair
|
* @typedef {import("../translations").LanguagePair} LanguagePair
|
||||||
* @typedef {import("../translations").SupportedLanguages} SupportedLanguages
|
* @typedef {import("../translations").SupportedLanguages} SupportedLanguages
|
||||||
* @typedef {import("../translations").LanguageIdModelRecord} LanguageIdModelRecord
|
* @typedef {import("../translations").LanguageIdModelRecord} LanguageIdModelRecord
|
||||||
|
|
@ -1386,7 +1386,7 @@ export class TranslationsParent extends JSWindowActorParent {
|
||||||
/**
|
/**
|
||||||
* Returns the lang tags that should be offered for translation.
|
* Returns the lang tags that should be offered for translation.
|
||||||
*
|
*
|
||||||
* @returns {Promise<null | { appLangTag: string, docLangTag: string }>}
|
* @returns {Promise<null | LangTags>}
|
||||||
*/
|
*/
|
||||||
getLangTagsForTranslation() {
|
getLangTagsForTranslation() {
|
||||||
return this.sendQuery("Translations:GetLangTagsForTranslation");
|
return this.sendQuery("Translations:GetLangTagsForTranslation");
|
||||||
|
|
@ -1603,7 +1603,7 @@ class TranslationsLanguageState {
|
||||||
/** @type {TranslationPair | null} */
|
/** @type {TranslationPair | null} */
|
||||||
#requestedTranslationPair = null;
|
#requestedTranslationPair = null;
|
||||||
|
|
||||||
/** @type {DetectedLanguages | null} */
|
/** @type {LangTags | null} */
|
||||||
#detectedLanguages = null;
|
#detectedLanguages = null;
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
|
|
@ -1663,7 +1663,7 @@ class TranslationsLanguageState {
|
||||||
* The TranslationsChild will detect languages and offer them up for translation.
|
* The TranslationsChild will detect languages and offer them up for translation.
|
||||||
* The results are stored here.
|
* The results are stored here.
|
||||||
*
|
*
|
||||||
* @returns {DetectedLanguages | null}
|
* @returns {LangTags | null}
|
||||||
*/
|
*/
|
||||||
get detectedLanguages() {
|
get detectedLanguages() {
|
||||||
return this.#detectedLanguages;
|
return this.#detectedLanguages;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue