掌上百科 - PDAWIKI

 找回密码
 免费注册

QQ登录

只需一步,快速开始

查看: 2725|回复: 2

[教程] Mdict字典转MacOS AppleDict

[复制链接]

该用户从未签到

发表于 2016-12-28 11:22:53 | 显示全部楼层 |阅读模式
本帖最后由 dgww 于 2016-12-28 11:22 编辑 2 ~8 P1 U  X' W! u
, R0 z, f8 s: m: v- X
转换目标:7w詞條!微軟必應雙向簡明詞典  https://www.pdawiki.com/forum/thread-16448-1-1.html ! t9 t: R2 Q/ i5 r

+ i5 ~4 F" W' B6 l+ U5 p转换工具:
9 Z6 B5 `9 K9 b# xhttps://github.com/ilius/pyglossary$ X9 X! X" @' Q/ u6 w' y. E4 @
https://github.com/SebastianSzturo/Dictionary-Development-Kit
6 E9 V; N- f, a, E; L3 B: u' f$ ~& g, ?. `* {$ t4 ]7 z
转换命令: 1 V  R; S+ f" B! l
  1. python3 pyglossary.pyw ~/Downloads/MBD/Microsoft\ Bing\ Dictionary.mdx ~/Desktop/Microsoft.bing.xml --read-format=OctopusMdict --write-format=AppleDict
复制代码

, f% G9 }) u7 {; _+ C
! ^' U+ V" ]7 l% w  C制作苹果字典:
; N9 {# n/ e( s4 j/ F! B把生成的Microsoft.bing/Microsoft.bing.xml 文件复制到Dictionary-Development-Kit目录,并修改对应的Makefile
4 f# ?% f9 w3 p9 t7 `0 m8 N
  1. DICT_NAME               =       "微軟必應雙向簡明詞典"
    8 _# G, f, P/ Y7 L
  2. DICT_SRC_PATH           =       MyDictionary.xml
    : G* ~: Y; c5 l, K
  3. CSS_PATH                =       MyDictionary.css# X& x+ v* P( J$ ~# G* D0 l" ~. z
  4. PLIST_PATH              =       MyInfo.plist
复制代码

2 K0 \; @' X. }5 L' ]5 H
3 c8 S% r/ N; R修改MyInfo.plist
+ X: ^1 h4 {1 E4 L8 f0 J' H
  1.         <key>CFBundleIdentifier</key>
    & |* j& Q% }+ ]0 z! Z- ]
  2.         <string>com.apple.dictionary.microsoft.bing70000</string>/ v9 [. S# ^* D
  3.         <key>CFBundleName</key>
    1 y0 L6 `6 N  b% E8 _! x  X6 }
  4.         <string>微軟必應雙向簡明詞典</string>
    3 e  j; p! `3 l8 v( K% n- r) K: e
  5.         <key>CFBundleShortVersionString</key>
复制代码
2 v5 d% Q6 S3 S) n% o
. p8 d: v' k) k
复制Mdict自带的css文件内容到MyDictionary.css,然后执行:
' w, y  V) `- V7 G6 A
  1. [~/Dictionary-Development-Kit/project_templates]$ make && make install
    ' d) Q) x2 J4 t. e9 R0 v
  2. """/Users/usr/Dictionary-Development-Kit"/bin"/build_dict.sh"  "微軟必應雙向簡明詞典" MyDictionary.xml MyDictionary.css MyInfo.plist$ K; c8 C# e1 E( a1 O7 ~( A; U7 e4 p
  3. - Building 微軟必應雙向簡明詞典.dictionary.: j" \+ s8 q  `
  4. - Cleaning objects directory.
    2 a8 h& u2 t9 v' t
  5. - Preparing dictionary template.9 C- Q# l- {3 z
  6. - Preprocessing dictionary sources.
    / H. \" L% S; T( W: n; v
  7. - Extracting index data.& Z, ~( h1 r1 n, g5 D
  8. - Preparing dictionary bundle.1 a* h. ]7 x/ j! _; s& t
  9. - Adding body data.
    6 G2 I# @* s- y2 l# T% A$ P
  10. - Preparing index data.) d- @; `  ]3 E" S9 S
  11. - Building key_text index.
    + o2 a+ _* J: L; D5 ~' ?0 [2 z
  12. - Building reference index.1 W3 ^! y6 b8 W+ @" l: v9 O
  13. * Note: No reference index record.
    ) C# s- W: Q/ L; K% i
  14. - Fixing dictionary property.
    ' v! Y& R  H# I) Y
  15. - Copying CSS.% H! b7 P5 e. B( {4 [& T0 q
  16. - Copying other resources.
    : H) C2 e. z  t9 \: `# }( r0 O) @
  17. - Finished building ./objects/微軟必應雙向簡明詞典.dictionary.' Z4 o7 v! H3 O
  18. echo "Done."
    . \1 x: ~0 I3 \9 O
  19. Done.
    2 g  Q9 P( Y7 O& A
  20. echo "Installing into ~/Library/Dictionaries".; c5 S4 H7 w" B2 m3 |8 r
  21. Installing into ~/Library/Dictionaries.0 t( ?. t- V+ D# D- I
  22. mkdir -p ~/Library/Dictionaries8 A! M7 e) E: I; h' ~  v. `
  23. ditto --noextattr --norsrc ./objects/"微軟必應雙向簡明詞典".dictionary  ~/Library/Dictionaries/"微軟必應雙向簡明詞典".dictionary
    9 Q  Z' [* [+ K) N( a  L: J
  24. touch ~/Library/Dictionaries
    . J$ q5 n/ g, M+ Q
  25. echo "Done."# y9 h* g6 g3 U7 n& a+ Z- p
  26. Done.
    9 o3 g0 p9 i$ o0 L6 p
  27. echo "To test the new dictionary, try Dictionary.app."
复制代码
. t( @( O: o7 Q  y

% c0 d) m# M4 J& s6 [7 B: n2 `, O. u* G: x
转换结果:0 ?5 O, s- W( |0 V! x+ y% v3 {

( j  h: n3 \$ r$ ^0 ]/ t$ z
7 W5 A/ ?: r$ G# l/ w

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?免费注册

x

评分

1

查看全部评分

本帖被以下淘专辑推荐:

  • · 工具|主题: 61, 订阅: 27

该用户从未签到

发表于 2016-12-29 17:49:24 | 显示全部楼层
本帖最后由 hexlec 于 2016-12-29 18:02 编辑 & H* L# T/ Z  `# B& m& L

7 D  a" u: p* f不错的教程,需要提醒下,Makefile 中的 ‘DICT_BUILD_TOOL_DIR’ 需要更改为 ‘Dictionary-Development-Kit’所在的绝对路径。
3 q0 b; J+ j0 {$ t8 ?1 g. G0 h* I例如在桌面的路径下,就需要这么更改:
  1. DICT_BUILD_TOOL_DIR="/Users/你的用户名/Project/My_Dictionary/Dictionary-Development-Kit"
复制代码

评分

1

查看全部评分

该用户从未签到

发表于 2017-1-3 12:09:05 | 显示全部楼层
目前看不懂,先马了。慢慢学习。感谢分享。
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

小黑屋|手机版|Archiver|PDAWIKI |网站地图

GMT+8, 2025-5-3 05:51 , Processed in 0.026511 second(s), 31 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表