feat: site languages, setup and site URL settings
This commit is contained in:
1 parent
0806733d5c
commit
d9158025d4
106 files changed
+10184
-56
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package localization
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Revision(rows []Row) string {
|
||||
ordered := slices.Clone(rows)
|
||||
slices.SortFunc(ordered, func(left Row, right Row) int { return strings.Compare(left.Tag, right.Tag) })
|
||||
digest := sha256.New()
|
||||
for _, row := range ordered {
|
||||
digest.Write([]byte(row.Tag + "|" + strconv.FormatBool(row.IsDefault) + "|" + strconv.FormatBool(row.Enabled) + "|" + socialText(row.SocialLocale) + "\n"))
|
||||
}
|
||||
return hex.EncodeToString(digest.Sum(nil))
|
||||
}
|
||||
|
||||
func SameRows(left []Row, right []Row) bool {
|
||||
return Revision(left) == Revision(right)
|
||||
}
|
||||
|
||||
func (r Row) Equal(other Row) bool {
|
||||
return r.Tag == other.Tag && r.IsDefault == other.IsDefault && r.Enabled == other.Enabled && r.Confirmed == other.Confirmed && sameSocialLocale(r.SocialLocale, other.SocialLocale)
|
||||
}
|
||||
|
||||
func sameSocialLocale(left *string, right *string) bool {
|
||||
if left == nil || right == nil {
|
||||
return left == right
|
||||
}
|
||||
return *left == *right
|
||||
}
|
||||
|
||||
func socialText(social *string) string {
|
||||
if social == nil {
|
||||
return ""
|
||||
}
|
||||
return *social
|
||||
}
|
||||
Reference in new issue
Block a user