Skip to content

Commit 6b39d1e

Browse files
committed
small improvements to translation feature
1 parent 7333a09 commit 6b39d1e

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

ext/franc-min/franc-min-6.2.0.bundle.mjs

Lines changed: 0 additions & 3 deletions
This file was deleted.

ext/franc/franc-6.2.0.bundle.mjs

Lines changed: 3 additions & 0 deletions
Large diffs are not rendered by default.

js/pageTranslations.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const webviews = require('webviews.js')
22
const statistics = require('js/statistics.js')
33

44
const pageTranslations = {
5-
apiURL: 'https://translate-api.minbrowser.org/translate',
65
languages: [
76
{
87
code: 'en'
@@ -78,7 +77,7 @@ const pageTranslations = {
7877
const userPrefs = navigator.languages.map(lang => lang.split('-')[0])
7978
const topLangs = allLangs.filter(lang => userPrefs.includes(lang.code))
8079

81-
// Translations to/from English are the highest quality in Libretranslate, so always show that near the top
80+
// English is the base/pivot language in Bergamot, so always show that near the top
8281
if (!topLangs.some(lang => lang.code === 'en')) {
8382
topLangs.push(allLangs.find(lang => lang.code === 'en'))
8483
}

js/preload/translate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const maxCharsToTranslate = 15000
1+
const maxCharsToTranslate = 50000
22

33
function isVisible (el) {
44
// https://github.com/jquery/jquery/blob/305f193aa57014dc7d8fa0739a3fefd47166cd44/src/css/hiddenVisibleSelectors.js

pages/translateService/translateService.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { LatencyOptimisedTranslator, TranslatorBacking } from '../../node_modules/@browsermt/bergamot-translator/translator.js'
22

3-
import { franc } from '../../ext/franc-min/franc-min-6.2.0.bundle.mjs'
3+
import { franc } from '../../ext/franc/franc-6.2.0.bundle.mjs'
44
import iso6393To1Mapping from './iso3To1Mapping.mjs'
55

66
const registryUrl = 'https://services.minbrowser.org/bergamot-models-v1/registry.json'
@@ -17,6 +17,7 @@ class CustomBacking extends TranslatorBacking {
1717
if (files[file].modelType !== 'prod') {
1818
return null
1919
}
20+
// The translation module expects absolute URLs but the registry entries are relative by default
2021
files[file].name = `${modelBaseUrl}/${key}/${files[file].name}`
2122
}
2223
return {
@@ -34,7 +35,7 @@ window.addEventListener('message', async function (e) {
3435
if (e.source === window && e.data === 'page-translation-session-create') {
3536
const options = {
3637
registryUrl: 'https://services.minbrowser.org/bergamot-models-v1/registry.json',
37-
cacheSize: 0, // TODO implications?
38+
cacheSize: 0, // This is a cache of translations, not models
3839
downloadTimeout: null // Disable timeout
3940
}
4041

0 commit comments

Comments
 (0)