# Add custom menu panel to the correct location (same as hamburger menu panel)

**URL:** <https://meta.discourse.org/t/add-custom-menu-panel-to-the-correct-location-same-as-hamburger-menu-panel/119364>\
**Category:** Development\
**Created:** [3 ביוני,‏ 2019,‏ 9:47am UTC](https://meta.discourse.org/t/add-custom-menu-panel-to-the-correct-location-same-as-hamburger-menu-panel/119364 "2019-06-03T09:47:39Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![thwright](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@thwright](https://meta.discourse.org/u/thwright)\
**Post date:** [5 בנובמבר,‏ 2019,‏ 7:08pm UTC](https://meta.discourse.org/t/add-custom-menu-panel-to-the-correct-location-same-as-hamburger-menu-panel/119364/4 "2019-11-05T19:08:29Z")

</div>

I’ve been wracking my brain on this one for a little while. The title for the custom hamburger menu displays the locale information, such that when hovering over the menu I am returned the following.

`[en_US.some-title]`

Attempting to use `Il8n.t(themePrefix("some-title"))` after creating a theme with a locale file I am given the following.

`[en_US.Some Title]`

> **As given**
>
> ```
> api.decorateWidget('header-icons:before', function (helper) {
> const headerState = helper.widget.parentWidget.state;
> 
> return helper.attach('header-dropdown', {
> title: "mysite.menu_title",
> icon: 'bars',
> iconId: 'toggle-custom-menu',
> active: headerState.customMenuVisible,
> action: 'toggleCustomMenu',
> href: ""
> });
> });
> 
> ```

> **Theme with il8n**
>
> ```
> api.decorateWidget('header-icons:before', function (helper) {
> const headerState = helper.widget.parentWidget.state;
> 
> return helper.attach('header-dropdown', {
> title: I18n.t(themePrefix("mysite.menu_title")),
> icon: 'bars',
> iconId: 'toggle-custom-menu',
> active: headerState.customMenuVisible,
> action: 'toggleCustomMenu'
> });
> });
> 
> ```

Here is my full script code. The theme and CSS are defaults for a newly generated theme using `discourse_theme new`.

> **Summary**
>
> ```
> <script type="text/discourse-plugin" version="0.8">
> 
> const { h } = require('virtual-dom');
> const { attachAdditionalPanel } = require('discourse/widgets/header');
> const { iconNode } = require("discourse-common/lib/icon-library");
> 
> const mySiteAboutLinks = [
> {
> text: "Knowledgebase",
> rawTitle: "Knowledgebase",
> href: "/k",
> className: "mysite-about",
> icon: "question"
> }
> ];
> 
> const mySiteSupportLinks = [
> {
> text: "Staff",
> rawTitle: "Staff",
> href: "/page/staff/1/",
> className: "mysite-support",
> icon: "link"
> },
> {
> text: "Contact",
> rawTitle: "Contact",
> href: "/page/contact/2/",
> className: "mysite-support",
> icon: "far-envelope"
> }
> ];
> 
> api.createWidget('custom-menu', {
> tagName: 'div.custom-panel',
>     
> settings: {
> maxWidth: 320
> },
>     
> panelContents() {
> results = [];
>         
> results[1] = h('ul.custom-about-menu.menu-links.columned', mySiteAboutLinks.map(l => h('li', h('a.widget-link', { href: l.href, title: l.rawTitle }, [iconNode(l.icon.toLowerCase()), ' ', h('span.d-label', l.text)]))));
> results[2] = h('div.clearfix');
> results[3] = h('hr');
> results[4] = h('ul.custom-support-menu.menu-links.columned', mySiteSupportLinks.map(k => h('li', h('a.widget-link', { href: k.href, title: k.rawTitle }, [iconNode(k.icon.toLowerCase()), ' ', h('span.d-label', k.text)]))))
>         
> return results;
>         
> },
> 
> html() {
> return this.attach('menu-panel', {
> contents: () => this.panelContents(),
> maxWidth: this.settings.maxWidth
> });
> },
> 
> clickOutside(event) {
> if (this.site.mobileView) {
> this.clickOutsideMobile(event);
> } else {
> this.sendWidgetAction('toggleCustomMenu');
> }
> },
> 
> clickOutsideMobile(event) {
> const centeredElement = document.elementFromPoint(event.clientX, event.clientY);
> if (
> !centeredElement.classList.contains('header-cloak') &&
> centeredElement.closest('.panel').length > 0
> ) {
> this.sendWidgetAction('toggleCustomMenu');
> } else {
> const panel = document.querySelector('.menu-panel');
> panel.classList.add('animate');
> const panelOffsetDirection = this.site.mobileView ? 'left' : 'right';
> panel.style.setProperty(panelOffsetDirection, -window.innerWidth);
> 
> const headerCloak = document.querySelector('.header-cloak');
> headerCloak.classList.add('animate');
> headerCloak.style.setProperty('opacity', 0);
> console.log('hi')
> 
> Ember.run.later(() => this.sendWidgetAction('toggleCustomMenu'), 200);
> }}
> });
> 
> api.decorateWidget('header-icons:before', function (helper) {
> const headerState = helper.widget.parentWidget.state;
> 
> return helper.attach('header-dropdown', {
> title: I18n.t(themePrefix("mysite.menu_title")),
> icon: 'bars',
> iconId: 'toggle-custom-menu',
> active: headerState.customMenuVisible,
> action: 'toggleCustomMenu'
> });
> });
> 
> api.attachWidgetAction('header', 'toggleCustomMenu', function() {
> this.state.customMenuVisible = !this.state.customMenuVisible;
> });
> 
> api.addHeaderPanel('custom-menu', 'customMenuVisible', function (attrs, state) {
> // This callback has to be provided. Don’t know why.
> });
> 
> ```

Any thoughts on how to correct the hover title so that only the title is displayed without brackets and locale?

---

_[View the full topic](https://meta.discourse.org/t/add-custom-menu-panel-to-the-correct-location-same-as-hamburger-menu-panel/119364)._
