Skip to content
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

SCPUI Options Localization #5622

Merged
merged 8 commits into from
Oct 19, 2023

Conversation

MjnMixael
Copy link
Contributor

@MjnMixael MjnMixael commented Sep 23, 2023

Adds localization support to the SCPUI options builders. Because these are constructed before the localization system is initialized this includes a new method Lafiel and I came up with to set strings to XSTRs but delay their processing until localization has been initialized. I searched the code and the last built-in xstr I could find was 1673. But to be sure I started these at 1700. I know at least BtA uses 1674+ a few for Custom Controls. Since #5210 mapified the built-in strings, it's not essential that they be sequential anyway. Where possible I used existing options xstr IDs from the retail strings.tbl.

Additionally this cleans up all the options builders throughout the files to have consistent whitespace for readability.

@MjnMixael
Copy link
Contributor Author

MjnMixael commented Sep 23, 2023

For completeness sake, and safekeeping, here's a list of all the built-in XSTRs this adds.
new_xstrs.txt

};

static void lcl_delayed_xstr_internal(tl::optional<xstr_delayed_order> to_init) {
static SCP_vector<xstr_delayed_order> delayed_init;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a point of clarification before anyone asks:
delayed_init is very explicitly a static function variable as making it a global variable runs into issues of the order in which static globals are initialized, and it not being guaranteed to be initialized before the (also static global) option variables need to request a delayed XSTR. As a static function variable however, it is always guaranteed to be initialized by the time this function is called.
Yes, it does require this weird calling convention of fill the optional to add a value, keep it empty to fulfill the delayed XSTRs, but since this is an exclusively hidden part of the API, with any user just seeing the lcl_delayed_xstr function, it should be fine.

@wookieejedi wookieejedi added enhancement A new feature or upgrade of an existing feature to add additional functionality. localization / translation (XSTR) A feature or issue related to language localization and translations. labels Sep 23, 2023
@MjnMixael MjnMixael added the Requested by Active Mod A feature request that has been requested by a mod that is actively in development. label Oct 16, 2023
code/localization/localize.cpp Outdated Show resolved Hide resolved
TRBlount
TRBlount previously approved these changes Oct 18, 2023
@TRBlount
Copy link
Contributor

Not sure why but there is suddenly a merge conflict.

# Conflicts:
#	code/camera/camera.cpp
@MjnMixael
Copy link
Contributor Author

Not sure why but there is suddenly a merge conflict.

Resolved

code/graphics/2d.cpp Outdated Show resolved Hide resolved
@TRBlount TRBlount self-requested a review October 18, 2023 18:29
@TRBlount TRBlount dismissed their stale review October 18, 2023 18:30

Double checking IDs

Copy link
Contributor

@TRBlount TRBlount left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now we're good.

@TRBlount TRBlount merged commit bfdf054 into scp-fs2open:master Oct 19, 2023
10 of 14 checks passed
@MjnMixael MjnMixael deleted the scpui_options_localization branch October 19, 2023 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or upgrade of an existing feature to add additional functionality. localization / translation (XSTR) A feature or issue related to language localization and translations. Requested by Active Mod A feature request that has been requested by a mod that is actively in development.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants