bash - 标题的Onfly翻译
问题描述
我使用Hugo来构建我的网站,其中包含多个语言部分。我经常专注于文本,以至于忘记翻译文件的标题。
title: "This is the title"
date: 2020-03-01
shorttext: "Here come the shorttext in for the blog cards"
...
现在的问题是,当我使用 grep 成为 title/shorttext 的入口并通过 translation-shell 命令进行管道传输时,如何将 translation-shell 的输出保存在 title/shorttext 的双引号中?
egrep 'shorttext:' $file | sed 's/shorttext: //g' | trans -brief -e bing :fr
"Ceci est un titre"
“Ceci est un titre”现在应该写入短文本后面的文件。有没有办法实现它?谢谢你的帮助
问候西尔维奥
解决方案
无论您获取翻译的命令是什么,您都可以在另一个sed
命令中使用命令替换,如
sed -E 's/(^shorttext: ).*/\1"'"$(egrep 'shorttext:' $file | sed ...)"'"/' your file
请注意,sed
替换命令被分成 3 个字符串,第一个和最后一个用单引号括起来,中间的一个用双引号括起来,以便在其中进行命令替换,"$(…)"
.
推荐阅读
- c# - 从 .Net Core 控制台应用程序更新 Firebase Firestore 中的文档
- excel - 参考多列删除列中的最后一个单元格
- java - 将 spring-boot 应用程序部署到云代工厂时出现 java.lang.NoSuchMethodException
- node.js - 如何将 nginx 与 adonis 一起使用?
- amazon-web-services - 什么是无服务器中的“hellostepfunc1”
- c# - ListView WPF中的ScrollHeader
- hmmlearn - 使用 hmmlearn 等于零的转换矩阵
- jenkins-pipeline - 在詹金斯管道中安全地传递 iam 角色
- python - 声明一个字符串的元组的最简洁方法
- regex - 使用正则表达式匹配字符串中的连续字符