slint/tests/cases/expr/tr.slint
Aurindam Jana 3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00

39 lines
1.4 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
export component TestCase {
property <int> int_value: 42;
property <string> t1: @tr("Hello World{{}}.");
property <string> t2: @tr("Hello {}.", "World");
property <string> t3: @tr("{} Hello {}", int_value, "World");
property <string> t4: @tr("{1} Hello {0}🌍", @tr("World"), int_value + 1);
property <string> c1: @tr("Context" => "xx{0}xx", @tr("CC" => "aa"));
function make_plural1(xx: int, yy: string) -> string { return @tr("there is one file in my {}" | "there are {n} files in my {}" % xx, yy); }
function make_plural2(xx: int) -> string { return @tr("Ctx=>" => "xx{n}xx" | "yy" % xx); }
out property <bool> test: t1 == "Hello World{}." && t2 == "Hello World." && t3 == "42 Hello World" && t4 == "43 Hello World🌍"
&& c1 == "xxaaxx"
&& make_plural1(1, @tr("Plop")) == "there is one file in my Plop" && make_plural1(10, @tr("Flop")) == "there are 10 files in my Flop"
&& make_plural2(1) == "xx1xx" && make_plural2(-999) == "yy";
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_test());
```
```rust
let instance = TestCase::new().unwrap();
assert!(instance.get_test());
```
```js
var instance = new slint.TestCase({});
assert(instance.test);
```
*/