-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 footsteps translation #37402
Merged
ZhilkinSerg
merged 11 commits into
CleverRaven:master
from
8street:Fix_footsteps_translation
Jan 27, 2020
Merged
Fix footsteps translation #37402
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e3bb1b3
Merge pull request #1 from CleverRaven/master
8street b5d17e9
Merge pull request #2 from CleverRaven/master
8street df84d2a
Merge branch 'master' of https://github.com/8street/Cataclysm-DDA
8street 5c83410
Merge pull request #3 from CleverRaven/master
8street 5830f7d
Merge remote-tracking branch 'upstream/master'
8street 35e8708
Merge pull request #15 from CleverRaven/master
8street 790e2e1
Add translations tags
8street 1397119
Another fix
8street 5fdc6ac
Update src/monstergenerator.cpp
8street 5873a28
Change footsteps to transtalion type
8street a597cb1
Resolve conflict
8street File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
So it doesn't translate the string twice at line 892.
Also, as the code currently stands, the translation won't update when switching the language in game. Could you change the type of
footsteps
totranslation
and update the code accordingly to fix it and modernize the code?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.
Thanks for your review.
Could you provide a simple example?
footsteps
is defined in the following structure: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.
Change
std::string footsteps;
totranslation footsteps;
, and update the code where it is used. Useto_translation( "footsteps." )
to create the default value, andfootstep.translated()
to get the translated string.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 changed the type of variable. I'm not sure that everything is correct, please review it. In the game, this solution works, I tested.
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.
There were some performance considerations to do so when it was jsonized (see #31493)
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.
@ZhilkinSerg Should I return the type of the variable as it was before? Or leave it?
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.
We can investigate the performance problem anytime, but for now we support switching language without restart, so this ensures consistency. Also I don't think this particular string is used that frequently.
Anyway, here are two (immature) ideas of mine about performance optimization of the translation class: we can create a new class
cached_translation
, which stores an extra cached translated string and the language of the cached string (perhaps through an id or a reference), and in the next translation call, we check if the language has changed and update the cache accordingly. This of course requires a few more bytes per translation object for the cache.Or we can add raw strings and their translation to a central repository when creating
translation
objects, which then point to the translated strings through a reference. When switching the language, we iterate through the central repo and update the translated string with gettext calls, so the translation objects automatically point to the new translated strings. I think this one is superior since it not only addresses the performance issue, but also reduces the memory usage of the translation class.