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

Added Zhuyin column in wordlist #30

Closed
wants to merge 18 commits into from
Closed

Conversation

kenxjy
Copy link

@kenxjy kenxjy commented Oct 20, 2019

I quite like using this extension, however, I personally use both Zhuyin and Pinyin for learning Mandarin. I actually prefer Zhuyin as it helps me distance myself from English. I find it helps me with my pronunciation.

I like the wordlist feature, but I wished it had a Zhuyin column to help me copy over stuff to Anki more easily. So... I implemented it myself, and I figured I would share this for anyone else wanting this feature as well.

I reused the "Show Zhuyin phonetic symbols" option to toggle displaying the Zhuyin column in the wordlist. It is not backwards compatible with any previously saved wordlist, it will just show a dash as it's Zhuyin.

image

In the example photo above, the bottom entry is an example of an older wordlist entry that is missing the Zhuyin property.

js/wordlist.js Outdated

let wordList = localStorage['wordlist'];
let zhuyinConfig = (localStorage['zhuyin'] === 'yes');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename the variable to showZhuyin or zhuyinVisible.

@Hirse
Copy link
Contributor

Hirse commented Oct 21, 2019

I'm not the owner of the repo, but I like this and I have two suggestions:

  1. Instead of the dash it might be nice to show a ? icon with a tooltip that explains why this is empty.
  2. Could you (maybe in a different PR) add functionality for only showing the traditional/simplified column depending on the setting?

@kenxjy
Copy link
Author

kenxjy commented Oct 21, 2019

I'm not the owner of the repo, but I like this and I have two suggestions:

1. Instead of the dash it might be nice to show a `?` icon with a tooltip that explains why this is empty.

2. Could you (maybe in a different PR) add functionality for only showing the traditional/simplified column depending on the setting?

I changed the default text to a tooltip that explains what happened. That was a good idea.

As for a setting that only shows traditional/simplified column, that's also not a bad idea. Perhaps in the future.

@kenxjy
Copy link
Author

kenxjy commented Oct 21, 2019

image

Example photo of the tooltip.

@Hirse
Copy link
Contributor

Hirse commented Oct 21, 2019

Thanks for the changes.

As far as I know, the wordlist page is already using Bootstrap. As such, I would recommend using their tooltip implementation so you don't have to add one yourself (and to keep it consistent).

For the tooltip text, I would be more specific like: "Zhuyin was added to the wordlist after this entry was saved and is only available for new entries."

@cschiller
Copy link
Owner

I think if the Zhuyin column is present it should always show a value in every row. There should not be any missing Zhuyin values. This behavior would be really confusing to the user. Since Zhuyin is derived from Pinyin it should be fairly easy to determine it on the fly. In this case there would also be no need for a tooltip.

As for only showing traditional or simplified characters, I believe this only adds unnecessary complexity. The main purpose of the built-in word list is that the dictionary entries can be exported into a tool like Anki. For example, if you don't like simplified characters, then you just don't map this column in the Anki importer. I don't think people will use the word list itself for studying. It's just meant to be used as an exporter for the CC-CEDICT dictionary entries you're interested in studying (plus the derived Zhuyin for convenience, maybe).

@kenxjy
Copy link
Author

kenxjy commented Oct 22, 2019

It should generate Zhuyin from the Pinyin. This will avoid having to use the tooltip for missing Zhuyin values, and like previously mentioned, avoid any confusion for the user. I decided any generated Zhuyin get saved to the wordlist, this way it doesn't need to be generated again.

zhuyin.js Outdated
return zhuyin;
}

let zhuyinTones = ['?', '', '\u02CA', '\u02C7', '\u02CB', '\u30FB'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be const?
(Actually applies to all let in this file I think.)

manifest.json Outdated
@@ -49,6 +50,7 @@
"web_accessible_resources": [
"css/*",
"js/*",
"images/*"
"images/*",
"zhuyin.js"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes more sense to move it to js/zhuyin.js.

js/wordlist.js Outdated
Comment on lines 33 to 34
let tone = getToneNumber(py);
let syllable = removeToneMarker(py, tone) + tone;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like these to calls could be combined in one function (pinyinToSyllable for example).
Right now it was a bit confusing to read.

js/wordlist.js Outdated
syllables.push(syllable);
});

let zhuyin = syllables.reduce((zhuyin, syllable) => zhuyin + mapToZhuyin(syllable) + ' ', '').trimEnd();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is also in content.js.
Can you extract it to the zhuyin file?

js/wordlist.js Outdated
@@ -3,6 +3,13 @@
Copyright (C) 2010-2019 Christian Schiller
https://chrome.google.com/extensions/detail/kkmlkkjojmombglmlpbpapmhcaljjkde
*/
const utones = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why utones?
Are these the markers for the tones in pinyin?

content.js Outdated
Comment on lines 935 to 941
let utones = {
1: '\u0304',
2: '\u0301',
3: '\u030C',
4: '\u0300',
5: ''
};
// let utones = {
// 1: '\u0304',
// 2: '\u0301',
// 3: '\u030C',
// 4: '\u0300',
// 5: ''
// };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your changes. 👍

I'm not sure about moving these though.
They seem to be used in non-zhuyin contexts too so they don't necessarily fit into that file.
Maybe @cschiller has a decision whether to include them.
(Either way, commented code should be removed.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. I left the comments in! Doh!

Copy link
Author

@kenxjy kenxjy Oct 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your changes. +1

I'm not sure about moving these though.
They seem to be used in non-zhuyin contexts too so they don't necessarily fit into that file.
Maybe @cschiller has a decision whether to include them.
(Either way, commented code should be removed.)

I was wondering about this too. I was trying to avoid duplicate variables that contain the same constants.

Edit: typo.

@cschiller
Copy link
Owner

I added this feature in version 5.8.0. I made it so that the zhuyin attribute is never saved to local storage. It is always generated on the fly. This saves some space and it allows for bugfixes if a mapping problem is discovered.

@hugolpz
Copy link

hugolpz commented Aug 12, 2020

I added this feature in version 5.8.0. I made it so that the zhuyin attribute is never saved to local storage.

Should the pull request be closed then ?

@kenxjy kenxjy closed this Aug 12, 2020
@kenxjy
Copy link
Author

kenxjy commented Aug 12, 2020

I added this feature in version 5.8.0. I made it so that the zhuyin attribute is never saved to local storage.

Should the pull request be closed then ?

Good point. There's no reason to leave it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants