Add KSY for QM
This commit is contained in:
parent
dae027e21d
commit
1a2e633b0e
|
@ -0,0 +1,200 @@
|
||||||
|
meta:
|
||||||
|
id: qm
|
||||||
|
title: Compiled Qt translations
|
||||||
|
application: Qt
|
||||||
|
file-extension: qm
|
||||||
|
license: GPL-3.0-or-later
|
||||||
|
encoding: utf-8
|
||||||
|
endian: be
|
||||||
|
seq:
|
||||||
|
- id: magic
|
||||||
|
contents: [0x3C, 0xB8, 0x64, 0x18,
|
||||||
|
0xCA, 0xEF, 0x9C, 0x95,
|
||||||
|
0xCD, 0x21, 0x1C, 0xBF,
|
||||||
|
0x60, 0xA1, 0xBD, 0xDD]
|
||||||
|
- id: blocks
|
||||||
|
type: block
|
||||||
|
repeat: eos
|
||||||
|
types:
|
||||||
|
block:
|
||||||
|
-webide-representation: '{tag}'
|
||||||
|
seq:
|
||||||
|
- id: tag
|
||||||
|
type: u1
|
||||||
|
enum: block_tag
|
||||||
|
- id: length
|
||||||
|
type: u4
|
||||||
|
- id: contents
|
||||||
|
type:
|
||||||
|
switch-on: tag
|
||||||
|
cases:
|
||||||
|
'block_tag::contexts': contexts
|
||||||
|
'block_tag::hashes': hashes
|
||||||
|
'block_tag::messages': messages
|
||||||
|
'block_tag::numerus_rules': numerus_rules
|
||||||
|
'block_tag::dependencies': dependencies
|
||||||
|
'block_tag::language': language
|
||||||
|
size: length
|
||||||
|
contexts:
|
||||||
|
seq:
|
||||||
|
- id: length
|
||||||
|
type: u2
|
||||||
|
- id: offsets
|
||||||
|
type: u2
|
||||||
|
repeat: expr
|
||||||
|
repeat-expr: length
|
||||||
|
- id: contexts
|
||||||
|
type: context
|
||||||
|
repeat: eos
|
||||||
|
types:
|
||||||
|
context:
|
||||||
|
-webide-representation: '{context}'
|
||||||
|
seq:
|
||||||
|
- id: length
|
||||||
|
type: u1
|
||||||
|
- id: context
|
||||||
|
type: str
|
||||||
|
size: length
|
||||||
|
- type: u1
|
||||||
|
if: length % 2 == 0
|
||||||
|
hashes:
|
||||||
|
seq:
|
||||||
|
- id: hashes
|
||||||
|
type: hash
|
||||||
|
repeat: eos
|
||||||
|
types:
|
||||||
|
hash:
|
||||||
|
-webide-representation: '{hash}'
|
||||||
|
seq:
|
||||||
|
- id: hash
|
||||||
|
type: u4
|
||||||
|
- id: offset
|
||||||
|
type: u4
|
||||||
|
messages:
|
||||||
|
seq:
|
||||||
|
- id: messages
|
||||||
|
type: message
|
||||||
|
repeat: eos
|
||||||
|
types:
|
||||||
|
message:
|
||||||
|
seq:
|
||||||
|
- id: attributes
|
||||||
|
type: attribute
|
||||||
|
repeat: until
|
||||||
|
repeat-until: '_.tag == attribute_tag::end'
|
||||||
|
attribute:
|
||||||
|
-webide-representation: '{tag}'
|
||||||
|
seq:
|
||||||
|
- id: tag
|
||||||
|
type: u1
|
||||||
|
enum: attribute_tag
|
||||||
|
- id: contents
|
||||||
|
type:
|
||||||
|
switch-on: tag
|
||||||
|
cases:
|
||||||
|
'attribute_tag::end': end
|
||||||
|
'attribute_tag::source_text_utf16': utf16string
|
||||||
|
'attribute_tag::translation': utf16string
|
||||||
|
'attribute_tag::context_utf16': utf16string
|
||||||
|
'attribute_tag::hash': hash
|
||||||
|
'attribute_tag::source_text': string
|
||||||
|
'attribute_tag::context': string
|
||||||
|
'attribute_tag::comment': string
|
||||||
|
'attribute_tag::obsolete_2': obsolete_2
|
||||||
|
types:
|
||||||
|
end: {}
|
||||||
|
utf16string:
|
||||||
|
-webide-representation: '{text}'
|
||||||
|
seq:
|
||||||
|
- id: length
|
||||||
|
type: s4
|
||||||
|
- id: text
|
||||||
|
type: str
|
||||||
|
encoding: utf-16be
|
||||||
|
size: length
|
||||||
|
string:
|
||||||
|
-webide-representation: '{text}'
|
||||||
|
seq:
|
||||||
|
- id: length
|
||||||
|
type: u4
|
||||||
|
- id: text
|
||||||
|
type: str
|
||||||
|
size: length
|
||||||
|
hash:
|
||||||
|
-webide-representation: '{hash}'
|
||||||
|
seq:
|
||||||
|
- id: hash
|
||||||
|
type: u4
|
||||||
|
obsolete_2:
|
||||||
|
-webide-representation: '{unknown_byte}'
|
||||||
|
seq:
|
||||||
|
- id: unknown_byte
|
||||||
|
type: u1
|
||||||
|
numerus_rules:
|
||||||
|
seq:
|
||||||
|
- id: components
|
||||||
|
type: component
|
||||||
|
repeat: eos
|
||||||
|
types:
|
||||||
|
component:
|
||||||
|
-webide-representation: '{operator}'
|
||||||
|
seq:
|
||||||
|
- id: component
|
||||||
|
type: u1
|
||||||
|
- id: param1
|
||||||
|
type: u1
|
||||||
|
if: operator.to_i <= 0x04
|
||||||
|
- id: param2
|
||||||
|
type: u1
|
||||||
|
if: operator == operator::between
|
||||||
|
instances:
|
||||||
|
is_arithmetic:
|
||||||
|
value: component & 0x80 != 0x80
|
||||||
|
not:
|
||||||
|
value: is_arithmetic and component & 0x08 == 0x08
|
||||||
|
mod10:
|
||||||
|
value: is_arithmetic and component & 0x10 == 0x10
|
||||||
|
mod100:
|
||||||
|
value: is_arithmetic and component & 0x20 == 0x20
|
||||||
|
leading1000:
|
||||||
|
value: is_arithmetic and component & 0x40 == 0x40
|
||||||
|
operator:
|
||||||
|
value: is_arithmetic ? component & 0b111 : component
|
||||||
|
enum: operator
|
||||||
|
enums:
|
||||||
|
operator:
|
||||||
|
0x01: equality
|
||||||
|
0x02: less_than
|
||||||
|
0x03: less_or_equal
|
||||||
|
0x04: between
|
||||||
|
0xfd: and
|
||||||
|
0xfe: or
|
||||||
|
0xff: new_rule
|
||||||
|
dependencies:
|
||||||
|
seq:
|
||||||
|
- id: dependencies
|
||||||
|
type: strz
|
||||||
|
repeat: eos
|
||||||
|
language:
|
||||||
|
-webide-representation: '{language}'
|
||||||
|
seq:
|
||||||
|
- id: language
|
||||||
|
type: strz
|
||||||
|
enums:
|
||||||
|
block_tag:
|
||||||
|
0x2F: contexts
|
||||||
|
0x42: hashes
|
||||||
|
0x69: messages
|
||||||
|
0x88: numerus_rules
|
||||||
|
0x96: dependencies
|
||||||
|
0xa7: language
|
||||||
|
attribute_tag:
|
||||||
|
1: end
|
||||||
|
2: source_text_utf16
|
||||||
|
3: translation
|
||||||
|
4: context_utf16
|
||||||
|
5: hash
|
||||||
|
6: source_text
|
||||||
|
7: context
|
||||||
|
8: comment
|
||||||
|
9: obsolete_2
|
832
content/qm.md
832
content/qm.md
|
@ -1,415 +1,417 @@
|
||||||
---
|
---
|
||||||
title: Compiled Qt translations
|
title: Compiled Qt translations
|
||||||
---
|
---
|
||||||
|
|
||||||
The compiled Qt translation file (`*.qm`) is generated by [Qt Linguist][qt-linguist] and holds all the translation data that a Qt application can use for a single language.
|
The compiled Qt translation file (`*.qm`) is generated by [Qt Linguist][qt-linguist] and holds all the translation data that a Qt application can use for a single language.
|
||||||
|
|
||||||
## Conventions used in this document
|
I have written [a Kaitai Struct YAML schema](./qm.ksy) for this format.
|
||||||
|
|
||||||
* When left unspecified, a number is signed.
|
## Conventions used in this document
|
||||||
* When left unspecified, a string is encoded in UTF-8.
|
|
||||||
* Strings with a defined size may contain null bytes. Strings without a defined size are null-terminated.
|
* When left unspecified, a number is signed.
|
||||||
|
* When left unspecified, a string is encoded in UTF-8.
|
||||||
## Structure
|
* Strings with a defined size may contain null bytes. Strings without a defined size are null-terminated.
|
||||||
|
|
||||||
The file starts with 16 bytes of a magic header, then is structured in blocks. The number of blocks is only determined by reading them until t he end of the file.
|
## Structure
|
||||||
|
|
||||||
```svgbob
|
The file starts with 16 bytes of a magic header, then is structured in blocks. The number of blocks is only determined by reading them until t he end of the file.
|
||||||
+-------+---------+---------+-...-+---------+
|
|
||||||
| Magic | Block 1 | Block 2 | | Block N |
|
```svgbob
|
||||||
+-------+---------+---------+-...-+---------+
|
+-------+---------+---------+-...-+---------+
|
||||||
```
|
| Magic | Block 1 | Block 2 | | Block N |
|
||||||
|
+-------+---------+---------+-...-+---------+
|
||||||
The magic header is as follows:
|
```
|
||||||
|
|
||||||
```
|
The magic header is as follows:
|
||||||
3C B8 64 18 CA EF 9C 95 CD 21 1C BF 60 A1 BD DD
|
|
||||||
```
|
```
|
||||||
|
3C B8 64 18 CA EF 9C 95 CD 21 1C BF 60 A1 BD DD
|
||||||
### Block
|
```
|
||||||
|
|
||||||
```svgbob
|
### Block
|
||||||
Block:
|
|
||||||
+-----+--------------+----------------+
|
```svgbob
|
||||||
| Tag | Block length | Block contents |
|
Block:
|
||||||
+-----+--------------+----------------+
|
+-----+--------------+----------------+
|
||||||
```
|
| Tag | Block length | Block contents |
|
||||||
|
+-----+--------------+----------------+
|
||||||
Tag (unsigned byte)
|
```
|
||||||
: One of the following:
|
|
||||||
|
Tag (unsigned byte)
|
||||||
0x2F
|
: One of the following:
|
||||||
: Contexts block
|
|
||||||
|
0x2F
|
||||||
0x42
|
: Contexts block
|
||||||
: Hashes block
|
|
||||||
|
0x42
|
||||||
0x69
|
: Hashes block
|
||||||
: Messages block
|
|
||||||
|
0x69
|
||||||
0x88
|
: Messages block
|
||||||
: Numerus Rules block
|
|
||||||
|
0x88
|
||||||
0x96
|
: Numerus Rules block
|
||||||
: Dependencies block
|
|
||||||
|
0x96
|
||||||
0xA7
|
: Dependencies block
|
||||||
: Language block
|
|
||||||
|
0xA7
|
||||||
Block length (unsigned int32)
|
: Language block
|
||||||
: The size of the block's contents, measured in bytes.
|
|
||||||
|
Block length (unsigned int32)
|
||||||
Block contents
|
: The size of the block's contents, measured in bytes.
|
||||||
: The contents of each block depend on the tag.
|
|
||||||
|
Block contents
|
||||||
There should only be one of each block tag in a single file. There should always be a Hashes block.
|
: The contents of each block depend on the tag.
|
||||||
|
|
||||||
### Contexts block
|
There should only be one of each block tag in a single file. There should always be a Hashes block.
|
||||||
|
|
||||||
When the QM file has been generated using `lrelease -compress`, the messages in the file are compressed by their common prefixes: their hash, their hash and context, or their hash, context and source text. The context prefix will be stored in a hash table in the Contexts block, and the context and source text will only be mentioned in the attributes of the first message that has this context or source text.
|
### Contexts block
|
||||||
|
|
||||||
This block cannot exceed 131072 bytes in size; if this limit is exceeded, `lrelease` acts like `-compress` was not set and the contexts will be saved in the Messages block.
|
When the QM file has been generated using `lrelease -compress`, the messages in the file are compressed by their common prefixes: their hash, their hash and context, or their hash, context and source text. The context prefix will be stored in a hash table in the Contexts block, and the context and source text will only be mentioned in the attributes of the first message that has this context or source text.
|
||||||
|
|
||||||
```svgbob
|
This block cannot exceed 131072 bytes in size; if this limit is exceeded, `lrelease` acts like `-compress` was not set and the contexts will be saved in the Messages block.
|
||||||
Block contents (Contexts block):
|
|
||||||
+------------+--------------+
|
```svgbob
|
||||||
| Hash table | Context pool |
|
Block contents (Contexts block):
|
||||||
+------------+--------------+
|
+------------+--------------+
|
||||||
```
|
| Hash table | Context pool |
|
||||||
|
+------------+--------------+
|
||||||
#### Hash table
|
```
|
||||||
|
|
||||||
The hash table maps a hash of the context to an offset where the context might be found in the context pool.
|
#### Hash table
|
||||||
|
|
||||||
```svgbob
|
The hash table maps a hash of the context to an offset where the context might be found in the context pool.
|
||||||
Hash table:
|
|
||||||
+--------+----------+----------+-...-+----------+
|
```svgbob
|
||||||
| Length | Offset 1 | Offset 2 | | Offset N |
|
Hash table:
|
||||||
+--------+----------+----------+-...-+----------+
|
+--------+----------+----------+-...-+----------+
|
||||||
```
|
| Length | Offset 1 | Offset 2 | | Offset N |
|
||||||
|
+--------+----------+----------+-...-+----------+
|
||||||
Length (unsigned int16)
|
```
|
||||||
: Length of the hash table.
|
|
||||||
|
Length (unsigned int16)
|
||||||
Offset (unsigned int16)
|
: Length of the hash table.
|
||||||
: Offset, in bytes, within the context pool, where the context's string should be seeked. Note that the context string probably will not be found at this offset; it will be found further away. All offsets should be multiples of 2. An offset of 0 means this hash does not exist in this file.
|
|
||||||
|
Offset (unsigned int16)
|
||||||
Note that the hash table's size may exceed the actual amount of contexts, resulting in many offsets being set to zero.
|
: Offset, in bytes, within the context pool, where the context's string should be seeked. Note that the context string probably will not be found at this offset; it will be found further away. All offsets should be multiples of 2. An offset of 0 means this hash does not exist in this file.
|
||||||
|
|
||||||
#### Context pool
|
Note that the hash table's size may exceed the actual amount of contexts, resulting in many offsets being set to zero.
|
||||||
|
|
||||||
```svgbob
|
#### Context pool
|
||||||
Context pool:
|
|
||||||
+--------+-----------+-----------+-...-+-----------+
|
```svgbob
|
||||||
| 0x0000 | Context 1 | Context 2 | | Context N |
|
Context pool:
|
||||||
+--------+-----------+-----------+-...-+-----------+
|
+--------+-----------+-----------+-...-+-----------+
|
||||||
```
|
| 0x0000 | Context 1 | Context 2 | | Context N |
|
||||||
|
+--------+-----------+-----------+-...-+-----------+
|
||||||
As offset 0 in the hash table means that the context does not exist in this file, the context at offset 0 in the context pool is set to `0x0000`.
|
```
|
||||||
|
|
||||||
#### Context
|
As offset 0 in the hash table means that the context does not exist in this file, the context at offset 0 in the context pool is set to `0x0000`.
|
||||||
|
|
||||||
```svgbob
|
#### Context
|
||||||
Context:
|
|
||||||
+--------+---------+---------+
|
```svgbob
|
||||||
| Length | Context | Padding |
|
Context:
|
||||||
+--------+---------+---------+
|
+--------+---------+---------+
|
||||||
```
|
| Length | Context | Padding |
|
||||||
|
+--------+---------+---------+
|
||||||
Length (unsigned byte)
|
```
|
||||||
: The length of the context string in bytes.
|
|
||||||
|
Length (unsigned byte)
|
||||||
Context (string)
|
: The length of the context string in bytes.
|
||||||
: The context name, truncated to up to 255 characters.
|
|
||||||
|
Context (string)
|
||||||
Padding (optional unsigned byte)
|
: The context name, truncated to up to 255 characters.
|
||||||
: An extra null byte (`0x00`) may be added to ensure the size of this whole block is a multiple of 2.
|
|
||||||
|
Padding (optional unsigned byte)
|
||||||
### Hashes block
|
: An extra null byte (`0x00`) may be added to ensure the size of this whole block is a multiple of 2.
|
||||||
|
|
||||||
The Hashes block holds pointers
|
### Hashes block
|
||||||
|
|
||||||
```svgbob
|
The Hashes block holds pointers
|
||||||
Block contents (Hashes block):
|
|
||||||
+--------+--------+-...-+--------+
|
```svgbob
|
||||||
| Hash 1 | Hash 2 | | Hash N |
|
Block contents (Hashes block):
|
||||||
+--------+--------+-...-+--------+
|
+--------+--------+-...-+--------+
|
||||||
```
|
| Hash 1 | Hash 2 | | Hash N |
|
||||||
|
+--------+--------+-...-+--------+
|
||||||
#### Hash
|
```
|
||||||
|
|
||||||
```svgbob
|
#### Hash
|
||||||
Hash:
|
|
||||||
+------+--------+
|
```svgbob
|
||||||
| Hash | Offset |
|
Hash:
|
||||||
+------+--------+
|
+------+--------+
|
||||||
```
|
| Hash | Offset |
|
||||||
|
+------+--------+
|
||||||
Hash (unsigned int32)
|
```
|
||||||
: A hash of the bytes represented by the concatenation of the source text and of the comment strings of a single message. This can be used for faster lookup of translations, since the source text and comment are defined in the source code.
|
|
||||||
|
Hash (unsigned int32)
|
||||||
Offset (unsigned int32)
|
: A hash of the bytes represented by the concatenation of the source text and of the comment strings of a single message. This can be used for faster lookup of translations, since the source text and comment are defined in the source code.
|
||||||
: Offset, in bytes, of the start of the message designated by this hash, starting from the beginning of the contents of the Messages block.
|
|
||||||
|
Offset (unsigned int32)
|
||||||
### Messages block
|
: Offset, in bytes, of the start of the message designated by this hash, starting from the beginning of the contents of the Messages block.
|
||||||
|
|
||||||
```svgbob
|
### Messages block
|
||||||
Block contents (Messages block):
|
|
||||||
+-------------+-------------+-...-+-------------+
|
```svgbob
|
||||||
| Attribute 1 | Attribute 2 | | Attribute N |
|
Block contents (Messages block):
|
||||||
+-------------+-------------+-...-+-------------+
|
+-------------+-------------+-...-+-------------+
|
||||||
```
|
| Attribute 1 | Attribute 2 | | Attribute N |
|
||||||
|
+-------------+-------------+-...-+-------------+
|
||||||
There is no exact structure for a message: attributes should be read into a list until an End attribute is reached, meaning all the attributes in this list are part of the message.
|
```
|
||||||
|
|
||||||
Messages are usually looked up using the Hashes block first, rather than reading through the Messages block sequentially.
|
There is no exact structure for a message: attributes should be read into a list until an End attribute is reached, meaning all the attributes in this list are part of the message.
|
||||||
|
|
||||||
#### Attribute
|
Messages are usually looked up using the Hashes block first, rather than reading through the Messages block sequentially.
|
||||||
|
|
||||||
Attributes have no official name; they have been named attributes as they are the various properties of a message.
|
#### Attribute
|
||||||
|
|
||||||
```svgbob
|
Attributes have no official name; they have been named attributes as they are the various properties of a message.
|
||||||
Attribute:
|
|
||||||
+-----+--------------------+
|
```svgbob
|
||||||
| Tag | Attribute contents |
|
Attribute:
|
||||||
+-----+--------------------+
|
+-----+--------------------+
|
||||||
```
|
| Tag | Attribute contents |
|
||||||
|
+-----+--------------------+
|
||||||
Tag (unsigned byte)
|
```
|
||||||
: One of the following:
|
|
||||||
|
Tag (unsigned byte)
|
||||||
1. End
|
: One of the following:
|
||||||
2. Source text (UTF-16)
|
|
||||||
3. Translation
|
1. End
|
||||||
4. Context (UTF-16)
|
2. Source text (UTF-16)
|
||||||
5. Hash (obsolete)
|
3. Translation
|
||||||
6. Source text
|
4. Context (UTF-16)
|
||||||
7. Context
|
5. Hash (obsolete)
|
||||||
8. Comment
|
6. Source text
|
||||||
9. Unknown (obsolete)
|
7. Context
|
||||||
|
8. Comment
|
||||||
Attribute contents
|
9. Unknown (obsolete)
|
||||||
: The contents of each attribute depend on the tag.
|
|
||||||
|
Attribute contents
|
||||||
* There should only be one Comment attribute.
|
: The contents of each attribute depend on the tag.
|
||||||
* There should only be one of either a Context or a Context (UTF-16) attribute.
|
|
||||||
* There should only be one of either a Source text or a Source text (UTF-16) attribute.
|
* There should only be one Comment attribute.
|
||||||
* There may be zero or more Translation attributes.
|
* There should only be one of either a Context or a Context (UTF-16) attribute.
|
||||||
* There must be one End attribute.
|
* There should only be one of either a Source text or a Source text (UTF-16) attribute.
|
||||||
|
* There may be zero or more Translation attributes.
|
||||||
#### End attribute
|
* There must be one End attribute.
|
||||||
|
|
||||||
Attributes with the `End` tag signify the end of the message. They have no contents.
|
#### End attribute
|
||||||
|
|
||||||
#### Source text (UTF-16) attribute
|
Attributes with the `End` tag signify the end of the message. They have no contents.
|
||||||
|
|
||||||
```svgbob
|
#### Source text (UTF-16) attribute
|
||||||
Attribute contents (Source text (UTF-16) attribute):
|
|
||||||
+--------+-------------+
|
```svgbob
|
||||||
| Length | Source text |
|
Attribute contents (Source text (UTF-16) attribute):
|
||||||
+--------+-------------+
|
+--------+-------------+
|
||||||
```
|
| Length | Source text |
|
||||||
|
+--------+-------------+
|
||||||
Length (int32)
|
```
|
||||||
: Length of the string, in bytes. Should always be a multiple of 2, unless it is negative, which indicates an empty string.
|
|
||||||
|
Length (int32)
|
||||||
Source text (UTF-16 string)
|
: Length of the string, in bytes. Should always be a multiple of 2, unless it is negative, which indicates an empty string.
|
||||||
: The source text for this message. If the translations are ID-based, this will be the ID of this translation, and the context and comment will always be empty.
|
|
||||||
|
Source text (UTF-16 string)
|
||||||
#### Translation attribute
|
: The source text for this message. If the translations are ID-based, this will be the ID of this translation, and the context and comment will always be empty.
|
||||||
|
|
||||||
```svgbob
|
#### Translation attribute
|
||||||
Attribute contents (Translation attribute):
|
|
||||||
+--------+-------------+
|
```svgbob
|
||||||
| Length | Translation |
|
Attribute contents (Translation attribute):
|
||||||
+--------+-------------+
|
+--------+-------------+
|
||||||
```
|
| Length | Translation |
|
||||||
|
+--------+-------------+
|
||||||
Length (int32)
|
```
|
||||||
: Length of the string, in bytes. Should always be a multiple of 2, unless it is negative, which indicates an empty string.
|
|
||||||
|
Length (int32)
|
||||||
Translation (UTF-16 string)
|
: Length of the string, in bytes. Should always be a multiple of 2, unless it is negative, which indicates an empty string.
|
||||||
: The translated text for this message.
|
|
||||||
|
Translation (UTF-16 string)
|
||||||
#### Context (UTF-16) attribute
|
: The translated text for this message.
|
||||||
|
|
||||||
```svgbob
|
#### Context (UTF-16) attribute
|
||||||
Attribute contents (Context (UTF-16) attribute):
|
|
||||||
+--------+---------+
|
```svgbob
|
||||||
| Length | Context |
|
Attribute contents (Context (UTF-16) attribute):
|
||||||
+--------+---------+
|
+--------+---------+
|
||||||
```
|
| Length | Context |
|
||||||
|
+--------+---------+
|
||||||
Length (int32)
|
```
|
||||||
: Length of the string, in bytes. Should always be a multiple of 2, unless it is negative, which indicates an empty string.
|
|
||||||
|
Length (int32)
|
||||||
Context (UTF-16 string)
|
: Length of the string, in bytes. Should always be a multiple of 2, unless it is negative, which indicates an empty string.
|
||||||
: Name of the context in which this message appears. This is usually a Qt class name.
|
|
||||||
|
Context (UTF-16 string)
|
||||||
#### Hash attribute
|
: Name of the context in which this message appears. This is usually a Qt class name.
|
||||||
|
|
||||||
```svgbob
|
#### Hash attribute
|
||||||
Attribute contents (Hash attribute):
|
|
||||||
+------+
|
```svgbob
|
||||||
| Hash |
|
Attribute contents (Hash attribute):
|
||||||
+------+
|
+------+
|
||||||
```
|
| Hash |
|
||||||
|
+------+
|
||||||
Hash (uint32)
|
```
|
||||||
: Hash of the message. This is now only stored in the separate Hashes block.
|
|
||||||
|
Hash (uint32)
|
||||||
#### Source text attribute
|
: Hash of the message. This is now only stored in the separate Hashes block.
|
||||||
|
|
||||||
```svgbob
|
#### Source text attribute
|
||||||
Attribute contents (Source text attribute):
|
|
||||||
+--------+-------------+
|
```svgbob
|
||||||
| Length | Source text |
|
Attribute contents (Source text attribute):
|
||||||
+--------+-------------+
|
+--------+-------------+
|
||||||
```
|
| Length | Source text |
|
||||||
|
+--------+-------------+
|
||||||
Length (unsigned int32)
|
```
|
||||||
: Length, in bytes, of the source text.
|
|
||||||
|
Length (unsigned int32)
|
||||||
Source text (string)
|
: Length, in bytes, of the source text.
|
||||||
: The source text for this message. If the translations are ID-based, this will be the ID of this translation, and the context and comment will always be empty.
|
|
||||||
|
Source text (string)
|
||||||
#### Context attribute
|
: The source text for this message. If the translations are ID-based, this will be the ID of this translation, and the context and comment will always be empty.
|
||||||
|
|
||||||
```svgbob
|
#### Context attribute
|
||||||
Attribute contents (Context attribute):
|
|
||||||
+--------+---------+
|
```svgbob
|
||||||
| Length | Context |
|
Attribute contents (Context attribute):
|
||||||
+--------+---------+
|
+--------+---------+
|
||||||
```
|
| Length | Context |
|
||||||
|
+--------+---------+
|
||||||
Length (unsigned int32)
|
```
|
||||||
: Length, in bytes, of the context.
|
|
||||||
|
Length (unsigned int32)
|
||||||
Context (string)
|
: Length, in bytes, of the context.
|
||||||
: Name of the context in which this message appears. This is usually a Qt class name.
|
|
||||||
|
Context (string)
|
||||||
#### Comment attribute
|
: Name of the context in which this message appears. This is usually a Qt class name.
|
||||||
|
|
||||||
```svgbob
|
#### Comment attribute
|
||||||
Attribute contents (Comment attribute):
|
|
||||||
+--------+---------+
|
```svgbob
|
||||||
| Length | Comment |
|
Attribute contents (Comment attribute):
|
||||||
+--------+---------+
|
+--------+---------+
|
||||||
```
|
| Length | Comment |
|
||||||
|
+--------+---------+
|
||||||
Length (unsigned int32)
|
```
|
||||||
: Length, in bytes, of the comment.
|
|
||||||
|
Length (unsigned int32)
|
||||||
Comment (string)
|
: Length, in bytes, of the comment.
|
||||||
: A comment left by the developer on this message, meant for disambiguation.
|
|
||||||
|
Comment (string)
|
||||||
https://doc.qt.io/qt-6/i18n-source-translation.html#disambiguation
|
: A comment left by the developer on this message, meant for disambiguation.
|
||||||
|
|
||||||
#### Unknown obsolete attribute
|
https://doc.qt.io/qt-6/i18n-source-translation.html#disambiguation
|
||||||
|
|
||||||
```svgbob
|
#### Unknown obsolete attribute
|
||||||
Attribute contents (Unknown obsolete attribute):
|
|
||||||
+------+
|
```svgbob
|
||||||
| Byte |
|
Attribute contents (Unknown obsolete attribute):
|
||||||
+------+
|
+------+
|
||||||
```
|
| Byte |
|
||||||
|
+------+
|
||||||
Byte (unknown, 1 byte)
|
```
|
||||||
: No definition known.
|
|
||||||
|
Byte (unknown, 1 byte)
|
||||||
This attribute is not found in Qt 2.1.1, and can be found in Qt 2.2.0 as "Obsolete 1". It is now known as "Obsolete 2", because the Hash attribute because "Obsolete 1". I cannot find any other versions between those two version nombers those could tell what this attribute was for.
|
: No definition known.
|
||||||
|
|
||||||
### Numerus Rules block
|
This attribute is not found in Qt 2.1.1, and can be found in Qt 2.2.0 as "Obsolete 1". It is now known as "Obsolete 2", because the Hash attribute because "Obsolete 1". I cannot find any other versions between those two version nombers those could tell what this attribute was for.
|
||||||
|
|
||||||
Defines the rules for automatic pluralization of names in the translation language.
|
### Numerus Rules block
|
||||||
|
|
||||||
```svgbob
|
Defines the rules for automatic pluralization of names in the translation language.
|
||||||
Block contents (Numerus Rules block):
|
|
||||||
+------------------+------------------+-...-+------------------+
|
```svgbob
|
||||||
| Rule component 1 | Rule component 2 | | Rule component N |
|
Block contents (Numerus Rules block):
|
||||||
+------------------+------------------+-...-+------------------+
|
+------------------+------------------+-...-+------------------+
|
||||||
```
|
| Rule component 1 | Rule component 2 | | Rule component N |
|
||||||
|
+------------------+------------------+-...-+------------------+
|
||||||
Rule component (unsigned byte)
|
```
|
||||||
: Either an integer, an arithmetic operator with optional flags, a logical operator or a rule separator.
|
|
||||||
|
Rule component (unsigned byte)
|
||||||
The following arithmetic operators are defined:
|
: Either an integer, an arithmetic operator with optional flags, a logical operator or a rule separator.
|
||||||
|
|
||||||
0x01
|
The following arithmetic operators are defined:
|
||||||
: Equality operator. Followed by one integer X, means "the value is equal to X".
|
|
||||||
|
0x01
|
||||||
0x02
|
: Equality operator. Followed by one integer X, means "the value is equal to X".
|
||||||
: Less than operator. Followed by one integer X, means "the value is less than to X".
|
|
||||||
|
0x02
|
||||||
0x03
|
: Less than operator. Followed by one integer X, means "the value is less than to X".
|
||||||
: Less than or equal operator. Followed by one integer X, means "the value is less than or equal to X".
|
|
||||||
|
0x03
|
||||||
0x04
|
: Less than or equal operator. Followed by one integer X, means "the value is less than or equal to X".
|
||||||
: Between operator. Followed by two integers X and Y, means "the value is between X and Y".
|
|
||||||
|
0x04
|
||||||
The following flags can be applied to the arithmetic operators:
|
: Between operator. Followed by two integers X and Y, means "the value is between X and Y".
|
||||||
|
|
||||||
0x08
|
The following flags can be applied to the arithmetic operators:
|
||||||
: Not.
|
|
||||||
|
0x08
|
||||||
0x10
|
: Not.
|
||||||
: Modulo 10. Get the remainder of the division of the value by 10 before applying the operator.
|
|
||||||
|
0x10
|
||||||
0x20
|
: Modulo 10. Get the remainder of the division of the value by 10 before applying the operator.
|
||||||
: Modulo 100. Get the remainder of the division of the value by 100 before applying the operator.
|
|
||||||
|
0x20
|
||||||
0x40
|
: Modulo 100. Get the remainder of the division of the value by 100 before applying the operator.
|
||||||
: Leading 1000. Meaning is unclear.
|
|
||||||
|
0x40
|
||||||
The following logical operators are defined:
|
: Leading 1000. Meaning is unclear.
|
||||||
|
|
||||||
0xFD
|
The following logical operators are defined:
|
||||||
: And.
|
|
||||||
|
0xFD
|
||||||
0xFE
|
: And.
|
||||||
: Or.
|
|
||||||
|
0xFE
|
||||||
The logical operators apply in their order of definition; "A and B or C and D" means "((A and B) or C) and D".
|
: Or.
|
||||||
|
|
||||||
Finally, the rule separator is defined:
|
The logical operators apply in their order of definition; "A and B or C and D" means "((A and B) or C) and D".
|
||||||
|
|
||||||
0xFF
|
Finally, the rule separator is defined:
|
||||||
: New rule.
|
|
||||||
|
0xFF
|
||||||
The numerus rules are applied to a numeric value to determine whether the name associated with this value should be pluralized. Each rule is applied one after the other, and maps to a different pluralization form. The amount of pluralization forms depends on the language.
|
: New rule.
|
||||||
|
|
||||||
With N pluralization forms, there should be N-1 rules. If the first rule matches, then the second pluralization form is picked. If the second rule matches, then the third pluralization form is picked. If no rule matches, then the first pluralization form is picked -- defined as the singular form.
|
The numerus rules are applied to a numeric value to determine whether the name associated with this value should be pluralized. Each rule is applied one after the other, and maps to a different pluralization form. The amount of pluralization forms depends on the language.
|
||||||
|
|
||||||
### Dependencies block
|
With N pluralization forms, there should be N-1 rules. If the first rule matches, then the second pluralization form is picked. If the second rule matches, then the third pluralization form is picked. If no rule matches, then the first pluralization form is picked -- defined as the singular form.
|
||||||
|
|
||||||
```svgbob
|
### Dependencies block
|
||||||
Block contents (Dependencies block):
|
|
||||||
+--------------+--------------+-...-+--------------+
|
```svgbob
|
||||||
| Dependency 1 | Dependency 2 | | Dependency N |
|
Block contents (Dependencies block):
|
||||||
+--------------+--------------+-...-+--------------+
|
+--------------+--------------+-...-+--------------+
|
||||||
```
|
| Dependency 1 | Dependency 2 | | Dependency N |
|
||||||
|
+--------------+--------------+-...-+--------------+
|
||||||
Dependency (string)
|
```
|
||||||
: The name of a file in the same directory as this one that this file depends on.
|
|
||||||
|
Dependency (string)
|
||||||
### Language block
|
: The name of a file in the same directory as this one that this file depends on.
|
||||||
|
|
||||||
```svgbob
|
### Language block
|
||||||
Block contents (Language block):
|
|
||||||
+---------------+
|
```svgbob
|
||||||
| Language code |
|
Block contents (Language block):
|
||||||
+---------------+
|
+---------------+
|
||||||
```
|
| Language code |
|
||||||
|
+---------------+
|
||||||
Language code (string)
|
```
|
||||||
: Holds the language code of the translation file.
|
|
||||||
|
Language code (string)
|
||||||
## References
|
: Holds the language code of the translation file.
|
||||||
|
|
||||||
* [Qt Linguist Manual][qt-linguist]
|
## References
|
||||||
* [Writing Source Code for Translation](https://doc.qt.io/qt-6/i18n-source-translation.html)
|
|
||||||
* [Source code of the QM reader and writer](https://github.com/qt/qttools/blob/dev/src/linguist/shared/qm.cpp) of Qt Linguist
|
* [Qt Linguist Manual][qt-linguist]
|
||||||
* [Source code of the QTranslator](https://github.com/qt/qtbase/blob/dev/src/corelib/kernel/qtranslator.cpp), which reads from QM files to perform the translations within apps
|
* [Writing Source Code for Translation](https://doc.qt.io/qt-6/i18n-source-translation.html)
|
||||||
* [The Qt archive](https://download.qt.io/archive/qt/), to examine the sources of older versions of Qt. Try reading `src/corelib/kernel/qtranslator.cpp` or `tools/linguist/shared/qm.cpp`.
|
* [Source code of the QM reader and writer](https://github.com/qt/qttools/blob/dev/src/linguist/shared/qm.cpp) of Qt Linguist
|
||||||
|
* [Source code of the QTranslator](https://github.com/qt/qtbase/blob/dev/src/corelib/kernel/qtranslator.cpp), which reads from QM files to perform the translations within apps
|
||||||
[qt-linguist]: https://doc.qt.io/qt-6/qtlinguist-index.html
|
* [The Qt archive](https://download.qt.io/archive/qt/), to examine the sources of older versions of Qt. Try reading `src/corelib/kernel/qtranslator.cpp` or `tools/linguist/shared/qm.cpp`.
|
||||||
|
|
||||||
|
[qt-linguist]: https://doc.qt.io/qt-6/qtlinguist-index.html
|
||||||
|
|
Loading…
Reference in New Issue