# Transform MAP files for a binding

**URL:** <https://community.openhab.org/t/transform-map-files-for-a-binding/82831>\
**Category:** Misc\
**Created:** [October 1, 2019, 8:12pm UTC](https://community.openhab.org/t/transform-map-files-for-a-binding/82831 "2019-10-01T20:12:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scherer](https://community.openhab.org/user_avatar/community.openhab.org/scherer/32/43134_2.png) [@scherer](https://community.openhab.org/u/scherer)\
**Post date:** [October 1, 2019, 8:12pm UTC](https://community.openhab.org/t/transform-map-files-for-a-binding/82831/1 "2019-10-01T20:12:31Z")

</div>

I’m currently developing the Sure Petcare binding and I’d like to ship a number of maps for the MAP transform bundle, so that user can use human readable text in sitemaps etc.

Is there a way to package the maps, so that they get installed with the bundle? If not, where is the correct place to put them, so that it is a easy as possible for the end user to install them?

Many thanks,  
Rene

---

<div class="post-metadata">

**Author:** ![hilbrand](https://community.openhab.org/user_avatar/community.openhab.org/hilbrand/32/72354_2.png) [@hilbrand](https://community.openhab.org/u/hilbrand)\
**Post date:** [October 2, 2019, 10:22am UTC](https://community.openhab.org/t/transform-map-files-for-a-binding/82831/2 "2019-10-02T10:22:10Z")

</div>

As far as I know there is no way to install those maps. However the pattern in general to implement such a feature is to add them channel state options and as localized text in the binding and make them part of the binding itself. For the other language you add the options text to the language file. If people still want to have another language they can create a map file that transforms the number or English word of the options into their own language. To give an example of how that works for a channel. Here is an example of your `genderIdType` it could look like this:

```auto
	<channel-type id="genderIdType">
		<item-type>String</item-type> <--- Needs to be String
		<label>Gender Id</label>
		<description>The pet's gender id</description>
		<state readOnly="true">
			<options>
				<option value="0">Female</option>
				<option value="1">Male</option>
				<option value="unknown">Unknown</option>
			</options>
		</state>
	</channel-type>

```

or

```auto
				<option value="Female">Female</option>
				<option value="Male">Male</option>
				<option value="Unknown">Unknown</option>

```

---

<div class="post-metadata">

**Author:** ![kugelsicha](https://community.openhab.org/user_avatar/community.openhab.org/kugelsicha/32/57143_2.png) [@kugelsicha](https://community.openhab.org/u/kugelsicha)\
**Post date:** [October 2, 2019, 10:55am UTC](https://community.openhab.org/t/transform-map-files-for-a-binding/82831/3 "2019-10-02T10:55:01Z")

</div>

this is exactly i was playing with…

I found this in [Internationalization | openHAB](https://www.openhab.org/docs/developer/utils/i18n.html)

and for now i have done it with:

**things.xml**

```auto
	<channel-type id="genderIdType">
		<item-type>String</item-type>
		<label>Gender Id</label>
		<description>The pet's gender id</description>
		<state readOnly="true" pattern="%s">
			<options>
				<option value="0">@text/genderFemale</option>
				<option value="1">@text/genderMale</option>
				<option value="">@text/genderUnknown</option>
			</options>
		</state>
	</channel-type>

```

**surepetcare\_en.properties**

```auto
genderFemale = Female
genderMale = Male
genderUnknown = Unknown

```

i will push the related PR later this day. @scherer

---

<div class="post-metadata">

**Author:** ![scherer](https://community.openhab.org/user_avatar/community.openhab.org/scherer/32/43134_2.png) [@scherer](https://community.openhab.org/u/scherer)\
**Post date:** [October 3, 2019, 8:15am UTC](https://community.openhab.org/t/transform-map-files-for-a-binding/82831/4 "2019-10-03T08:15:54Z")

</div>

Hi Hilbrand

Thanks for the response. That certainly works for read-only channels, but I’m not sure about writable channels. I assume the i18n translation only works one-way.

I can see 2 options:  
Option 1. Expose 2 channels, a read-only string-type one called “Gender” which uses the options and i18n files to show a textual representation and a writable number channel called “Gender Id”, which shows the gender as a code and can be updated by sending a DecimalType command.

Option 2. Expose only one string-type channel called “Gender” which uses the options and i18n files to show a textual representation when displayed, but the handler expects a StringCommand with a code in the payload (i.e. “1”) to update the thing’s gender.

IMHO the first option looks cleaner, but requires 2 channels for basically the same information. What do you think? Is there a recommended design pattern?

Cheers,  
Rene

---

<div class="post-metadata">

**Author:** ![hilbrand](https://community.openhab.org/user_avatar/community.openhab.org/hilbrand/32/72354_2.png) [@hilbrand](https://community.openhab.org/u/hilbrand)\
**Post date:** [October 3, 2019, 12:50pm UTC](https://community.openhab.org/t/transform-map-files-for-a-binding/82831/5 "2019-10-03T12:50:12Z")

</div>

It works both ways. In the sense that when it’s a writable channel it will be displayed in the UI as a selection box. The selection box will show the translated texts. The handler gets the StringCommand with the content from the option `value` attribute. Basically this is what you describe as option 2.
