minor: i18n component writing - #1050

This commit is contained in:
Jean-Baptiste Pasquier 2021-03-30 21:10:05 +02:00
parent 60b9e54294
commit 4860b20e20
2 changed files with 66 additions and 67 deletions

119
README.md
View File

@ -120,14 +120,7 @@ On `config.json`:
"css": "/path/to/custom.css",
"i18n": {
"lang": "fr",
"force": "false",
"files": [
{
"name": "yourCustomLangName",
"file": "/path/to/file.json"
},
...
]
"force": "false"
}
}
}
@ -139,8 +132,6 @@ Where:
* `client.css` is an URL to a distant CSS that'll be the last one loaded by the Hubl
* `client.i18n.lang` is the fallback langage in case the visitor's browser one does not contain the string
* `client.i18n.force` allows to ignore the visitor's browser langage and force the `client.i18n.lang` one
* `client.i18n.files[].name` allows to use custom client lang file.
* `client.i18n.files[].file` is the path the the json lang file
### Allow to login to your application
@ -159,56 +150,6 @@ Where:
* `authority` is the OpenID Provider. Usually, if you use `djangoldp_account` it's the same as your djangoldp server.
### Custom lang files
Each client can overwrite langs files with their own or even create custom langs.
#### Overwrite langs
On `config.json`:
```json
{
"client": {
"i18n": {
"files": [
{
"name": "fr",
"file": "/path/to/custom-fr.json"
}
]
}
}
}
```
#### Custom langs
Needs `client.i18n.force` to `true` and `client.i18n.lang` to the custom lang name.
Your custom JSON file **must** contain every keys, from the template and from every bloxes, prefixed by the blox namespace. See example on `src/locales/fr.json`.
On `config.json`:
```json
{
"client": {
"i18n": {
"lang": "pirate",
"force": "true",
"files": [
{
"name": "pirate",
"file": "/path/to/yarr.json"
}
]
}
}
}
```
Setting custom langs will not allow user to choose their own lang.
## Optional modules
### Adding modules
@ -405,6 +346,64 @@ You can get only future events by using:
"get": "http://server.url/events/future/",
```
### Internationalization
Each client can overwrite langs files with their own or even create custom langs.
#### Overwrite langs
On `config.json`:
```json
{
"type": "lang",
"parameters": {
"name": "fr",
"file": "/path/to/fr.json"
},
"route": false
}
```
Where:
* `parameters.name` allows to use custom client lang file.
* `parameters.file` is the path the the json lang file
#### Custom langs
Needs `client.i18n.force` to `true` and `client.i18n.lang` to the custom lang name.
Your custom JSON file **must** contain every keys, from the template and from every bloxes, prefixed by the blox namespace. See example on `src/locales/fr.json`.
On `config.json`:
```json
"client": {
"i18n": {
"lang": "pirate",
"force": "true"
}
},
"components": [
{
"type": "i18n",
"parameters": {
"name": "pirate",
"file": "/path/to/yarr.json"
},
"route": false
}
]
```
Where:
* `parameters.name` allows to use custom client lang file.
* `parameters.file` is the path the the json lang file
Setting custom langs will not allow user to choose their own lang.
### Job Offers
Job Offers includes a job board with conversation. To activate them

View File

@ -175,6 +175,13 @@ html(lang="en")
if component.type == "notification"
include views/partials/notifications.pug
if component.type == "lang"
hubl-lang(
hidden
lang=component.parameters.name
file=component.parameters.file
)
if componentSet.has('profileDirectory')
.scrollbar-content(
id=`${getRoute("profileDirectory", true)}-profile`
@ -220,13 +227,6 @@ html(lang="en")
hidden
lang=client.i18n.lang?client.i18n.lang:"fr"
)&attributes({"force": client.i18n.force})
if client.i18n.files
for clientI18n in client.i18n.files
hubl-lang(
hidden
lang=clientI18n.name
file=clientI18n.file
)
div(
id="swal-content-text"