Foundation
system
System state APIs.
system.locale
The device's language preferences and region, read synchronously.
import { system } from "onescript";
console.log(system.locale.languages) // ["ja-JP", "en-US"]
console.log(system.locale.region) // "JP"| Property | Type | Description |
|---|---|---|
languages | readonly string[] | BCP 47 language tags in the user's order of preference. |
region | string | undefined | The device region, such as "JP". |
navigator.languages, navigator.language, and process.env.LANG (for example ja_JP.UTF-8) use the same preferences. If your script needs internationalization, see i18n.
system.isDarkMode
Returns true when the current environment is using Dark Mode, otherwise returns false.
import { system } from "onescript";
if (await system.isDarkMode()) {
console.log("Dark Mode")
} else {
console.log("Light Mode")
}system.getNetworkType
Returns the current network connection type.
| Value | Enum | Description |
|---|---|---|
0 | NetworkType.None | No available network |
1 | NetworkType.WiFi | Wi-Fi |
2 | NetworkType.Cellular | Cellular data |
3 | NetworkType.Ethernet | Wired Ethernet |
4 | NetworkType.Other | Virtual or other network |
import { NetworkType, system } from "onescript";
const networkType = await system.getNetworkType();
if (networkType === NetworkType.WiFi) {
console.log("Connected through Wi-Fi")
}How is this guide?
Last updated on