Make dump translations work again

This commit is contained in:
Aarni Koskela 2023-05-13 19:22:39 +03:00
parent 1f57b948b7
commit cd6990c243

View File

@ -109,18 +109,23 @@ function processNode(node){
} }
function dumpTranslations(){ function dumpTranslations(){
if(!hasLocalization()) {
// If we don't have any localization,
// we will not have traversed the app to find
// original_lines, so do that now.
processNode(gradioApp());
}
var dumped = {} var dumped = {}
if (localization.rtl) { if (localization.rtl) {
dumped.rtl = true dumped.rtl = true;
} }
Object.keys(original_lines).forEach(function(text){ for (const text in original_lines) {
if(dumped[text] !== undefined) return if(dumped[text] !== undefined) continue;
dumped[text] = localization[text] || text;
}
dumped[text] = localization[text] || text return dumped;
})
return dumped
} }
function download_localization() { function download_localization() {