嘛。懶得寫介紹,直接把 readme 拖過來了。目前 Homebrew 還沒 merge ,請自行編譯安裝。在 Mac 上運行完了就可以直接通過 iCloud 同步到所有設備上去了。
E 一個畫圖喵一年多沒寫代碼了,就這些,將就著用吧。
很慚愧,做了一點微小的貢獻,謝謝大家。
功能:
- 簡體中文(多音字)
- 繁體中文(多音字)
- 日本語
- 韓語
- 注音符號
- 過濾空格
建議運行的時候加上 -i 參數把所有的注音都重新設定,如果聯繫人只有中國人的話,可以加上 -j 和 -k 忽略掉日本語和韓語。
關於實現方式:
- 語言初次判斷用的 Core Foundation 的 tokenizer ,名字比較難判斷語言,所以後面還加了二次對比;
- 簡繁體中文和韓語用的都是很簡單的 CFStringTransform ,可以參考 NSHipster 的文章;
- 日語因為和中文有很多重合部分,用 CFStringTransform 無法處理, CFStringTransform 本身也沒提供 Kanji -> Romaji 的轉換選項,所以還是直接用了 Core Foundation 的 tokenizer 提取了 Latin transcription ;
- 過濾 accents and diacritcs 用的也是 CFStringTransform ;
- 去空格直接手拼 NSString ;
- API 用了 ABAddressBook ,如果誰有興趣也可以拿 Contacts 重新實現一遍。
ContactsUtil-PhoneticName
General
Add phonetic names to contacts. Supports all CJK characters and multiple formats.
Install
With Homebrew:
$ brew install contacts-phonetic
Compile on your own:
$ git clone https://github.com/Elethom/ContactsUtil-PhoneticName.git
$ cd ContactsUtil-PhoneticName
$ make install
Usage
-i, --ignore-existing
Ignore existing phonetic names. Use of this option will update all person entries in the address book.
-m, --keep-marks
Keep accents and diacritcs.
-s, --keep-spaces
Keep spaces between characters.
-c, --ignore-chinese
Ignore Chinese. (Will use Japanese Romaji if both are possible.)
-j, --ignore-japanese
Ignore Japanese. (Will use Chinese Pinyin if both are possible.)
-k, --ignore-korean
Ignore Korean.
Example:
$ contacts-phonetic
--------------------
Alice Alstromeria
--------------------
Dieter Rams
--------------------
Elethom Alstromeria
--------------------
ことり 椎名
椎名 1. Japanese (shiina); 2. Chinese (chuí míng). Select: Select: 1
Kotori Shiina
--------------------
直人 深澤
直人 1. Japanese (naoto); 2. Chinese (zhí rén). Select: Select: 1
深澤 1. Japanese (fukazawa); 2. Chinese (shēn zé). Select: Select: 1
Naoto Fukazawa
--------------------
研哉 原
研哉 1. Japanese (ken'ya); 2. Chinese (yán zāi). Select: Select: 1
原 1. Japanese (hara); 2. Chinese (yuán). Select: Select: 1
Ken'ya Hara
--------------------
License
This code is distributed under the terms and conditions of the MIT license.
Donate
You can support me by:
- sending me iTunes Gift Cards;
- via Alipay: [email protected]
- via PayPal: [email protected]
:-)