view modules/translate/REFERENCE.md @ 245:b0f8b88fea5c

Add "translate" module used by MySQL module
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Dec 2019 14:12:10 -0500
parents
children
line wrap: on
line source

# Reference
<!-- DO NOT EDIT: This document was generated by Puppet Strings -->

## Table of Contents

**Functions**

* [`translate`](#translate): A function that calls the _() function in gettext. This is because _ is protected in the puppet language

## Functions

### translate

Type: Ruby 4.x API

A function that calls the _() function in gettext. This is because _ is protected in the puppet language

* **Note** Translate with simple strings:
  - Takes in a string and passes it to fast_gettext's _() function. Primarily used for 'marking' a string to be added to a .pot file.
Translate with interpolation:
  - Takes in a string and a hash. Please note that variables in the message are wrapped with %{VAR} not ${VAR}.
  - The hash contains key value pairs with marker and the variable it will be assigned to.
  - The translate module passes it to fast_gettext's _() function. Primarily used for 'marking' a string to be added to a .pot file.

#### Examples

##### 

```puppet
fail(translate("Failure message"))
```

##### 

```puppet
fail(translate('message is %{color}'), {'color' => 'green'})
```

#### `translate(String $message, Optional[Hash] $interpolation_values)`

The translate function.

Returns: `String` translated message.

##### Examples

###### 

```puppet
fail(translate("Failure message"))
```

###### 

```puppet
fail(translate('message is %{color}'), {'color' => 'green'})
```

##### `message`

Data type: `String`

Message to translate

##### `interpolation_values`

Data type: `Optional[Hash]`

Optional.