1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// *LocalizationManager* provides access to descriptions of
/// the message catalogs that are available for client-side message
/// localization.
///
/// Clients of the VIM API may use
/// *SessionManager*.*SessionManager.SetLocale*
/// to cause the server to emit localized messages, or may perform
/// client-side localization based on message catalogs provided by the
/// *LocalizationManager*.
///
/// A message catalog is a file that contains a set of key-value pairs.
/// - The key is an ASCII string that identifies the message.
/// - The value is a UTF-8 string that contains the text of the message, sometimes
/// containing substitution variables.
///
/// The server will localize fields tagged with 'localizable' based on the
/// value of the *UserSession*.*UserSession.locale*
/// and *UserSession.messageLocale* properties which are set via
/// *SessionManager*.*SessionManager.SetLocale*.
///
/// The following list shows some of the ways that vSphere uses localized
/// messages.
/// - Current task status (*TaskInfo*.*TaskInfo.description*)
/// - Events (*VirtualMachineMessage*.*VirtualMachineMessage.text* and
/// Questions (*VirtualMachineQuestionInfo*.*VirtualMachineQuestionInfo.text*)
/// - Faults (*MethodFault*.*MethodFault.faultMessage*)
/// - *HostProfile* and
/// *ClusterProfile* descriptions
/// (*Profile*.*ProfileDescription*.
/// *Profile.description* returned by the
/// *Profile*.*Profile.RetrieveDescription* method)
#[derive(Clone)]
pub struct LocalizationManager {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl LocalizationManager {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Fetches the descriptions of all the client-side localization message
/// catalogs available for the current session locale.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// the message catalogs for the current locale
pub async fn catalog(&self) -> Result<Option<Vec<crate::types::structs::LocalizationManagerMessageCatalog>>> {
let pv_opt = self.client.fetch_property_raw("", "LocalizationManager", &self.mo_id, "catalog").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
}