diff --git a/BERGAMOT_VERSION b/BERGAMOT_VERSION
index 0eec13e47..f87d474c4 100644
--- a/BERGAMOT_VERSION
+++ b/BERGAMOT_VERSION
@@ -1 +1 @@
-v0.4.2
+v0.4.3
diff --git a/doc/requirements.txt b/doc/requirements.txt
index d95cc684c..778f08914 100644
--- a/doc/requirements.txt
+++ b/doc/requirements.txt
@@ -1,5 +1,6 @@
sphinx==2.4.4
breathe==4.13.0
+Jinja2==3.0.3
exhale
sphinx_rtd_theme
mistune<2.0.0
diff --git a/wasm/test_page/js/index.js b/wasm/test_page/js/index.js
index eec834cc8..b1c308e8b 100644
--- a/wasm/test_page/js/index.js
+++ b/wasm/test_page/js/index.js
@@ -7,17 +7,6 @@ const status = message => ($("#status").innerText = message);
const langFrom = $("#lang-from");
const langTo = $("#lang-to");
-const langs = [
- ["en", "English"],
- ["it", "Italian"],
- ["pt", "Portuguese"],
- ["ru", "Russian"],
- ["cs", "Czech"],
- ["de", "German"],
- ["es", "Spanish"],
- ["et", "Estonian"],
-];
-
if (window.Worker) {
worker = new Worker("js/worker.js");
worker.postMessage(["import"]);
@@ -99,11 +88,6 @@ worker.onmessage = function (e) {
}
};
-langs.forEach(([code, name]) => {
- langFrom.innerHTML += ``;
- langTo.innerHTML += ``;
-});
-
const loadModel = () => {
const lngFrom = langFrom.value;
const lngTo = langTo.value;
@@ -127,7 +111,7 @@ langTo.addEventListener("change", e => {
$(".swap").addEventListener("click", e => {
[langFrom.value, langTo.value] = [langTo.value, langFrom.value];
- $("#input").value = $("#output").value;
+ $("#input").value = $("#output").innerText;
loadModel();
});
@@ -140,11 +124,25 @@ $('#output').addEventListener('mouseover', e => {
})
function init() {
+ // Populate langs
+ const langs = Array.from(new Set(Object.keys(modelRegistry).reduce((acc, key) => acc.concat([key.substr(0, 2), key.substr(2, 2)]), [])));
+ const langNames = new Intl.DisplayNames(undefined, {type: "language"});
+
+ // Sort languages by display name
+ langs.sort((a, b) => langNames.of(a).localeCompare(langNames.of(b)));
+
+ // Populate the dropdowns
+ langs.forEach(code => {
+ const name = langNames.of(code);
+ langFrom.innerHTML += ``;
+ langTo.innerHTML += ``;
+ });
+
// try to guess input language from user agent
let myLang = navigator.language;
if (myLang) {
myLang = myLang.split("-")[0];
- let langIndex = langs.findIndex(([code]) => code === myLang);
+ let langIndex = langs.indexOf(myLang);
if (langIndex > -1) {
console.log("guessing input language is", myLang);
langFrom.value = myLang;
@@ -152,7 +150,7 @@ function init() {
}
// find first output lang that *isn't* input language
- langTo.value = langs.find(([code]) => code !== langFrom.value)[0];
+ langTo.value = langs.find(code => code !== langFrom.value);
// load this model
loadModel();
}