This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var WebComponentDemo=function(L){"use strict";var RZ=Object.defineProperty;var yZ=(L,C,B)=>C in L?RZ(L,C,{enumerable:!0,configurable:!0,writable:!0,value:B}):L[C]=B;var s=(L,C,B)=>yZ(L,typeof C!="symbol"?C+"":C,B);function C(){}function B(Z,l){for(const b in l)Z[b]=l[b];return Z}function yl(Z){return Z()}function ul(){return Object.create(null)}function v(Z){Z.forEach(yl)}function bl(Z){return typeof Z=="function"}function E(Z,l){return Z!=Z?l==l:Z!==l||Z&&typeof Z=="object"||typeof Z=="function"}function xl(Z){return Object.keys(Z).length===0}function dl(Z,l,b,d){if(Z){const X=Yl(Z,l,b,d);return Z[0](X)}}function Yl(Z,l,b,d){return Z[1]&&d?B(b.ctx.slice(),Z[1](d(l))):b.ctx}function Xl(Z,l,b,d){if(Z[2]&&d){const X=Z[2](d(b));if(l.dirty===void 0)return X;if(typeof X=="object"){const m=[],c=Math.max(l.dirty.length,X.length);for(let G=0;G<c;G+=1)m[G]=l.dirty[G]|X[G];return m}return l.dirty|X}return l.dirty}function ml(Z,l,b,d,X,m){if(X){const c=Yl(l,b,d,m);Z.p(c,X)}}function cl(Z){if(Z.ctx.length>32){const l=[], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize the web worker | |
const worker = new Worker('translationWorker.js'); | |
// Listen for messages from the worker | |
worker.addEventListener('message', (event) => { | |
if (event.data.status === 'update') { | |
console.log('Partial output:', event.data.output); | |
} else if (event.data.status === 'complete') { | |
console.log('Translation complete:', event.data.output); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { pipeline } from '@xenova/transformers'; | |
/** | |
* This class uses the Singleton pattern to ensure that only one instance of the | |
* pipeline is loaded. This is because loading the pipeline is an expensive | |
* operation and we don't want to do it every time we want to translate a sentence. | |
*/ | |
class MyTranslationPipeline { | |
static task = 'translation'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.6.0'; | |
env.allowLocalModels = false; | |
const status = document.getElementById('status'); | |
status.textContent = 'Loading model...'; | |
const translator = await pipeline('translation', 'Xenova/nllb-200-distilled-600M'); | |
status.textContent = 'Ready'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Translation Manager</title> | |
<style> | |
/* Modal styles */ | |
.modal { | |
display: none; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieve translations from local storage or use default | |
const storedTranslations = localStorage.getItem('translations'); | |
const translations = storedTranslations ? JSON.parse(storedTranslations) : { | |
"Hello, world!": "Hola, mundo!", | |
"This is a test.": "Esto es una prueba.", | |
// Add more default translations as needed | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to update the translations object with new strings that need translating | |
function updateTranslations(textNodes, translations) { | |
textNodes.forEach(node => { | |
const originalText = node.nodeValue.trim(); | |
if (!translations.hasOwnProperty(originalText)) { | |
translations[originalText] = ""; | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to collect all text nodes | |
function getTextNodes(element) { | |
let textNodes = []; | |
function recursiveCollect(node) { | |
if (node.nodeType === Node.TEXT_NODE) { | |
// Check if the node value is not blank or just newline characters | |
if (node.nodeValue.trim() !== "") { | |
textNodes.push(node); | |
} | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cec tc MyDemoRepository -s BitmapBytesServer -d BitmapBytesServer -n 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Cachebusting value based on update date from OCM Asset to reset the cache | |
*/ | |
function cb(asset) { | |
const time = new Date(asset.updatedDate.value).getTime() | |
return parseInt(time, 10).toString(36) | |
} | |
/** | |
* Retrieve the sourceset for an asset that is constructed from the rendition |
NewerOlder