Skip to content

Commit

Permalink
1.9 Docs improve reference structure
Browse files Browse the repository at this point in the history
  • Loading branch information
NigelBreslaw authored Dec 13, 2024
1 parent 1663337 commit f6da11e
Show file tree
Hide file tree
Showing 39 changed files with 216 additions and 132 deletions.
186 changes: 116 additions & 70 deletions docs/astro/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -172,103 +172,150 @@ export default defineConfig({
},
{
label: "Reference",
link: "reference/primitive-types",
link: "reference/overview",
icon: "information",
items: [
{
label: "Primitive Types",
slug: "reference/primitive-types",
label: "Overview",
slug: "reference/overview",
},
{
label: "Colors & Brushes",
slug: "reference/colors-and-brushes",
},
{
label: "Common Properties & Callbacks",
slug: "reference/common",
},
{
label: "Basic Elements",
label: "Types and Properties",
collapsed: true,
autogenerate: {
directory: "reference/elements",
},
},
{
label: "Gestures & Keyboard",
collapsed: true,
autogenerate: {
directory: "reference/gestures",
},
},
{
label: "Layouts",
collapsed: true,
autogenerate: {
directory: "reference/layouts",
},
},
{
label: "Window",
collapsed: true,
autogenerate: { directory: "reference/window" },
items: [
{
label: "Primitive Types",
slug: "reference/primitive-types",
},
{
label: "Common Properties & Callbacks",
slug: "reference/common",
},
{
label: "Colors & Brushes",
slug: "reference/colors-and-brushes",
},
],
},
{
label: "Std-Widgets",
label: "Visual Elements",
collapsed: true,
items: [
"reference/std-widgets/overview",
"reference/std-widgets/style",
{
label: "UI Widgets",
label: "Basic Elements",
autogenerate: {
directory: "reference/elements",
},
},
{
label: "Gestures",
autogenerate: {
directory: "reference/gestures",
},
},
{
label: "Keyboard Input",
items: [
"reference/std-widgets/aboutslint",
"reference/std-widgets/button",
"reference/std-widgets/checkbox",
"reference/std-widgets/combobox",
"reference/std-widgets/datepicker",
"reference/std-widgets/lineedit",
"reference/std-widgets/listview",
"reference/std-widgets/progressindicator",
"reference/std-widgets/scrollview",
"reference/std-widgets/slider",
"reference/std-widgets/spinbox",
"reference/std-widgets/spinner",
"reference/std-widgets/standardbutton",
"reference/std-widgets/standardlistview",
"reference/std-widgets/standardtableview",
"reference/std-widgets/switch",
"reference/std-widgets/tabwidget",
"reference/std-widgets/textedit",
"reference/std-widgets/timepicker",
{
label: "Overview",
slug: "reference/keyboard-input/overview",
},
{
label: "HorizontalLayout",
slug: "reference/keyboard-input/focusscope",
},
{
label: "VerticalLayout",
slug: "reference/keyboard-input/textinput",
},
],
},
{
label: "Layout Widgets",
label: "Layouts",
items: [
"reference/std-widgets/gridbox",
"reference/std-widgets/groupbox",
"reference/std-widgets/horizontalbox",
"reference/std-widgets/verticalbox",
{
label: "Overview",
slug: "reference/layouts/overview",
},
{
label: "GridLayout",
slug: "reference/layouts/gridlayout",
},
{
label: "HorizontalLayout",
slug: "reference/layouts/horizontallayout",
},
{
label: "VerticalLayout",
slug: "reference/layouts/verticallayout",
},
],
},
{
label: "Window",
autogenerate: {
directory: "reference/window",
},
},
],
},
{
label: "Global Structs and Enums",
slug: "reference/global-structs-enums",
label: "Globals",
collapsed: true,
items: [
{
label: "Global Structs and Enums",
slug: "reference/global-structs-enums",
},
{
label: "Global Functions",
collapsed: true,
items: [
{
label: "Math",
slug: "reference/global-functions/math",
},
{
label: "animation-tick() / debug()",
slug: "reference/global-functions/builtinfunctions",
},
],
},
],
},
{
label: "Global Functions",
label: "Std-Widgets",
collapsed: true,
items: [
"reference/std-widgets/overview",
"reference/std-widgets/style",
{
label: "Basic Widgets",
autogenerate: {
directory:
"reference/std-widgets/basic-widgets",
},
},
{
label: "Views",
autogenerate: {
directory:
"reference/std-widgets/views",
},
},
{
label: "Math",
slug: "reference/global-functions/math",
label: "Layouts",
autogenerate: {
directory:
"reference/std-widgets/layouts",
},
},
{
label: "animation-tick() / debug()",
slug: "reference/global-functions/builtinfunctions",
label: "Misc",
autogenerate: {
directory:
"reference/std-widgets/misc",
},
},
],
},
Expand Down Expand Up @@ -351,7 +398,6 @@ export default defineConfig({
]),
starlightLinksValidator({
errorOnLocalLinks: false,
exclude: ["**/index.mdx"],
}),
],
social: {
Expand Down
2 changes: 1 addition & 1 deletion docs/astro/ec.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function languageLabel() {
inset-inline-end: calc(var(--ec-brdWd) + var(--ec-uiPadInl) );
direction: ltr;
font-size: 0.8rem;
color: #767676;
color:rgb(169, 169, 169);
opacity: 1;
transition: opacity 0.3s;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- Copyright © SixtyFPS GmbH <info@slint.dev> ; SPDX-License-Identifier: MIT -->
title: Winit Backend
description: Winit Backend
next: false
---

The Winit backend uses the [winit](https://docs.rs/winit/latest/winit/) library to interact with the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
<!-- Copyright © SixtyFPS GmbH <info@slint.dev> ; SPDX-License-Identifier: MIT -->
// cSpell: ignore msgfmt msgctx msginit poedit Lokalize Transifex
title: Translations
description: Translations
---

<!-- cSpell: ignore msgfmt msgctx msginit poedit Lokalize Transifex -->
import { Tabs, TabItem, FileTree } from '@astrojs/starlight/components';

Slint's translation infrastructure makes your application available in different languages.

Expand Down Expand Up @@ -139,9 +140,14 @@ Slint can use the [Gettext](https://www.gnu.org/software/gettext/) library to lo

Gettext expects translation files - called message catalogs - in following directory hierarchy:

```
dir_name/locale/LC_MESSAGES/domain_name.mo
```
<FileTree>

- dir_name/
- locale/ e.g. `fr`, `en`, `de`, etc
- LC_MESSAGES/
- domain_name.mo
</FileTree>


- `dir_name`: the base directory that you can choose freely.
- `locale`: The name of the user's locale for a given target language, such as `fr` for French, or `de` for German.
Expand All @@ -150,38 +156,13 @@ dir_name/locale/LC_MESSAGES/domain_name.mo

- `domain_name`: Selected based on the programming language you're using Slint with.

:::info

:::tip[Tip]
Read the [Gettext documentation](https://www.gnu.org/software/gettext/manual/gettext.html#Locating-Catalogs) for more information.

:::

### Select and Load Translations with Rust

First, enable the `gettext` feature of the `slint` crate in the `features` section to gain access to the translations API
and activate run-time translation support.

Next, use the `slint::init_translations!` macro to specify the base location of your `.mo` files. This is
the `dir_name` in the scheme of the previous section. Slint expects the `.mo` files to be in the
corresponding sub-directories and their file name - `domain_name` - must match the package name
in your `Cargo.toml`. This is often the same as the crate name.

For example:

```rust
slint::init_translations!(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/"));
```

For example, if your `Cargo.toml` contains the following lines and the user's locale is `fr`:

```toml
[package]
name = "gallery"
```

With these settings, Slint looks for `gallery.mo` in the `lang/fr/LC_MESSAGES/gallery.mo`.

### Select and Load Translations with C++
### Select and Load Translations
<Tabs syncKey="dev-language">
<TabItem label="C++" icon="cpp">

First, enable the `SLINT_FEATURE_GETTEXT` cmake option when compiling Slint to gain access to
the translations API and activate run-time translation support.
Expand Down Expand Up @@ -220,6 +201,33 @@ int main()

For example, if you're using the above and the user's locale is `fr`,
Slint looks for `my_application.mo` in the `lang/fr/LC_MESSAGES/` directory.
</TabItem>
<TabItem label="Rust" icon="rust">

First, enable the `gettext` feature of the `slint` crate in the `features` section to gain access to the translations API
and activate run-time translation support.

Next, use the `slint::init_translations!` macro to specify the base location of your `.mo` files. This is
the `dir_name` in the scheme of the previous section. Slint expects the `.mo` files to be in the
corresponding sub-directories and their file name - `domain_name` - must match the package name
in your `Cargo.toml`. This is often the same as the crate name.

For example:

```rust
slint::init_translations!(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/"));
```

For example, if your `Cargo.toml` contains the following lines and the user's locale is `fr`:

```toml
[package]
name = "gallery"
```

With these settings, Slint looks for `gallery.mo` in the `lang/fr/LC_MESSAGES/gallery.mo`.
</TabItem>
</Tabs>

## Bundled Translations

Expand All @@ -233,24 +241,30 @@ Translation files should be organized in the following hierarchy:
path/<lang>/LC_MESSAGES/<domain>.po
```

### Bundling with Rust
### Bundling
<Tabs syncKey="dev-language">
<TabItem label="C++" icon="cpp">
Set the `SLINT_BUNDLE_TRANSLATIONS` property in CMake:

```cmake
set_property(TARGET my_application PROPERTY SLINT_BUNDLE_TRANSLATIONS "${CMAKE_CURRENT_SOURCE_DIR}/lang")
```

the `<domain>` is the cmake target name.

</TabItem>
<TabItem label="Rust" icon="rust">

```rust
let config = slint_build::CompilerConfiguration::new()
.with_bundled_translations("path/to/translations");
```

The `<domain>` is the crate name.
</TabItem>
</Tabs>

### Bundling with C++

Set the `SLINT_BUNDLE_TRANSLATIONS` property in CMake:

```cmake
set_property(TARGET my_application PROPERTY SLINT_BUNDLE_TRANSLATIONS "${CMAKE_CURRENT_SOURCE_DIR}/lang")
```

the `<domain>` is the cmake target name.

### Selecting a Translation

Expand Down
Loading

0 comments on commit f6da11e

Please sign in to comment.