Commit ca2ebc89 authored by xmodar's avatar xmodar Committed by AUTOMATIC1111
Browse files

Add RTL languages support and improved Arabic localization

parent df0a1f83
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ function processNode(node){
}

function dumpTranslations(){
    dumped = {}
    dumped = { rtl: localization.rtl || false }

    Object.keys(original_lines).forEach(function(text){
        if(dumped[text] !== undefined)  return
@@ -129,6 +129,24 @@ onUiUpdate(function(m){

document.addEventListener("DOMContentLoaded", function() {
    processNode(gradioApp())

    if (localization.rtl) {  // if the language is from right to left,
        (new MutationObserver((mutations, observer) => { // wait for the style to load
            mutations.forEach(mutation => {
                mutation.addedNodes.forEach(node => {
                    if (node.tagName === 'STYLE') {
                        observer.disconnect();

                        for (const x of node.sheet.rules) {  // find all rtl media rules
                            if (Array.from(x.media || []).includes('rtl')) {
                                x.media.appendMedium('all');  // enable them
                            }
                        }
                    }
                })
            });
        })).observe(gradioApp(), { childList: true });
    }
})

function download_localization() {
+455 −690

File changed.

Preview size limit exceeded, changes collapsed.

+1 −0
Original line number Diff line number Diff line
{
    "rtl": false,
    "⤡": "⤡",
    "⊞": "⊞",
    "×": "×",
+1 −0
Original line number Diff line number Diff line
{
  "rtl": false,
  "×": "×",
  "•": "•",
  "⊞": "⊞",
+1 −0
Original line number Diff line number Diff line
{
    "rtl": false,
    "⤡": "⤡",
    "⊞": "⊞",
    "×": "×",
Loading