Jamling/hexo-generator-i18n

Compatibility issue with icarus theme.

twatzl opened this issue · 1 comments

Hello,

I am using the Icarus theme for my blog (https://github.com/ppoffice/hexo-theme-icarus) however it seems icarus expects the language to be a string and not an array.

ERROR Render HTML failed: 2019/07/19/Hello-World/index.html
TypeError: /data/blog/themes/icarus/layout/layout.ejs:2
    1| <!DOCTYPE html>                                                                                
 >> 2| <html <%- has_config('language') ? ' lang="' + get_config('language').substring(0, 2) + '"' : '' %>>                                                                                                 
    3| <head>                                                                                         
    4|     <%- partial('common/head') %>                                                              
    5| </head>                                                                                        
                                                                                                      
get_config(...).substring is not a function                                                           
    at eval (eval at compile (/data/blog/node_modules/ejs/lib/ejs.js:633:12), <anonymous>:11:77)      
    at returnedFn (/data/blog/node_modules/ejs/lib/ejs.js:668:17)                                     
    at Theme._View.View._compiled (/data/blog/node_modules/hexo/lib/theme/view.js:123:48)             
    at Theme._View.View.View.render (/data/blog/node_modules/hexo/lib/theme/view.js:29:15)            
    at /data/blog/node_modules/hexo/lib/theme/view.js:40:23                                           
    at tryCatcher (/data/blog/node_modules/bluebird/js/release/util.js:16:23)                         
    at Promise._settlePromiseFromHandler (/data/blog/node_modules/bluebird/js/release/promise.js:517:31)                                                                                                    
    at Promise._settlePromise (/data/blog/node_modules/bluebird/js/release/promise.js:574:18)         
    at Promise._settlePromise0 (/data/blog/node_modules/bluebird/js/release/promise.js:619:10)        
    at Promise._settlePromises (/data/blog/node_modules/bluebird/js/release/promise.js:699:18)        
    at _drainQueueStep (/data/blog/node_modules/bluebird/js/release/async.js:138:12)                  
    at _drainQueue (/data/blog/node_modules/bluebird/js/release/async.js:131:9)                       
    at Async._drainQueues (/data/blog/node_modules/bluebird/js/release/async.js:147:5)                
    at Immediate.Async.drainQueues [as _onImmediate] (/data/blog/node_modules/bluebird/js/release/async.js:17:14)                                                                                           
    at processImmediate (internal/timers.js:439:21)

Is there any way to fix this? For example use a different config setting for the i18n generator and set language to the language currently being rendered?

As a workaround I was able to just delete the line, but I don't think that is a great solution.

I note that the get_config('language') is the helper function of icarus, and I read the source code of the theme, the theme will read config from hexo _config.yml and theme _config.yml but the default theme _config.yml is empty. The i18n plugin works on multi-languages. The languages config in hexo _config.yml must be language array. If there is only one language, it's not suggested to use i18n plugin. Here is some suggestions.

1, try to config single language string in theme _config.yml
2, modify the theme source code to support multilang, the simplest way is removing the html lang attribute in layout.ejs
3, new one issue in theme project on github, suggesting the owner of project to add multi-language supporting feature.