-
Notifications
You must be signed in to change notification settings - Fork 38
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
Fix music images items in other languages #1014
Fix music images items in other languages #1014
Conversation
Correction of displaying pictures in different languages. The category options values were translated into different languages and the translated values could not be checked against the values from icon.jres.
Уlement layout fixes, for more readable blocks
@jwunderl But I have another question. I want to make it so that long words are wrapped with a hyphen. I want to do something so that the text in Russian translation is displayed even better. |
@jwunderl please see changes |
Co-authored-by: Joey Wunderlich <jwunderl@users.noreply.github.com>
Co-authored-by: Joey Wunderlich <jwunderl@users.noreply.github.com>
@jwunderl indeed pxt.Util.userLanguage() works. I also found this in other files, but did not have time to try to apply it here. If this English conditional change doesn't work for some reason, you can undo it... |
The tag is not needed for English, because in the html tag it is already always set.
@jwunderl I checked, everything works. This change can be considered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought I merged / bumped this one, must have gotten distracted, sorry! Thanks for the pr!
The problem has existed for a long time, icons for elements with music are not displayed.
If you look, then in Russian an undenfined error appears in the console.
buttonImg.src = this.getSoundIcon(category);
Here are some examples. English language.
That's it in Russian.
(These are pictures from the beta version.)
The problem was that if you enable another language on the site (for example, Russian), then the options values were taken with a translation in the selected language. They didn't match the category values (in English) in icons.jres.
Therefore, I decided to change it so that options sorting is disabled so that options do not change places in different languages.
Next, I from the initially obtained values
soundIconCache = JSON.parse(pxtTargetBundle.bundledpkgs['music']['icons.jres']);
I recycle the object so that all elements are with indices
soundIconCacheArray = Object.entries(soundIconCache);
I remove the first element from my array, it is not needed. Interferes.
soundIconCacheArray.shift();
const categories = this.getCategories(options);
Then I look up the index in the array with all the categories of the category element
const categoryIndex = categories.indexOf(category);
Further, to set the picture for the musical element, I pass this index to getSoundIcon.
buttonImg.src = this.getSoundIcon(categoryIndex);
I checked in several languages. The changes are working.
As a result, we get this...