Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
16f0739d
Commit
16f0739d
authored
Apr 30, 2023
by
Aarni Koskela
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make localization.js do nothing if there's no localization to do
parent
335428c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
31 deletions
+37
-31
javascript/localization.js
javascript/localization.js
+37
-31
No files found.
javascript/localization.js
View file @
16f0739d
...
@@ -25,6 +25,10 @@ re_emoji = /[\p{Extended_Pictographic}\u{1F3FB}-\u{1F3FF}\u{1F9B0}-\u{1F9B3}]/u
...
@@ -25,6 +25,10 @@ re_emoji = /[\p{Extended_Pictographic}\u{1F3FB}-\u{1F3FF}\u{1F9B0}-\u{1F9B3}]/u
original_lines
=
{}
original_lines
=
{}
translated_lines
=
{}
translated_lines
=
{}
function
hasLocalization
()
{
return
window
.
localization
&&
Object
.
keys
(
window
.
localization
).
length
>
0
;
}
function
textNodesUnder
(
el
){
function
textNodesUnder
(
el
){
var
n
,
a
=
[],
walk
=
document
.
createTreeWalker
(
el
,
NodeFilter
.
SHOW_TEXT
,
null
,
false
);
var
n
,
a
=
[],
walk
=
document
.
createTreeWalker
(
el
,
NodeFilter
.
SHOW_TEXT
,
null
,
false
);
while
(
n
=
walk
.
nextNode
())
a
.
push
(
n
);
while
(
n
=
walk
.
nextNode
())
a
.
push
(
n
);
...
@@ -119,37 +123,6 @@ function dumpTranslations(){
...
@@ -119,37 +123,6 @@ function dumpTranslations(){
return
dumped
return
dumped
}
}
onUiUpdate
(
function
(
m
){
m
.
forEach
(
function
(
mutation
){
mutation
.
addedNodes
.
forEach
(
function
(
node
){
processNode
(
node
)
})
});
})
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
()
{
function
download_localization
()
{
var
text
=
JSON
.
stringify
(
dumpTranslations
(),
null
,
4
)
var
text
=
JSON
.
stringify
(
dumpTranslations
(),
null
,
4
)
...
@@ -163,3 +136,36 @@ function download_localization() {
...
@@ -163,3 +136,36 @@ function download_localization() {
document
.
body
.
removeChild
(
element
);
document
.
body
.
removeChild
(
element
);
}
}
if
(
hasLocalization
())
{
onUiUpdate
(
function
(
m
)
{
m
.
forEach
(
function
(
mutation
)
{
mutation
.
addedNodes
.
forEach
(
function
(
node
)
{
processNode
(
node
)
})
});
})
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
});
}
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment