Skip to content

Commit 9a0a719

Browse files
Merge branch 'main' into hassan/asg-37-design-a-wall-of-love-page-for-eap-members-pre-eap-and-eap
2 parents e4f76a5 + a6f8e6f commit 9a0a719

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

resources/views/docs/desktop/1/the-basics/application.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ To get the current app version, use the `version` method. The version is defined
7070
$version = App::version();
7171
```
7272

73+
### Locale information
74+
75+
The facade offers several methods for accessing some of the system's localisation information.
76+
This data can be helpful for localising your application, e.g. if you want to suggest the corresponding language to the user on first launch.
77+
78+
```php
79+
App::getLocale(); // e.g. "de", "fr-FR"
80+
App::getLocaleCountryCode(); // e.g. "US", "DE"
81+
App::getSystemLocale(); // e.g. "it-IT", "de-DE"
82+
```
83+
84+
The `getLocale` method will return the locale used by the app.
85+
Dependening on the user's settings, this might include both the language and the country / region or the language only.
86+
It is based on Chromiums `l10n_util` library; see [this page](https://source.chromium.org/chromium/chromium/src/+/main:ui/base/l10n/l10n_util.cc) to see possible values.
87+
88+
`getLocaleCountryCode` returns the user's system country code (using the [ISO 3166 code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
89+
This information is pulled from native OS APIs. If it is not possible to detect this information, an empty string will be returned.
90+
91+
With `getSystemLocale` you can access the system-wide locale setting. This is the locale set at the operating system level, not necessarily what the app is using.
92+
Under Windows and Linux, Chromium's `i18n` library is used to evaluate this information. macOS will use `[NSLocale currentLocale]`.
93+
94+
7395
### App Badge Count
7496
_Only available on macOS and Linux_
7597

resources/views/docs/desktop/1/the-basics/windows.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,55 @@ Window::open()
394394

395395
This is particularly useful for always-on-top utility windows or menubar applications that should not be visible in Mission Control.
396396

397+
### Restrict navigation within a window
398+
399+
When opening windows that display content that is not under your control (such as external websites), you may want to
400+
restrict the user's navigation options. NativePHP provides two handy methods for this on the `Window` facade:
401+
402+
```php
403+
Window::open()
404+
->url('https://nativephp.com/')
405+
->preventLeaveDomain();
406+
407+
Window::open()
408+
->url('https://laravel-news.com/bifrost')
409+
->preventLeavePage();
410+
```
411+
412+
The `preventLeaveDomain()` method allows navigation within the same domain but blocks any attempt to navigate away to a
413+
different domain, scheme or port.
414+
415+
With `preventLeavePage()` you can strictly confine the user to the initially rendered page. Any attempt to navigate to a
416+
different path (even within the same domain) will be blocked. However, in-page navigation via anchors (e.g. "#section")
417+
and updates to the query string remain permitted.
418+
419+
#### Preventing new windows from popping up
420+
421+
By default, Electron allows additional windows to be opened from a window that was previously opened programmatically.
422+
This is the case, for example, with `a` elements that have the target attribute set to `_blank` or when the user clicks on a link with the middle mouse button.
423+
This behaviour is potentially undesirable in a desktop application, as it enables the user to "break out" of a window.
424+
425+
To prevent additional windows from opening, you can apply the `suppressNewWindows()` method when opening a new window.
426+
427+
```php
428+
Window::open()
429+
->suppressNewWindows();
430+
```
431+
432+
### Zoom factor
433+
434+
In certain cases, you may want to set a zoom factor for a window.
435+
This can be particularly helpful in cases where you have no control over the content displayed (e.g. when showing external websites).
436+
You may use the `zoomFactor` method to define a zoom factor.
437+
438+
```php
439+
Window::open()
440+
->zoomFactor(1.25);
441+
```
442+
443+
The zoom factor is the zoom percent divided by 100.
444+
This means that you need to pass the value `1.25` if you want the window to be displayed at 125% size.
445+
397446
## Window Title Styles
398447

399448
### Default Title Style

0 commit comments

Comments
 (0)