xapi_rs/data/multi_lingual.rs
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3use crate::data::{DataError, MyLanguageTag};
4
5/// xAPI refers to a [Language Map][1] as a dictionary of words or sentences
6/// keyed by the [RFC 5646:][2] "Tags for Identifying Languages".
7///
8/// This trait exposes a way for populating such dictionaries.
9///
10/// Note though that the recommended way for populating a _Language Map_ is
11/// through the [add_language][crate::add_language] macro.
12///
13/// [1]: [crate::LanguageMap]
14/// [2]: https://datatracker.ietf.org/doc/rfc5646/
15pub trait MultiLingual {
16 /// A _Builder_ style method to add to, and if successful return, `self` (a
17 /// [LanguageMap][1]) a `label` string in a given language `tag`.
18 ///
19 /// Raise [DataError] if an error occurs in the process.
20 ///
21 /// [1]: [crate::LanguageMap]
22 fn add_label(&mut self, tag: &MyLanguageTag, label: &str) -> Result<&mut Self, DataError>;
23}