translator.lua

main 78 lines · 1.9 KB Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1local IMG_ATTR_TRANSLATED = {
2 ['offset-x'] = 'image-offset-x',
3 ['offset-y'] = 'image-offset-y',
4 ['offset'] = 'image-offset',
5 ['width'] = 'image-width',
6 ['height'] = 'image-height',
7 ['size'] = 'image-size',
8 ['rect'] = 'image-rect',
9 ['clip'] = 'image-clip',
10 ['fixed-ratio'] = 'image-fixed-ratio',
11 ['repeated'] = 'image-repeated',
12 ['smooth'] = 'image-smooth',
13 ['color'] = 'image-color',
14 ['border-top'] = 'image-border-top',
15 ['border-right'] = 'image-border-right',
16 ['border-bottom'] = 'image-border-bottom',
17 ['border-left'] = 'image-border-left',
18 ['border'] = 'image-border',
19 ['auto-resize'] = 'image-auto-resize',
20 ['individual-animation'] = 'image-individual-animation',
21 ['src'] = 'image-source'
22}
23
24local function translateStyleName(styleName, el)
25 if styleName == 'select' then
26 return 'combobox'
27 end
28
29 if styleName == 'hr' then
30 return 'HorizontalSeparator'
31 end
32
33 if styleName == 'input' then
34 if el.attributes['type'] == 'checkbox' or el.attributes['type'] == 'radio' then
35 return 'CheckBox'
36 end
37
38 return 'TextEdit'
39 end
40
41 if styleName == 'textarea' then
42 return 'MultilineTextEdit'
43 end
44
45 return styleName
46end
47
48local function translateAttribute(styleName, tagName, attr)
49 if attr == '*style' then
50 return '*mergeStyle'
51 end
52
53 if attr == '*if' then
54 return '*visible'
55 end
56
57 if styleName ~= 'CheckBox' and styleName ~= 'ComboBox' then
58 if attr == '*value' then
59 return '*text'
60 end
61
62 if attr == 'value' then
63 return 'text'
64 end
65 end
66
67 if tagName == 'img' then
68 local newAttr = IMG_ATTR_TRANSLATED[attr]
69 if newAttr then
70 return newAttr
71 end
72 end
73
74 return attr
75end
76
77return translateStyleName, translateAttribute
78
Top