-
Notifications
You must be signed in to change notification settings - Fork 276
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
Hard code time to leave string in window title #931
Hard code time to leave string in window title #931
Conversation
Codecov Report
@@ Coverage Diff @@
## main #931 +/- ##
==========================================
- Coverage 70.38% 70.25% -0.14%
==========================================
Files 27 27
Lines 2161 2165 +4
Branches 323 323
==========================================
Hits 1521 1521
- Misses 640 644 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
You could instead use document.title to change the page from within the renderer pages. Then you can also update the preferences page title with the language update.
https://stackoverflow.com/a/6715344
I tried using document.title to change the title. Is that what you suggested me to do, or did I miss something? |
@SarahRemus you can add this call to the document ready block in workday waiver.js and preferences.js. In preferences you can add another call to document.title in the callback to language changed. |
I'm having a really hard time implementing your suggestions. On another note, I'm not sure if this is the smart way to go. Typically, a user only changes the language preference once. With the implementation I proposed before ( However, if we change the title with |
Hi @SarahRemus, you can check https://github.com/thamara/time-to-leave/blob/3040f66028c1df445b580b61eef80e4244d3daeb/src/preferences.js#L37 to see the language data that is returned by the main process to the renderer process once the language is changed.
We already have this glitch with the theme loading, so if we add the delay, it'll fix both issues at once. But we can open another issue to add this delay, you don't need to add it here. We also already have today the Preferences title changing as the page loads. |
Okay now I think I finally get what you @araujoarthur0 mean! :) Sorry it took me so long. I think now everything is working as you suggested. |
I was reviewing the code once more, and I think there is a better place to add the translation code rather than what I suggested before 😥
If you do this, you don't have to add the two pieces of code you added to preferences.js, as |
Okay, I moved the functionality into |
Thanks! I'm just not seeing the changes in locales\en\translation.json yet. |
I must have overlooked that! Thanks for pointing it out, I included the changes. |
\changelog-update |
Related issue
Closes #912
Context / Background
At the moment, the Time to Leave string is part of the translations. In particular, it concerns these cases: Preferences - title, WorkdayWaiver - title.
This can cause potential errors in the translation when the translator is translating the time-to-leave string as well (which should not be the case). It happened before in issue https://github.com/thamara/time-to-leave/issues/861 where the title was translated in Hindi and Gujarati.
What change is being introduced by this PR?
Instead of setting the title of the Preference and WorkdayWaiver window in the respecting html file, I set the title where the new Browser window is created with
prefWindow.setTitle(Time to leave - ${getCurrentTranslation('$Preferences.title')})
.This way, Time to leave can't be translated on accident.
If you would like to use this solution, we have to remove the time-to-leave string from all translation files. I just wanted to wait with this until I know if you want to proceed with this solution.
Without removing the string from the translation file, the time-to-leave title is currently shown twice in the window title. Just wanted to mention that, so you are not confused what's going on.
If the language is changed, the title of the preference window will only update once the window is closed. But I think that is the case for all translations set not directly in the html file?
How will this be tested?
Open the Preference or WorkdayWaiver window. You will see the title Time to leave - Time to leave - Preferences/ Workday Waiver which is the expected behavior at the moment and shows that the first time-to-leave string is set in js.