melborne / togglate

A tool for creating a base text of translation
MIT License
18 stars 1 forks source link

原文との比較を行う方法 #8

Closed gosyujin closed 10 years ago

gosyujin commented 10 years ago

ローカルにcloneした文書(Togglateで原文コメントアウト済、翻訳文章追加済)と、特定リビジョンの原文を比較し、 原文に差異がないか確認するコマンドが欲しいので作成してみました。

https://github.com/gosyujin/togglate/commit/8d66b935e496d0fd032e1fd015781926bc5dfe84

大まかな動作としては、

  1. git remote add togglate で原文取得用のリモートリポジトリをGitに登録する
  2. togglate diff コマンドに 比較したいファイル 特定のリビジョン を渡す
    1. ローカルの 比較したいファイルtogglate commentout で原文だけにする
    2. リモートリポジトリ togglate から 特定のリビジョン比較したいファイル を取得してくる
    3. i. ii. のファイルのdiffを取る

こんな感じになります。(Jekyllの原文ドキュメントに対してdiffをとる) 翻訳したリビジョンを対象とする場合。

$ git remote -v
(略)
togglate    https://github.com/jekyll/jekyll.git (push)
$ bundle exec togglate diff docs/configuration.md --revision 5daf987 --difference site
Local doc: docs/configuration.md
Original doc url: https://raw.githubusercontent.com/jekyll/jekyll/5daf987/site/docs/configuration.md
 GitHub user: jekyll
 GitHub repository: jekyll
 Revision: 5daf987
Diff result: OK

時間がたち、原文のリポジトリの master がかなり進んでNGとなる場合。

$ bundle exec togglate diff docs/configuration.md --revision master --difference site
Local doc: docs/configuration.md
Original doc url: https://raw.githubusercontent.com/jekyll/jekyll/master/site/docs/configuration.md
 GitHub user: jekyll
 GitHub repository: jekyll
 Revision: master
--- docs/configuration.md_togglate_local    2014-04-28 01:29:52.138137854 +0900
+++ docs/configuration.md_togglate_original 2014-04-28 01:29:52.240138863 +0900
(略)
 markdown:      kramdown
-markdown_ext:  markdown,mkd,mkdn,md
+markdown_ext:  markdown,mkdown,mkdn,mkd,md
 textile_ext:   textile

 excerpt_separator: "\n\n"
Diff result: NG

良い案が思いつかなかったため diff という一般的すぎるコマンドで拡張してしまいましたが、 commentout コマンドの拡張とすべきとか 別のレイヤーでやるべき(元々は Rake で作っていました)とか 意見いただけたらと思います。 (ソース自体はもうちょっと整理しようと思っています)

melborne commented 10 years ago

togglateに対する提案ありがとうございます!Github上で翻訳をする上で、あったらかなり便利そうですね。

問題はtogglate側で何処までの機能を担うのがいいのかという議論があると思います。2つあると思います。

  1. togglateがdiffの機能を持つべきか。
  2. diffの機能を持つとしてGithubの使用を前提とした機能を持つべきか。

1についてはcommentoutコマンドを実装するときにも考えたのですが、そのときの自分の答えとしては「togglateは最小の機能を保ってdiffのことはdiffでやるべき」でした。これはtogglate側でdiffのすべてのオプションを持つのは現実的でないし、別実装のdiff(colordiffとか)を使いたいユーザもいると思ったからです。

@gosyujin さんからの提案を頂いて、便利そうと思う一方でdiffの取り込みに躊躇しているくらいなので、さらに2の機能を含んでいるものをtogglateに取り込むのはちょっと難しいかな、というのが率直な意見です。

ですので、折角のユニークな提案を頂けて喜んでいるのですが、現状のtogglateの方向性としては別レイヤーのほうが収まりがいいと考えています。

gosyujin commented 10 years ago

ありがとうございます。 やっぱりTogglateに役割を持たせすぎですよね :cry:

  1. と 2. に関しては、melborne さんと同じようなことを 自分で書いていても思いました…。 (他のdiff使うにはとか、そもそもdiffまでやるべきかとか、原文はGitHub以外にもあるのではないかとか…)

現状やりたいこととしては既に Rake でできているので特に問題ないのですが、 (Rakefile の中での Togglate の役割は togglate commentout でローカルにある文書のピックアップに使うものとしている) もっと汎用化して組み込めないかなーと思った次第です。

gosyujin commented 10 years ago

issueとしてはcloseしておきます。

melborne commented 10 years ago

折角のいい提案すいません :disappointed: