add option to override locale messages per-group, update readme
This commit is contained in:
@@ -55,43 +55,74 @@ A typical setup could look like this:
|
||||
│ │ ├── control.json
|
||||
│ │ └── state.json
|
||||
│ └── chatterbox@botsin.space
|
||||
│ ├── config.json
|
||||
│ ├── control.json
|
||||
│ └── state.json
|
||||
│ ├── config.json ... fixed config edited manually
|
||||
│ ├── messages.json ... custom locale overrides (optional)
|
||||
│ ├── control.json ... mutable config updated by the group service
|
||||
│ └── state.json ... group state data
|
||||
├── locales
|
||||
│ ├── ... custom locale files, same format like en.json
|
||||
│ └── ru.json
|
||||
└── groups.json
|
||||
```
|
||||
|
||||
#### Locales
|
||||
|
||||
English locale ("en") is bundled in the binary. Additional locales can be placed in the `locales` folder.
|
||||
If an entry is missing, the English version will be used.
|
||||
|
||||
The locale file looks like this (excerpt):
|
||||
|
||||
```json
|
||||
{
|
||||
"group_announcement": "**📢Group announcement**\n{message}",
|
||||
"ping_response": "pong, this is fedigroups service v{version}"
|
||||
}
|
||||
```
|
||||
|
||||
- Words in curly braces (`{}`) are substitution tokens. These must be preserved in all translations.
|
||||
- Pay attention to line endings and blank lines (`\n`). Some messages from the locale file are combined to form the
|
||||
final post, leaving out newlines can result in a mangled output.
|
||||
|
||||
The locale to use is chosen in each group's `config.json`, "en" by default (if not specified).
|
||||
|
||||
Group-specific overrides are also possible: create a file `messages.json` in the group folder
|
||||
and define messages you wish to change, e.g. the greeting or announcement templates.
|
||||
|
||||
#### Common config
|
||||
|
||||
There is one shared config file: `groups.json`
|
||||
|
||||
- If the file does not exist, default settings are used. This is usually good enough.
|
||||
- This file applies to all groups
|
||||
- Prior to 0.3, the groups were also configured here.
|
||||
- Running 0.3+ with the old file will produce an error, you need to update the config before continuing - move groups to subfolders
|
||||
- If the file does not exist, default settings are used. This is usually sufficient.
|
||||
- This file applies to all groups and serves as the default config.
|
||||
|
||||
```
|
||||
{
|
||||
// name of the directory with groups
|
||||
"groups_dir": "groups",
|
||||
// name of the directory with locales
|
||||
"locales_dir": "locales",
|
||||
// Show warning if locales are missing keys
|
||||
"validate_locales": true,
|
||||
// Max number of missed notifs to process after connect
|
||||
max_catchup_notifs: 30,
|
||||
"max_catchup_notifs": 30,
|
||||
// Max number of missed statuses to process after connect
|
||||
max_catchup_statuses: 50,
|
||||
"max_catchup_statuses": 50,
|
||||
// Delay between fetched pages when catching up
|
||||
delay_fetch_page_s: 0.25,
|
||||
"delay_fetch_page_s": 0.25,
|
||||
// Delay after sending a status, making a follow or some other action.
|
||||
// Set if there are Throttled errors and you need to slow the service down.
|
||||
delay_after_post_s: 0.0,
|
||||
"delay_after_post_s": 0.0,
|
||||
// Delay before trying to re-connect after the server closed the socket
|
||||
delay_reopen_closed_s: 0.5,
|
||||
"delay_reopen_closed_s": 0.5,
|
||||
// Delay before trying to re-connect after an error
|
||||
delay_reopen_error_s: 5.0,
|
||||
"delay_reopen_error_s": 5.0,
|
||||
// Timeout for a notification/timeline socket to be considered alive.
|
||||
// If nothing arrives in this interval, reopen it. Some servers have a buggy socket
|
||||
// implementation where it stays open but no longer works.
|
||||
socket_alive_timeout_s: 30.0,
|
||||
"socket_alive_timeout_s": 30.0,
|
||||
// Time after which a socket is always closed, even if seemingly alive.
|
||||
// This is a work-around for servers that stop sending notifs after a while.
|
||||
socket_retire_time_s: 120.0,
|
||||
"socket_retire_time_s": 120.0
|
||||
}
|
||||
```
|
||||
|
||||
@@ -111,6 +142,7 @@ Only the `config.json` file with credentials is required; the others will be cre
|
||||
- `state.json` - frequently changing state data. The last-seen status/notification timestamps are kept here.
|
||||
State is split from Control to limit the write frequency of the control file. Timestamps can be updated multiple times
|
||||
per minute.
|
||||
- `messages.json` - optional per-group locale overrides
|
||||
|
||||
**Do not edit the control and state files while the group service is running, it may overwrite your changes!**
|
||||
|
||||
@@ -127,9 +159,11 @@ The file formats are quite self-explanatory (again, remove comments before copyi
|
||||
{
|
||||
// Enable or disable the group service
|
||||
"enabled": true,
|
||||
// Group locale (optional, defaults to "en")
|
||||
"locale": "en",
|
||||
// Group account name
|
||||
"acct": "group@myserver.xyz",
|
||||
// Saved mastodon API credentials
|
||||
// Saved mastodon API credentials, this is created when authenticating the group.
|
||||
"appdata": {
|
||||
"base": "https://myserver.xyz",
|
||||
"client_id": "...",
|
||||
|
||||
Reference in New Issue
Block a user