ChrAlpha / hexo-theme-cards

Another Simple & Swift theme for Hexo
https://theme-cards.ichr.me
GNU General Public License v3.0
421 stars 47 forks source link

关于多语言支持 #99

Open realZnS opened 3 years ago

realZnS commented 3 years ago

主题是有写多语言支持的,但是导航栏菜单却写死了(基于config.yml,不根据语言设置而切换)

ChrAlpha commented 3 years ago

但是让用户修改 language 文件夹下的语言配置文件有点反直觉,用户第一反应应该都是修改配置文件中的条目,是否要在配置文件中加入多语言配置呢?

realZnS commented 3 years ago

Get 到你这点了 我原本的想法是,既然有了多语言支持,就应该使站内文字根据 hexo 配置文件里面 language 字段所指定的语言一致。 至于自定义 可以默认按照语言配置,用户也可以在主题配置文件里面进行覆盖

ChrAlpha commented 3 years ago

可以默认按照语言配置,用户也可以在主题配置文件里面进行覆盖

但是 _config.yml导航栏配置项 条目数是不确定的,并非一定是 5 个,默认配置该如何写呢?

realZnS commented 3 years ago

增加可选的id字段 例如:

  menu: 
    - name: 首页
      id: home
      url: /
    - name: 标签
      id: tag
      url: /tags/
    - name: 
      id: archive
      url: /archives/
    - name: 
      id: link
      url: /friends/
    - name: Page
      id: 
      url: /page/

当 id 能与语言库匹配且 name 字段不为空时,直接使用 name 字段(如上例1、2) 当 id 能与语言库匹配且 name 字段为空时,调用语言库中的名称(如上例3、4) 当 id 为空时,直接使用 name 字段(如上例5)

(本人技术力低下,不知道这个方案实现起来方不方便,表述不清处还请见谅)