# TranslationService

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-protranslate-core/struct-translationservice/

**struct** · [`ferroui-protranslate-core`](/docs/0.5.0/api/ferroui-protranslate-core/) · v0.5.0

```rust
struct TranslationService
```



[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L78)

## Members

- [`new`](#function-new)
- [`with_options`](#function-with_options)
- [`cultures`](#function-cultures)
- [`current_culture`](#function-current_culture)
- [`current_ui_culture`](#function-current_ui_culture)
- [`options`](#function-options)
- [`set_options`](#function-set_options)
- [`set_cache_options`](#function-set_cache_options)
- [`set_diagnostic_sink`](#function-set_diagnostic_sink)
- [`subscribe`](#function-subscribe)
- [`subscribe_diagnostics`](#function-subscribe_diagnostics)
- [`subscriber_count`](#function-subscriber_count)
- [`clear_cache`](#function-clear_cache)
- [`refresh`](#function-refresh)
- [`cached_lookup_count`](#function-cached_lookup_count)
- [`remove_cached_string`](#function-remove_cached_string)
- [`fallback_cultures`](#function-fallback_cultures)
- [`get_string`](#function-get_string)
- [`get_string_for`](#function-get_string_for)
- [`format`](#function-format)
- [`format_for`](#function-format_for)
- [`format_localized`](#function-format_localized)
- [`format_value`](#function-format_value)
- [`observe`](#function-observe)
- [`try_observe`](#function-try_observe)

<a id="function-new"></a>

### new

```rust
fn new(provider: Rc<dyn TranslationProvider>, cultures: CultureService) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L80)

<a id="function-with_options"></a>

### with_options

```rust
fn with_options(provider: Rc<dyn TranslationProvider>, cultures: CultureService, options: TranslationFallbackOptions, cache_options: TranslationCacheOptions) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L83)

<a id="function-cultures"></a>

### cultures

```rust
fn cultures(self: &Self) -> CultureService
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L118)

<a id="function-current_culture"></a>

### current_culture

```rust
fn current_culture(self: &Self) -> Culture
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L121)

<a id="function-current_ui_culture"></a>

### current_ui_culture

```rust
fn current_ui_culture(self: &Self) -> Culture
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L124)

<a id="function-options"></a>

### options

```rust
fn options(self: &Self) -> TranslationFallbackOptions
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L127)

<a id="function-set_options"></a>

### set_options

```rust
fn set_options(self: &Self, options: TranslationFallbackOptions)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L130)

<a id="function-set_cache_options"></a>

### set_cache_options

```rust
fn set_cache_options(self: &Self, options: TranslationCacheOptions)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L137)

<a id="function-set_diagnostic_sink"></a>

### set_diagnostic_sink

```rust
fn set_diagnostic_sink(self: &Self, sink: Option<Rc<dyn ProTranslateDiagnosticSink>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L141)

<a id="function-subscribe"></a>

### subscribe

```rust
fn subscribe(self: &Self, callback: impl Fn(&CultureChangedEventArgs) -> () + 'static) -> Subscription
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L144)

<a id="function-subscribe_diagnostics"></a>

### subscribe_diagnostics

```rust
fn subscribe_diagnostics(self: &Self, callback: impl Fn(&ProTranslateDiagnostic) -> () + 'static) -> Subscription
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L147)

<a id="function-subscriber_count"></a>

### subscriber_count

```rust
fn subscriber_count(self: &Self) -> usize
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L153)

<a id="function-clear_cache"></a>

### clear_cache

```rust
fn clear_cache(self: &Self)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L156)

<a id="function-refresh"></a>

### refresh

```rust
fn refresh(self: &Self)
```

Explicitly announces mutable provider data or changed configuration.
This also refreshes observable translations without changing culture.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L161)

<a id="function-cached_lookup_count"></a>

### cached_lookup_count

```rust
fn cached_lookup_count(self: &Self) -> usize
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L172)

<a id="function-remove_cached_string"></a>

### remove_cached_string

```rust
fn remove_cached_string(self: &Self, key: &str, culture: &Culture) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L175)

<a id="function-fallback_cultures"></a>

### fallback_cultures

```rust
fn fallback_cultures(self: &Self, culture: &Culture) -> Vec<Culture>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L187)

<a id="function-get_string"></a>

### get_string

```rust
fn get_string(self: &Self, key: &str) -> Result<LocalizedString, TranslationError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L219)

<a id="function-get_string_for"></a>

### get_string_for

```rust
fn get_string_for(self: &Self, key: &str, culture: &Culture) -> Result<LocalizedString, TranslationError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L222)

<a id="function-format"></a>

### format

```rust
fn format(self: &Self, key: &str, arguments: &[FormatArgument]) -> Result<String, TranslationError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L328)

<a id="function-format_for"></a>

### format_for

```rust
fn format_for(self: &Self, key: &str, arguments: &[FormatArgument], culture: &Culture) -> Result<String, TranslationError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L340)

<a id="function-format_localized"></a>

### format_localized

```rust
fn format_localized(self: &Self, localized: LocalizedString, arguments: &[FormatArgument], culture: &Culture) -> Result<String, TranslationError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L352)

<a id="function-format_value"></a>

### format_value

```rust
fn format_value(self: &Self, key: &str, template: &str, arguments: &[FormatArgument], culture: &Culture) -> Result<String, TranslationError>
```

Format an adapter-provided fallback or outer format with the configured
failure policy and diagnostic sink.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L384)

<a id="function-observe"></a>

### observe

```rust
fn observe(self: &Self, key: impl Into<String>, arguments: Vec<FormatArgument>) -> ObservableLocalizedString
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L397)

<a id="function-try_observe"></a>

### try_observe

```rust
fn try_observe(self: &Self, key: impl Into<String>, arguments: Vec<FormatArgument>) -> Result<ObservableLocalizedString, TranslationError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/ProTranslate/FerroUI.ProTranslate.Core/service.rs#L405)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `Clone`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
