Adding translatability information

Adsooi 2022-01-31 17:59:20 +00:00
parent 5a20346cfe
commit 29b2b21b31

@ -9,7 +9,7 @@ To create an object, create a new file javascript files in `LogarithmPlotter/qml
```js
/**
* LogarithmPlotter - Create graphs with logarithm scales.
* Copyright (C) 2021 Ad5001
* Copyright (C) 2022 Ad5001
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -69,6 +69,38 @@ So to create a new object, choose one of the two to extend, and then create a cl
- Lists: `new P.List(<static type>, format = /^.+$/, label = '', forbidAdding = false)`
- Dictionaries: `new P.Dictionary(valueType: <static type>, keytType: <static type>, format = /^.+$/, preKeyLabel = '', postKeyLabel = ': ', forbidAdding = false)`
- Other objects: `new P.ObjectType(<object type. E.g. "Point", "ExecutableObject"...>)`
- In order to allow the properties to be properly translated, you shoudl apply the `QT_TRANSLATE_NOOP` macro to both property names (in the `prop` namespace) and comments (in the `comment` namespace). For example:
```js
static properties() {return {
[QT_TRANSLATE_NOOP('prop','expression')]: 'Expression',
[QT_TRANSLATE_NOOP('prop','definitionDomain')]: 'Domain',
[QT_TRANSLATE_NOOP('prop','destinationDomain')]: 'Domain',
'comment1': QT_TRANSLATE_NOOP(
'comment',
'Ex: R+* (ℝ⁺*), N (), Z-* (ℤ⁻*), ]0;1[, {3;4;5}'
),
[QT_TRANSLATE_NOOP('prop','labelPosition')]: P.Enum.Position,
[QT_TRANSLATE_NOOP('prop','displayMode')]: P.Enum.FunctionDisplayType,
[QT_TRANSLATE_NOOP('prop','labelX')]: 'number',
'comment2': QT_TRANSLATE_NOOP(
'comment',
'The following parameters are used when the definition domain is a non-continuous set. (Ex: , , sets like {0;3}...)'
),
[QT_TRANSLATE_NOOP('prop','drawPoints')]: 'boolean',
[QT_TRANSLATE_NOOP('prop','drawDashedLines')]: 'boolean'
}}
````
- For enums that need to be translated, an alias should be created in `parameters.js`, and then use the static class value in your parameter. For example:
```js
Enum.XCursorValuePosition = new Enum(
QT_TR_NOOP('Next to target'),
QT_TR_NOOP('With label'),
QT_TR_NOOP('Hidden')
)
```
- `constructor(name = null, visible = true, color = null, labelContent = 'name + value', ...other arguments)`
- Constructor of the object, should contain at least the name, visible, color, and labelContent that are passed to the super constructor.
- You should also beaware that Expressions may be inputed as strings or numbers when restored from save, as such you should add a line in your constructor to convert them to an expression.