-
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
Deferred translation class with optional context for option/effect/item-action names #26402
Conversation
src/effect.cpp
Outdated
new_etype.name.push_back( jsarr.next_string() ); | ||
translation name; | ||
if( !jsarr.read_next( name ) ) { | ||
debugmsg( "Error reading effect names" ); |
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.
It would be better to call jsarr.throw_error
to generate an exception along with a proper JSON context.
src/translations.h
Outdated
@@ -19,6 +19,10 @@ | |||
#define translate_marker_context(c, x) x | |||
#endif | |||
|
|||
#include <string> | |||
#include "json.h" |
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.
Don't include "json.h" here, it's quite large and has more dependencies. You don't need to derive from JsonDeserializer
, having a deserialze
function with proper signature is enough.
Have you considered to adding a This means you don't need to add |
Will close #24102? |
|
@BrettDong I'll adapt the script as a tool for locally testing translations then. |
I'm not sure about it. It could of course make the code less verbose, but I'm concerned that if someone wants to use the class in more places, and happens to forget to change the variable from |
…lation # Conflicts: # lang/extract_json_strings.py
I see you've changed the Python scripts to use some Python 3-isms, rather than Python 2. This is not really about this PR, but the |
Thanks, I'll change them to python3 since |
5e77e4d
to
39ca634
Compare
Summary
SUMMARY: I18N "Deferred translation class with optional context for option/effect/item-action names"
Purpose of change
There are several places in both cpp and json code where a word with multiple meanings is used without translation context. This makes it hard to translate the given strings in some other languages. This PR adds the ability to specify a translation context in these cases.
Closes #21760.
Describe the solution
xgettext
call inupdate_pot.sh
is updated so it also searches for the constructor of the translation class;merge_po.sh
is updated to disable fuzzy matching and remove obsolete strings;(I'm not sure about this one. The .po files in the repo does not have fuzzy matching nor obsolete strings, but maybe they are not removed in the script for a reason? @BrettDong shouldmerge_po.sh
be kept as is?)Additional context
I need comments on the changes to the shell and python scripts, as I'm not very familiar with the languages.
The following are some screenshots showing the changes with this PR. I've marked relevant text with English so it's easier to see what is changed.
Before:
Item action menu:
The translations for "play - handheld game machine" and "smoke - cigar" do not make sense here.
Options menu:
According to the translation, the option is "physically disabled".
Character info UI:
These translations are correct.
After (after generating, editing, and compiling .po files):
Item action menu:
Options menu:
Character info UI: