-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.front.go
More file actions
40 lines (32 loc) · 947 Bytes
/
env.front.go
File metadata and controls
40 lines (32 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//go:build wasm
package fmt
import (
"syscall/js"
)
// getSystemLang detects browser language from navigator.language
func (c *Conv) getSystemLang() lang {
// Get browser language
navigator := js.Global().Get("navigator")
if navigator.IsUndefined() {
return EN
}
language := navigator.Get("language")
if language.IsUndefined() {
return EN
}
// Use the centralized parser.
return c.langParser(language.String())
}
// Println prints arguments to console.log (like fmt.Println)
func Println(args ...any) {
js.Global().Get("console").Call("log", GetConv().SmartArgs(BuffOut, " ", false, false, args...).String())
}
// Printf prints formatted output to console.log (like fmt.Printf)
func Printf(format string, args ...any) {
js.Global().Get("console").Call("log", Sprintf(format, args...))
}
// isWasm reports whether the current binary is compiled for WASM.
// Used for conditional testing.
func isWasm() bool {
return true
}