📄 index.ts
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 1 |
📦 Imports | 5 |
📊 Variables & Constants | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/core/usePreferredLanguages/index.ts
📦 Imports¶
Name | Source |
---|---|
Ref |
vue |
ConfigurableWindow |
../_configurable |
deepRef |
vue |
defaultWindow |
../_configurable |
useEventListener |
../useEventListener |
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
navigator |
Navigator |
const | window.navigator |
✗ |
Functions¶
usePreferredLanguages(options: ConfigurableWindow): Ref<readonly string[]>
¶
Code
export function usePreferredLanguages(options: ConfigurableWindow = {}): Ref<readonly string[]> {
const { window = defaultWindow } = options
if (!window)
return deepRef(['en'])
const navigator = window.navigator
const value = deepRef<readonly string[]>(navigator.languages)
useEventListener(window, 'languagechange', () => {
value.value = navigator.languages
}, { passive: true })
return value
}
-
JSDoc:
-
Parameters:
options: ConfigurableWindow
- Return Type:
Ref<readonly string[]>
- Calls:
deepRef (from vue)
useEventListener (from ../useEventListener)