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

I'm an idiot in need to consult a Geriatrician. #29

Closed
Lisias opened this issue Sep 17, 2022 · 7 comments
Closed

I'm an idiot in need to consult a Geriatrician. #29

Lisias opened this issue Sep 17, 2022 · 7 comments
Assignees
Labels
bug Something isn't working Not My Fault Not my Fault! I'm innocent! :)
Milestone

Comments

@Lisias
Copy link

Lisias commented Sep 17, 2022

Somehow (and I really failed to understand how the devs managed to accomplish this one), KSP is failing to load the displayName attribute from the Localization file for the ResourceInfo data structure of a Resource. [edit : mystery solved]

Weird enough, the damned thing worked fine on pt-br Localization.

So, the following code:

GUILayout.Toggle (GetResourceFlags (pr.resourceName, 1) == 1, Localizer.Format(/* Pump {0} */"#GPOSP-pump", pr.info.displayName))
GUILayout.Toggle (GetResourceFlags (pr.resourceName, 2) == 2, Localizer.Format(/* Balance {0} */"#GPOSP-balance", pr.info.displayName))

Will produce this result on a en-us installment:
Screen Shot 2022-09-16 at 13 58 46

But will produce this one on a localized one (only pt-br tested to this moment):
Screen Shot 2022-09-16 at 16 20 52

This misnbehaviour is happening since KSP 1.4.3, so it's a pretty old bug. [edit: KSP is fine, I was wrong.]

On the bright side, it's virtually impossible that nobody else got hit by this before, so I'm looking for the solution on google and github. [edit: so it is that I found the problem when I decided to look on the right place!!]

@Lisias Lisias added bug Something isn't working Not My Fault Not my Fault! I'm innocent! :) labels Sep 17, 2022
@Lisias Lisias self-assigned this Sep 17, 2022
@Lisias Lisias changed the title KSP is failing to properly load EN-US (!!) Localization for ResourceInfo.displayName KSP is failing to properly ~~load~~ apply EN-US (!!) Localization for ResourceInfo.displayName Sep 17, 2022
@Lisias Lisias changed the title KSP is failing to properly ~~load~~ apply EN-US (!!) Localization for ResourceInfo.displayName KSP is failing to properly apply EN-US (!!) Localization for ResourceInfo.displayName Sep 17, 2022
@Lisias Lisias changed the title KSP is failing to properly apply EN-US (!!) Localization for ResourceInfo.displayName KSP is failing to properly apply EN-US (!!) on Localizer.Format (!!!) Sep 17, 2022
@Lisias
Copy link
Author

Lisias commented Sep 17, 2022

Now I was caught with my pants down!!!!!!

The following code:

		string displayName = string.IsNullOrEmpty(pr.info.displayName) ? "" : pr.info.displayName.Trim();
		displayName = string.IsNullOrEmpty(displayName) ? pr.resourceName : displayName;
		Log.force("displayName `{0}` `{1}` `{2}`", displayName, pr.resourceName, pr.info.displayName);
		SetResourceFlags(pr.resourceName, GetResourceFlags(pr.resourceName, ~1) | (GUILayout.Toggle(GetResourceFlags(pr.resourceName, 1) == 1, Localizer.Format(/* Pump {0} */"#GPOSP-pump", displayName)) ? 1 : 0));
		SetResourceFlags(pr.resourceName, GetResourceFlags(pr.resourceName, ~2) | (GUILayout.Toggle(GetResourceFlags(pr.resourceName, 2) == 2, Localizer.Format(/* Balance {0} */"#GPOSP-balance", displayName)) ? 2 : 0));

when running on a en-us localized KSP (from 1.4.3 to 1.12.3), give me on KSP.log:

[LOG 23:25:30.407] [GPOSpeedPump] displayName `Xenon Gas` `XenonGas` `Xenon Gas`

What's completely right! But yet, I have on GUI:

Screen Shot 2022-09-16 at 23 32 02

And yet, when running on a pt-br localized game, things works as expected on GUI!

It's, apparently, a problem on Localizer.Format but only when using en-us localisation (or, alternatively, the damned thing only works with pt-br???).

I'm pretty at lost on this one….

@Lisias
Copy link
Author

Lisias commented Sep 17, 2022

Changing the issue Tittle to reflect the findings.

@Lisias Lisias changed the title KSP is failing to properly apply EN-US (!!) on Localizer.Format (!!!) I'm an idiot in need to consult a Geriatrician. Sep 17, 2022
@Lisias
Copy link
Author

Lisias commented Sep 17, 2022

Found the problem. This is one of the most embarrassing misdiagnosing of my career… #facePalm

Everything is working fine on KSP. The en-us localization was not working because I dumbly shoved {0} on the string, instead of <<1>> as it's expected by Localization.Format.

it's working on pt-br because I did right on that file.

(sigh).

Fixing the mess.

@Lisias
Copy link
Author

Lisias commented Sep 17, 2022

"fixed" on commit d924ef1 .

Screen Shot 2022-09-17 at 00 04 05

Now I will kick 1.9.0.8 trough the door, get some fries and bacon and a bottle of cheap wine on the nearest shop and stay away from computers until the Sun shines, curing the hangover and smoothing the face.

@Lisias Lisias closed this as completed Sep 17, 2022
@Lisias Lisias added this to the 1.9.0.7 milestone Sep 17, 2022
@zer0Kerbal
Copy link
Collaborator

Found the problem. This is one of the most embarrassing misdiagnosing of my career… #facePalm

Everything is working fine on KSP. The en-us localization was not working because I dumbly shoved {0} on the string, instead of <<1>> as it's expected by Localization.Format.

it's working on pt-br because I did right on that file.

(sigh).

Fixing the mess.

I've done that innumerable times, seriously - I have a massive issue remembering what is zero based, and what is one based in all things programming!

@zer0Kerbal
Copy link
Collaborator

I took today off to avoid that same fate - smelling the 🔥 a little 🔥

will update and push the revised docs tomorrow after the 🌞 shines!

only two questions remain:

  • what is the name of this release? Goo Strikes Again? (but in PT-BR?)
  • when/who is pushing what to CF? will wait for two (or more) weeks to let it 🍲 and 🎈 before sending (who) to SD/CKAN

and most ‼️ 🙇‍♂️ thank you.

@Lisias
Copy link
Author

Lisias commented Sep 17, 2022

  • what is the name of this release? Goo Strikes Again? (but in PT-BR?)

What about "O Retorno de Goo" :)

when/who is pushing what to CF? will wait for two (or more) weeks to let it 🍲 and 🎈 before sending (who) to SD/CKAN

I will do it Saturday (well, today) by noon, and SpaceDock/CKAN Saturday night - assuming no one (including me) finds something in the mean time.

Stupid mistakes are social beings, it's not unusual that you find more once the first shows up - so it's better to spend a bit of time playing it tomorrow morning looking for something weird. Just in case….

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Not My Fault Not my Fault! I'm innocent! :)
Projects
None yet
Development

No branches or pull requests

2 participants