The first line of code can correctly display the corresponding translation fields on different language pages, but there is a disadvantage, that is, if it is changed, the hugo translation file needs to be modified.
The goal of the second line of code is to directly use the content of the title field in the content file without using the i18n translation file.
The problem we are encountering now is that the .Page.LinkTitle in the second line of code only displays the title of the default language. In other language pages, the navigation bar menu only displays the title field in the default content file instead of other languages. .
I don’t know if I expressed it clearly, through Google Translate.
It queries the translation table for the current language using the menu entry’s identifier and returns the translated string. If the translation table does not exist, or if the identifier key is not present in the translation table, it falls back to name.
or if the identifier key is not present in the translation table, it falls back to name .
I think the expected work has not been completed. When the corresponding key does not exist in the translation table, the name is not used.
What you said requires writing some Identifier translations in the translation table file. I want to use the title fields in files in different languages to be used as menu text in pages in different languages. In this way, when modifying the menu, you only need to modify the text in one position.
That is when there is only one menu. If there are multiple different menus, it should be convenient if the name of the menu can directly use the title of the content page. For multilingual sites.