Skip to content

feat: make glossary entries work in other languages #687

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

Conversation

Wolfy7
Copy link
Contributor

@Wolfy7 Wolfy7 commented Oct 2, 2022

Please check if the PR fulfills these requirements:

  • The commit message follows our guidelines.
  • For bug fixes and features:
    • You tested the changes.

Related issue (if applicable): #685

What kind of change does this PR introduce?
Emit the "translation_changed" signal from the TranslationManager when the language is set.
Listen to this signal in UILesson.gd and trigger the new defined function _underline_glossary_entries for Underline glossary entries.

@Wolfy7
Copy link
Contributor Author

Wolfy7 commented Oct 2, 2022

If changes are okay, please label it for Hacktoberfest
Thank you 😊

@NathanLovato
Copy link
Contributor

NathanLovato commented Oct 3, 2022

Thanks for the help! This currently doesn't work because it tries to underline the English keywords in other languages. For example, in Spanish, "function" becomes "función" so we should underline the work "función" when the language is set to Spanish.

To achieve that, you'll need to update _glossary.replace_matching_terms() (or generally the glossary script) to compile and use regexes in the target language.

The way it works right now is we make a big regex with all the glossary terms to find and use a regex replace to find and underline them. But it's only done in English.

Let me know if you have any questions or need a hand.

@Wolfy7
Copy link
Contributor Author

Wolfy7 commented Oct 3, 2022

Yes, you right.
This will just fix that if you switch the language from english to another language and back again to english, that then the word from the glossary are underlined again.

To handle this for other languages like Spanish, there are more work to do. As you already wrote.

I will think about it how to archive this, if you have already something in mind i would appreciate if you shared it with me 😊

Should this done with an addtional PR or in this one?

Thank you for your help.

@NathanLovato
Copy link
Contributor

Thanks. I'd prefer this to be done in this PR because otherwise, fixing this bug the way it's currently done will introduce a separate bug for people using other languages. We might as well handle both cases at once.

@Wolfy7
Copy link
Contributor Author

Wolfy7 commented Oct 3, 2022

If we create/read the glossary after TranslationManager is ready and also recreate it after a languange switch.
It should work without changing _glossary.replace_matching_terms()

But not completely sure if these changes are wanted.

@NathanLovato
Copy link
Contributor

Rebuilding the glossary on a language change and changing the highlighted keywords at that time sounds good to me, it's a good approach!

@Wolfy7
Copy link
Contributor Author

Wolfy7 commented Oct 4, 2022

I did these changes in my last commit 959c670

In my test it works as expected:
image

image

Edit:
Looking at the scrrenshots im not sure now if the "term" is really correct 🤔

@NathanLovato NathanLovato linked an issue Oct 4, 2022 that may be closed by this pull request
@NathanLovato NathanLovato changed the title fix: underline glossary entries even after language switch feat: make glossary entries work in other languages Oct 4, 2022
@NathanLovato
Copy link
Contributor

Great work André. The issue was small, you were trying to translate the capitalized term in the glossary entries but then that would not match translation strings.

I just moved the capitalize() call after the tr() call.

image

@NathanLovato NathanLovato merged commit 8cf215c into GDQuest:main Oct 4, 2022
@Wolfy7
Copy link
Contributor Author

Wolfy7 commented Oct 4, 2022

Thank you Nathan.

Just want to use the change, writing with you. To say Thank you! of course to you and the whole GDQuest-Team.
I follow your YouTube-Channel since years, and every video is a pleasure to watch.

But also to all the work you (GDQuest) put into the OpenSource-Community, the GameDevelopment community.
I'm pleasured to work on your amazing products.

So, yeah im not so good with words. But wanted to let you know. An just once again Thank you..

@NathanLovato
Copy link
Contributor

Thanks :)

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

Successfully merging this pull request may close these issues.

Glossary does not work after switching languages
2 participants