forked from YaoApp/yao
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
562 additions
and
111 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package component | ||
|
||
// Trans trans | ||
func (column *DSL) Trans(widgetName string, inst string, trans func(widget string, inst string, value *string) bool) bool { | ||
return transMap(column.Props, widgetName, inst, trans) | ||
} | ||
|
||
func transMap(value map[string]interface{}, widgetName string, inst string, trans func(widget string, inst string, value *string) bool) bool { | ||
res := false | ||
for key, val := range value { | ||
|
||
switch val.(type) { | ||
case map[string]interface{}: | ||
if transMap(val.(map[string]interface{}), widgetName, inst, trans) { | ||
res = true | ||
} | ||
break | ||
|
||
case []interface{}: | ||
if transArr(val.([]interface{}), widgetName, inst, trans) { | ||
res = true | ||
} | ||
break | ||
|
||
case string: | ||
new := val.(string) | ||
if trans(widgetName, inst, &new) { | ||
val = new | ||
res = true | ||
} | ||
break | ||
} | ||
|
||
if trans(widgetName, inst, &key) { | ||
res = true | ||
} | ||
|
||
value[key] = val | ||
} | ||
|
||
return res | ||
} | ||
|
||
func transArr(value []interface{}, widgetName string, inst string, trans func(widget string, inst string, value *string) bool) bool { | ||
res := false | ||
for idx, val := range value { | ||
|
||
switch val.(type) { | ||
case map[string]interface{}: | ||
if transMap(val.(map[string]interface{}), widgetName, inst, trans) { | ||
res = true | ||
} | ||
break | ||
|
||
case []interface{}: | ||
if transArr(val.([]interface{}), widgetName, inst, trans) { | ||
res = true | ||
} | ||
break | ||
|
||
case string: | ||
new := val.(string) | ||
if trans(widgetName, inst, &new) { | ||
val = new | ||
res = true | ||
} | ||
break | ||
} | ||
|
||
value[idx] = val | ||
} | ||
|
||
return res | ||
} |
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
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
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
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
Oops, something went wrong.