Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use to-jyutping Package, Strict Typing, Migrate to Manifest Version 3 #8

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 40 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
name: Build
name: Lint & Build

on:
push:
release:
types:
- created
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- created

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install opencc
- name: Build
run: python build.py
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: inject-jyutping
path: |
_locales
background_scripts
content_scripts
icons
lib
popup
manifest.json
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4

- name: Install dependencies
run: npm i

- name: Run lint
run: npm run lint

- name: Upload artifact
if: ${{ github.event_name == 'release' }}
uses: actions/upload-artifact@v4
with:
name: inject-jyutping
path: |
_locales
background_scripts
content_scripts
icons
lib
popup
manifest.json
node_modules/webextension-polyfill/dist/browser-polyfill.min.js
node_modules/to-jyutping/dist/index.js
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/jyut6ping3.dict.yaml
/jyut6ping3.simple.dict.yaml
/background_scripts/dictionary.json.txt
/preprocess.py
/lib/browser-polyfill.js
/inject-jyutping.zip
inject-jyutping.zip
node_modules
DS_Store
jsconfig.tsbuildinfo
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 2-Clause License

Copyright (c) 2020, Cantonese Computational Linguistics Infrastructure Development Workgroup
Copyright (c) 2024, Cantonese Computational Linguistics Infrastructure Development Workgroup
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
<h1>Inject Jyutping <ruby>幫<rt>bong1</rt></ruby> <ruby>漢<rt>hon3</rt></ruby> <ruby>字<rt>zi6</rt></ruby> <ruby>標<rt>biu1</rt></ruby> <ruby>粵<rt>jyut6</rt></ruby> <ruby>拼<rt>ping3</rt></ruby></h1>

呢個係一個可以幫網頁上面嘅漢字自動標註粵拼嘅 Chrome 同 Firefox 插件,係學習粵拼同粵語嘅強大工具。
呢個係一個可以幫網頁上面嘅漢字自動標註粵拼嘅 Chrome、FirefoxEdge 擴充功能,係學習粵拼同粵語嘅強大工具。

A browser extension for Mozilla Firefox and Google Chrome that adds Cantonese pronunciation (Jyutping) on Chinese characters, a powerful tool for learning Cantonese and Jyutping.
A browser extension for Google Chrome, Mozilla Firefox, and Microsoft Edge that adds Cantonese pronunciation (Jyutping) on Chinese characters, a powerful tool for learning Cantonese and Jyutping.

項目靈感來自 [EYHN/Furigana](https://github.com/EYHN/Furigana)。
<h2>Install <ruby>安<rt>on1</rt></ruby> <ruby>裝<rt>zong1</rt></ruby></h2>

This project is inspired by [EYHN/Furigana](https://github.com/EYHN/Furigana).
- [Chrome Web Store](https://chrome.google.com/webstore/detail/inject-jyutping/lfgpgjkjglogbndlkikjgbbfoiofbdjp)
- [Firefox Browser Add-On](https://addons.mozilla.org/firefox/addon/inject-jyutping/)

<h2>Install <ruby><rt>on1</rt></ruby> <ruby><rt>zong1</rt></ruby> </h2>
<h2>Preview <ruby><rt>jyu6</rt></ruby> <ruby><rt>laam5</rt></ruby></h2>

- [Chrome Web Store](https://chrome.google.com/webstore/detail/inject-jyutping/lfgpgjkjglogbndlkikjgbbfoiofbdjp)
- [Firefox Browser Add-On](https://addons.mozilla.org/en-US/firefox/addon/inject-jyutping/)

<h2>Build <ruby>編<rt>pin1</rt></ruby> <ruby>譯<rt>jik6</rt></ruby> </h2>

See [`.github/workflows/build.yml`](.github/workflows/build.yml).

<h2>Screenshot <ruby>截<rt>zit6</rt></ruby> <ruby>圖<rt>tou4</rt></ruby> </h2>

![](./demo.jpg)
![Demo](./demo.jpg)
2 changes: 1 addition & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"message": "Inject Jyutping"
},
"popupCheckboxText": {
"message": "Inject automatically(<ruby class=\"inject-jyutping\">自<rp>(</rp><rt lang=\"yue-Latn\">zi6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">動<rp>(</rp><rt lang=\"yue-Latn\">dung6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">注<rp>(</rp><rt lang=\"yue-Latn\">zyu3</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">入<rp>(</rp><rt lang=\"yue-Latn\">jap6</rt><rp>)</rp></ruby>)"
"message": "Inject automatically"
},
"refreshPromptText": {
"message": "Please refresh the page for the change to take effect."
Expand Down
8 changes: 4 additions & 4 deletions _locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"message": "ja"
},
"extensionName": {
"message": "粵拼を注入"
"message": "粤拼を注入"
},
"extensionDescription": {
"message": "漢字に広東語の発音(粵拼)を付ける。"
"message": "漢字に広東語の発音(粤拼)を付けます。"
},
"contextMenuItemDoInjectJyutping": {
"message": "粵拼を注入"
"message": "粤拼を注入"
},
"popupCheckboxText": {
"message": "オート注入(<ruby class=\"inject-jyutping\">自<rp>(</rp><rt lang=\"yue-Latn\">zi6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">動<rp>(</rp><rt lang=\"yue-Latn\">dung6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">注<rp>(</rp><rt lang=\"yue-Latn\">zyu3</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">入<rp>(</rp><rt lang=\"yue-Latn\">jap6</rt><rp>)</rp></ruby>)"
"message": "自動で注入"
},
"refreshPromptText": {
"message": "変更を有効にするには、ページを再読み込みしてください。"
Expand Down
20 changes: 20 additions & 0 deletions _locales/ko/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"langCode": {
"message": "ko"
},
"extensionName": {
"message": "월병(粵拼)을 주입"
},
"extensionDescription": {
"message": "한자에 광동어의 발음(월병/粵拼)을 붙인다."
},
"contextMenuItemDoInjectJyutping": {
"message": "월병(粵拼)을 주입"
},
"popupCheckboxText": {
"message": "자동으로 주입"
},
"refreshPromptText": {
"message": "변경사항을 적용하려면 페이지를 다시 로드하세요."
}
}
2 changes: 1 addition & 1 deletion _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"message": "注入粤拼"
},
"popupCheckboxText": {
"message": "<ruby class=\"inject-jyutping\">自<rp>(</rp><rt lang=\"yue-Latn\">zi6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">动<rp>(</rp><rt lang=\"yue-Latn\">dung6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">注<rp>(</rp><rt lang=\"yue-Latn\">zyu3</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">入<rp>(</rp><rt lang=\"yue-Latn\">jap6</rt><rp>)</rp></ruby>"
"message": "自动注入"
},
"refreshPromptText": {
"message": "请刷新页面使更改生效。"
Expand Down
4 changes: 2 additions & 2 deletions _locales/zh_HK/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"message": "注入粵拼"
},
"popupCheckboxText": {
"message": "<ruby class=\"inject-jyutping\">自<rp>(</rp><rt lang=\"yue-Latn\">zi6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">動<rp>(</rp><rt lang=\"yue-Latn\">dung6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">注<rp>(</rp><rt lang=\"yue-Latn\">zyu3</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">入<rp>(</rp><rt lang=\"yue-Latn\">jap6</rt><rp>)</rp></ruby>"
"message": ""
},
"refreshPromptText": {
"message": "請刷新頁面使更改生效。"
"message": "請重新載入頁面以使變更生效。"
}
}
4 changes: 2 additions & 2 deletions _locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"message": "注入粵拼"
},
"popupCheckboxText": {
"message": "<ruby class=\"inject-jyutping\">自<rp>(</rp><rt lang=\"yue-Latn\">zi6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">動<rp>(</rp><rt lang=\"yue-Latn\">dung6</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">注<rp>(</rp><rt lang=\"yue-Latn\">zyu3</rt><rp>)</rp></ruby><ruby class=\"inject-jyutping\">入<rp>(</rp><rt lang=\"yue-Latn\">jap6</rt><rp>)</rp></ruby>"
"message": ""
},
"refreshPromptText": {
"message": "請刷新頁面使更改生效。"
"message": "請重新載入頁面以使變更生效。"
}
}
25 changes: 25 additions & 0 deletions background_scripts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import '/node_modules/webextension-polyfill/dist/browser-polyfill.min.js';
import '/node_modules/to-jyutping/dist/index.js';
import '/lib/MessageManager.js';

/* Communicate with content script */

browser.runtime.onConnect.addListener(port => {
/** @type { MessageManager<{ convert(msg: string): [string, string | null][] }> } */
const mm = new MessageManager(port);
mm.registerHandler('convert', ToJyutping.getJyutpingList);
});

/* Context Menu */

browser.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === 'do-inject-jyutping') {
browser.tabs.sendMessage(tab?.id || 0, { name: 'do-inject-jyutping' });
}
});

browser.contextMenus.create({
id: 'do-inject-jyutping',
title: browser.i18n.getMessage('contextMenuItemDoInjectJyutping'),
contexts: ['page'],
});
54 changes: 0 additions & 54 deletions background_scripts/main.js

This file was deleted.

22 changes: 0 additions & 22 deletions build.py

This file was deleted.

File renamed without changes.
Loading