Skip to content

Instantly share code, notes, and snippets.

@shawnfeng0
Last active February 4, 2020 23:42
Show Gist options
  • Save shawnfeng0/b6b9134a33a5e72ee3c327dac0f312ee to your computer and use it in GitHub Desktop.
Save shawnfeng0/b6b9134a33a5e72ee3c327dac0f312ee to your computer and use it in GitHub Desktop.
Package trans command line translation software to realize automatic translation into Chinese when the input language is English
#!/bin/bash
target_language=$(trans -id ${!#} | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?m//g" | awk '$1=="Code" && $2!="zh-CN" {printf ":zh-CN"}')
trans $target_language "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment