blob: 2ea70bd3d06cfa94396b7187bb0bf4cf7cfa9c24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# lupdate.lua
lupdate.lua allows you to update your .ts files from your .lua files.
## Installation
You need to install lua, luarocks and luafilesystem.
On macOS:
```sh
$ brew install lua luarocks
$ luarocks install luafilesystem
```
For other platforms see: [Download luarocks](https://github.com/luarocks/luarocks/wiki/Download)
## Usage
You need to add a "languages" key to your plugin spec file.
```lua
--- In your plugin.lua file
return {
Name = "MyPlugin",
Version = "1.0.0",
languages = {"de", "fr", "en"},
--- ....
} --[[@as QtcPlugin]]
```
Then run the lupdate.lua script in your plugin directory. Make sure that lupdate is in your PATH.
```sh
$ # export PATH=$PATH:/path/to/Qt/bin
$ cd my-plugin
$ lua lupdate.lua
```
Once you have the .ts files you can use Qt Linguist to translate your strings.
After translation you can run lrelease to generate the .qm files.
```sh
$ cd ts
$ lrelease *.ts
```
## Background
Since Qt's lupdate does not currently support lua files, the lupdate.lua script uses a trick
to make it work. It creates a temporary file for each lua file and adds a comment at the start
and end of the file:
```lua
--- class Plugin { Q_OBJECT
print(tr("Hello World"))
--- }
```
That way lupdate thinks its inside a C++ Plugin and takes as context the name of the class, in this case "Plugin".
It then starts the actual lupdate tool to update the .ts files.
|