(The official version has been fixed) Hexo NexT theme Valine comments are invalid in multiple languages

The official version of 8.0.0 has fixed this small bug. Use the official version of 8.0.0 or later to avoid this problem.

This blog must be open to the whole world (so why the Cookie statement appears at the top of this blog for the first visit), so the interface is in English (the blog post will not be considered for translation). Previously, Bili commented that the page could not be displayed after sending the comment. The background was displayed but the foreground was not displayed. Considering that most of the newly opened personal blog sites now adopt the Valine framework for comments, I also intend to switch to Valine. However, after configuring the languageproperties in the NexT theme, the language of the comment interface has not changed. This should also be displayed in English.

The Valine configuration in the original NexT configuration file is like this. (Here I found the version of 8.0.0-rc.5)

# Valine
# For more information: https://valine.js.org, https://github.com/xCss/Valine
valine:
  enable: false
  appId: # Your leancloud application appid
  appKey: # Your leancloud application appkey
  placeholder: Just go go # Comment box placeholder
  avatar: mm # Gravatar style
  meta: [] # Custom comment header: [nick, mail, link]
  pageSize: 10 # Pagination size
  language: # Language, available values: en, zh-cn
  visitor: false # Article reading statistic
  comment_count: true # If false, comment count will only be displayed in post page, not in home page
  recordIP: false # Whether to record the commenter IP
  serverURLs: # When the custom domain name is enabled, fill it in here (it will be detected automatically by default, no need to fill in)
  enableQQ: false # Whether to enable the Nickname box to automatically get QQ Nickname and QQ Avatar
  requiredFields: [] # Set required fields: [nick] | [nick, mail]
  #post_meta_order: 0

After discovering this problem, check the source code of the page generated by the server and notice that there is a one-to-one correspondence between the name of the key-value pair and the yaml above.

NexT.utils.loadComments('#valine-comments', () => {
    
    
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/[email protected]/dist/Valine.min.js', () => {
    
    
    new Valine(Object.assign({
    
    
      el  : '#valine-comments',
      path: location.pathname,
    }, {
    
    "enable":true,"appId":"...","appKey":"...","placeholder":"Just go go","avatar":"mm","meta":["nick","mail","link"],"pageSize":10,"language":"en","visitor":false,"comment_count":true,"recordIP":false,"serverURLs":null}
    ));
  }, window.Valine);
});

The guess is languagethat there is a problem with the attribute reading. Check Valine's official document, open "Multilingual Support", and find that the attribute name of the configuration language has changed langinstead language.

So change the languageattribute name of the configuration file to lang. Restart the server and refresh the page. At this point, you can see that the comment interface has been successfully changed to English.

At present, I have submitted this issue to Issue on NexT official Github. I hope that this small BUG can be corrected over there.

A small problem: Valine 1.4.14 multi-language attribute name is wrong in the theme configuration here (language should be lang)

Guess you like

Origin blog.csdn.net/qq_35977139/article/details/107844018
Recommended