npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hexo-translate-title-modified

v1.0.11

Published

Translate the Chinese title in the Hexo blog into english

Downloads

4

Readme

hexo-translate-title

使用Google翻译,百度翻译和有道翻译将Hexo中的汉字标题转成英文标题,配置完成后直接翻译,无需手工修改标题内容

安装与使用

NPM

安装

npm install hexo-translate-title --save

使用

1.配置hexo根项目下的_config.yml

translate_title:
  translate_way: google  # google,youdao,baidu_with_appid,baidu_no_appid
  youdao_api_key: '' # Your youdao_api_key
  youdao_keyfrom: xxxx-blog # Your youdao_keyfrom
  is_need_proxy: false     # true | false
  proxy_url: http://localhost:50018 # Your proxy_url
  baidu_appid: '' # Your baidu_appid
  baidu_appkey: '' # Your baidu_appkey

注意

  • 判断是否需要配置google本地代理,因为我在本地是开启时才能访问google翻译的,如果没有被墙,请将_config.yml 下的is_need_proxy: true改为false。如果设置为true,请设置本地代理地址
  • 目前google翻译,youdao翻译均可直接使用,百度翻译使用APPID版本,无APPID版本均已完成,APPID版本需要在百度翻译开放平台
  • 如果担心百度翻译开发平台的APP_ID和APP_KEY有泄漏风险,建议在百度翻译开发平台-》管理控制台的服务器地址一栏,填写好服务器IP即可

2.修改hexo根目录下的_config.yml

修改

permalink: :year/:month:day/:translate_title.html

:title修改为:translate_title即可,前面的路径也可按照自己的要求变更,例如 permalink: blog/:translate_title.html

改进之处

  1. 使用了ES6的很多新特性,例如变量声明使用了const和let, 函数体使用async/await同步操作等
  2. 原有百度翻译API发生变化,重写了百度翻译的翻译逻辑
  3. 对于翻译的标题内容,去除标点符号,空格转换为横线连接,并剔除重复单词

版本历程

V1.0.11

1.添加request库依赖,hexo安装时候会报错

V1.0.10

  1. ~~修复引用错误,将request库引用注释掉~~

V1.0.9

  1. 修复issue#8中提出的问题,在设置相同翻译器情况下,如果translate_title中有值,并且和翻译接口获取的翻译内容一致时,不做生成静态页和写入md文件操作。

V1.0.8

版本对标-npm

V1.0.7

  1. 合并 ChaosTong 同学提交的PR,修正在在选择有appid版本百度翻译接口时,hexo s启动服务器时会一直调用翻译接口bug。

v1.0.6

  1. 新增百度无appid功能,不需要申请百度翻译开放平台账号即可直接使用

v1.0.5

  1. 添加async/await函数,引入request-promise请求操作库

TODO

  1. google 获取TKK的时候,是参照这篇文章里面的JS计算方式(谢谢作者!),但是更换为初次获取http://translate.google.cn/TKK值,参与计算获取tk时会计算出错,原因待查中。
  2. 百度无appid版本仍然需要固化token和header中的Cookie值,尚未完成动态获取及拼接Cookie值的操作,对端百度翻译接口会返回Error 998-Cookie超时的错误,目前没有什么好的解决方法,如果有哪位朋友知道的欢迎issue给我😄

翻译效果评估

Google翻译 > Baidu翻译 > 有道翻译

DEMO

星星之语's Blog

License

MIT