OARepo Model Builder Multilingual
plugin for the oarepo-model-builder module that adds support for multilingual data types
Usage
Within this plugin, two data types are added: multilingual and i18nstr. They can be added to the data model
using type: multilingual or type: i18nstr.
Values containing language tags must be in IETF format.
The structure of both data types can be changed using the multilingual field
i18nStr
An object that contains the language of the item and the actual value of the item.
Example
Model
"abstract": {"type": "i18nStr"}
Generated JsonSchema
"abstract": {
"type": "object",
"properties": {
"lang": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
Multilingual
Array of i18nStr objects.
Example
Model
"abstract": {"type": "multilingual"}
Generated Schema
"abstract": {
"type": "array",
"items": {
"type": "object",
"properties": {
"lang": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
}
Usage of i18nStr within another object
i18nstr can be added to another object using "use": "i18n".
Example
Supported languages:
Supported languages are defined in the object in the structure: "supported language tag": {object containing additional information} within the field supported-langs in model settings.
Supported languages definition is used to specify the languages to be indexed in elasticsearch and opensearch,
respectively. All supplied data for the supported language will be inserted into the mapping definition.
Example
Model
"model": {"properties": {"a": {"type": "multilingual"}}
"settings": {"supported-langs": {
"cs": {
"text": {
"analyzer": "czech",
},
"sort": {
"type": "icu_collation_keyword"
},
"keyword": {
"test": "test"
}
},
"en": {
"text": {
"analyzer": "en"
},
"sort": {
"type": "icu_collation_keyword"
}
}}}}
Generated Schema
"mappings": {
"properties": {
"a": {
"type": "object",
"properties": {
"lang": {
"type": "keyword"
},
"value": {
"type": "text"
}
}
},
"a_cs": {
"type": "text",
"analyzer": "czech",
"sort": {
"type": "icu_collation_keyword",
"index": false,
"language": "cs"
},
"fields": {
"keyword": {
"test": "test",
"type": "keyword"
}
}
},
"a_en": {
"type": "text",
"analyzer": "en",
"sort": {
"type": "icu_collation_keyword",
"index": false,
"language": "en"
},
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
The change of the name of a language or value field
The name of the field for the language value and the name of the field for the value of the item itself can be changed
using the multilingual field and the value-field and lang-field fields. It is not required to rename both fields.
Example:
Model
"b":{"type": "i18nStr", "multilingual":{"lang-field": "language", "value-field": "val"}}
Generated Schema
class BSchema(ma.Schema, ):
"""BSchema schema."""
language = ma_fields.String()
val = ma_fields.String()
class TestSchema(ma.Schema, ):
"""TestSchema schema."""
b = ma_fields.Nested(lambda: BSchema())
Indexing another data type using supported languages
If supported languages are defined, indexing for these languages can be added to data types other than multilingual and
i18nStr. For this purpose you need to add to the field: 'multilingual': {'i18n': True}
Example:
Model:
"model": {"properties": {"a": {"type": "fulltext", "multilingual": {"i18n": true}}}
"settings": {"supported-langs": {"cs": {}, "en": {}}}}
Schema:
{"mappings":
{"properties":{
"a":{"type":"text"},
"a_cs":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":50}}},
"a_en":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":50}}}}}}
Metadata
Release files for oarepo-model-builder-multilingual 3.0.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oarepo_model_builder_multilingual-3.0.21.tar.gz | 13.5 kB | Without provenance | Details for oarepo_model_builder_multilingual-3.0.21.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oarepo_model_builder_multilingual-3.0.21-py3-none-any.whl | Python 3 | none | any | Details for oarepo_model_builder_multilingual-3.0.21-py3-none-any.whl |
Total release size: 44.6 kB
Release files / oarepo_model_builder_multilingual-3.0.21.tar.gz
| Download URL | oarepo_model_builder_multilingual-3.0.21.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79d5407686fb15c152861f0d3b48228188a454d27a13a9203ec5f84a45b7ddf7
|
|
BLAKE2b-256 checksum How to use checksums |
eb60fd0a2b23f7dd6f6fcea5ee39eef6cda2d0b2a49b1da925a390f92db7682f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / oarepo_model_builder_multilingual-3.0.21-py3-none-any.whl
| Download URL | oarepo_model_builder_multilingual-3.0.21-py3-none-any.whl |
|---|---|
| Size | 31.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dfc8c922d7e16bd4f8035274e0b30a2fb989369262272a7e301f6dc7709c7c06
|
|
BLAKE2b-256 checksum How to use checksums |
894e164d220eb4de0a46ae0b661e4a6202be84d22777d901e1c2647bda8866b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for oarepo-model-builder-multilingual 3.0.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.