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

Allow more localisation in skin editor #30231

Merged
merged 5 commits into from
Oct 16, 2024

Conversation

SchiavoAnto
Copy link
Contributor

@SchiavoAnto SchiavoAnto commented Oct 11, 2024

This PR allows for more strings in the skin editor to be localised.

As a note, I wanted to localise the dropdown below as well, but the strings it uses come from Description attributes which expect a constant, so they cannot be passed a LocalisableString (or its value), so not sure how to proceed with that.

image

@Joehuu
Copy link
Member

Joehuu commented Oct 11, 2024

As a note, I wanted to localise the dropdown below as well, but the strings it uses come from Description attributes which expect a constant, so they cannot be passed a LocalisableString (or its value), so not sure how to proceed with that.

If you use VSCode and similarly other IDEs, you can use the "quick fix" feature where the raw string is underlined with three dots:

Code_I8UCLueMpr.mp4

I saw the documenting how to localise discussion. Might get the time to document this for you and others.

@SchiavoAnto
Copy link
Contributor Author

Oh thank you, I knew to use that method to add new strings, but I added them manually for this PR because adding translations to SkinSelectionHandler would have created another file, while I thought it would be better to use SkinEditorStrings instead.

I will add them now and commit.

@Joehuu
Copy link
Member

Joehuu commented Oct 11, 2024

Oh thank you, I knew to use that method to add new strings, but I added them manually for this PR because adding translations to SkinSelectionHandler would have created another file, while I thought it would be better to use SkinEditorStrings instead.

What you did is right (putting the strings in SkinEditorStrings). You can first use that method to auto generate the line (with CommonStrings quick-fix), then moving it to where applicable.

@SchiavoAnto
Copy link
Contributor Author

I accidentally committed, but it looks like it doesn't work?

[LocalisableDescription(typeof(SkinEditorStrings), nameof(SkinEditorStrings.HUD))]

I used this on all of the enum entries but it shows as the entry's name.

image

@Joehuu
Copy link
Member

Joehuu commented Oct 11, 2024

You would have to change these lines:

if (Ruleset == null) return Lookup.GetDescription();
return $"{Lookup.GetDescription()} (\"{Ruleset.Name}\" only)";

to use GetLocalisableDescription().

@SchiavoAnto
Copy link
Contributor Author

Yes, I figured, thank you.

I think this is now fine, the only other thing that would be left to do is to localise the (\"{Ruleset.Name}\" only) text but not sure how it could be done while respecting language-specific rules (the "only" going before or after the ruleset).

@Joehuu Joehuu self-requested a review October 12, 2024 01:44
@@ -31,9 +31,9 @@ public GlobalSkinnableContainerLookup(GlobalSkinnableContainers lookup, RulesetI

public override string ToString()
{
if (Ruleset == null) return Lookup.GetDescription();
if (Ruleset == null) return Lookup.GetLocalisableDescription().ToString();
Copy link
Member

Choose a reason for hiding this comment

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

This will always fallback to English. Unsure how to restructure this to not use ToString().

Copy link
Contributor

@smoogipoo smoogipoo Oct 12, 2024

Choose a reason for hiding this comment

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

I will harken back to my ruleset skinning configuration PR which added the target to the ISkinComponentLookup interface:

https://github.com/smoogipoo/osu/blob/ruleset-component-skinnin-redux/osu.Game/Skinning/ISkinComponentLookup.cs

https://github.com/smoogipoo/osu/blob/70edf15f21b3cc08668122a32ea6f49151528003/osu.Game/Overlays/SkinEditor/SkinEditor.cs#L753-L770

I still believe this is a valid path.

Otherwise, expose a Name property. There were other reasons why I moved Target into the base interface in my PR, but that would be enough for this one particular use in the interim.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just saw this, I don't really know how this would be implemented as I don't fully understand the code flow.

I was planning to open another PR to localise the gameplay overlay (during autoplay and replays), but I will wait for this in case there's the need for GetLocalisableDescription.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think both the special dropdown path from here as well as adding a name property sound fine, but maybe for simplicity let's just revert this specific change for now so that this doesn't get blocked on it?

Copy link
Contributor Author

@SchiavoAnto SchiavoAnto Oct 14, 2024

Choose a reason for hiding this comment

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

I'm fine with reverting the dropdown localisation for now. I think of reverting fc1ebfd and 9cd7f2b, as without the former the dropdown entries look confusing (#30231 (comment))

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, reverted.

@bdach bdach merged commit 5fff632 into ppy:master Oct 16, 2024
11 of 13 checks passed
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.

4 participants