Making a theme translation for Custom Header Links

Hi friend, I want to make a Theme Translations for this component
I have read the Multiple languages support in How to add settings to your Discourse theme

and i find this theme have the theme translations functions.

but i don’t know how to start to make a translations for this theme component,

can you give me a guidelines

1 Like

I’m trying to change this use David Taylor’s topic


in Adding localizable strings to themes and theme components

<script type="text/discourse-plugin" version="0.8.20">
  // Add an attribute to the <html> tag. This might help the user to style
  // his header links 
  $('html').attr('dhp-locale', I18n.locale)

  const customHeaderLinks = I18n.t(themePrefix("header_nav_link"));
  if (!customHeaderLinks.length) return;

  const h = require("virtual-dom").h;
  const headerLinks = [];

  const mobileView = api.container.lookup("site:main").mobileView;

and add a locales/en.yml

but get the [en.theme_translations.87.header_nav_link] resuilt

…so, i do someting wrong?

1 Like

No, you’re not doing anything wrong. This component does not support theme translations yet but updating it is on my list.

Are you trying to translate the text for each link so that it shows up based on the user’s language preference?


yes, Johani, i use this component as a menu,
as you said ,i want translate the text for each link.
it is on your list, i’m very heappy, you can do it. :smiling_face_with_three_hearts: :smiling_face_with_three_hearts: :smiling_face_with_three_hearts:

1 Like

haha, I have an idea,
I can use this component to achieve a bilingual website,
I can creat some chinese categories and some english categories,
and ues this component as the main navigation,
the title link include in the translate locales file en.yml and zh_CN.yml

the homepage and categories page i can use a translated theme component( even it’s a static page, ) achieve.

and hide the default category-drop,
and in my think, it is good for me just use two language in our website.

1 Like

haha, i get it, just move the header.html content to head_tag.html

get it from read again this topic

thanks johani and this joe guy. :blush: :blush: :blush: :blush: