mdn / yari

The platform code behind MDN Web Docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to show locale title instead of the last path string in `main menu of module` for macros?

awxiaoxian2020 opened this issue · comments

Related to mdn/translated-content#13881.

Our main menus of module display the last path string:

if ($2) {
var startString = $2;
var linkTextArray = startString.split('/');
var linkText = linkTextArray[linkTextArray.length-1];
var re = /_/gi;
var finalString = linkText.replace(re,' ');

In locale, we only can only see the English title (i.e. the last past string):
image

Is it possible to show locale title instead of the last path string?

ping @yin1999 for ideas :)

commented

Displaying localized titles would be better. I'm trying to embed localized titles into the page info in the macro system (#8241). But before this could be landed, we can only implement this in the following way:

  1. generate the full, localized slug with the env.locale variable
  2. call getPageByURL method to get the page info, if the page does not exist, fallback to the en-US title, else use the title field in the returned object.