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

Interact with localizaton #1266

Merged
merged 10 commits into from
Apr 12, 2022
Merged

Conversation

andy840119
Copy link
Member

It's the base implementation of trying to translate the karaoke ruleset.
The full step of adding localization can see #1265

What's done in this PR:

  • Install package for localization hint and auto-generate the class.
  • Add dotnet tool.json for able to generate the localization resource file(.resx)
  • Create the localization class for testing purposes.
  • Create the localization resource file.

@andy840119 andy840119 added the enhancement New feature or request label Apr 8, 2022
@andy840119 andy840119 added this to the 2022.0416 milestone Apr 8, 2022
@andy840119 andy840119 self-assigned this Apr 8, 2022
@andy840119
Copy link
Member Author

Let's test on the release build

@andy840119
Copy link
Member Author

andy840119 commented Apr 8, 2022

image
Seems not working in the release build.
Need to check the reason.

[update]
image
Got no idea why zh.resx and ja.resx is missing while packing.
Checked by the dotpeek.

[another update]
image
Got no idea why the resource is still missing in the local debug build, but Japanese localization can be loaded in the osuGame test scene.

@andy840119
Copy link
Member Author

andy840119 commented Apr 8, 2022

Also, not really sure should place the localization file into:

  • <root>/Localisation -> will let the code and file in the same namespace.
  • <root>/Resources/Localisation -> need to setup .editorconfig and deal with Duplicated resource issue(NETSDK1022)

@andy840119
Copy link
Member Author

Make the reference:
https://crowdin.com/project/karaoke-dev
The translation is available here.

@andy840119
Copy link
Member Author

andy840119 commented Apr 8, 2022

Check:

  • is all language can be found in the resources dll

image
Damn, got no idea why some of the localization files are missing(or not visible?)

@andy840119
Copy link
Member Author

andy840119 commented Apr 9, 2022

image
But it's OK to catch the fall-back localization fie(?) in the release environment.
So seems it might have an issue getting another kind of localization file?

@andy840119
Copy link
Member Author

andy840119 commented Apr 9, 2022

todo:

[update]
Tested in this code, but seems it's only able to read the resource file.

 new StreamReader(matchingAssembly.GetManifestResourceStream("osu.Game.Rulesets.Karaoke.Localisation.KaraokeSettingsSubsection.resources")).ReadToEnd()

@andy840119
Copy link
Member Author

andy840119 commented Apr 9, 2022

Seems it's the issue related to the return manager.GetString(key, EffectiveCulture); in ResourceManagerLocalisationStore. It's only able to get the default localization.
Or the localization does not pack well in the release build.
Very not sure.

Not sure related to those kinds of issues:
dotnet/android#4664
https://stackoverflow.com/questions/33274715/wrong-culture-string-from-resourcemanager-getstring

@andy840119 andy840119 marked this pull request as draft April 9, 2022 03:15
@smoogipoo
Copy link

smoogipoo commented Apr 11, 2022

Hmm.. So it looks like you need the osu.Game.Rulesets.Karaoke.resources.dll files placed inside /bin/{Debug/Release}/netstandard2.1/{locale}/. Copying them inside the osu.Desktop/bin/Debug/net6.0/{locale} dirs seems to work for me.

Can you confirm this is the case?

Bundling the localisation files alongside the ruleset also seems to work, like:
image

This would be a .NET ResourceManager localisation, it needs those files and can't search inside the parenting assembly... Not sure how to handle this yet but it's a good find. I would say that bundling the localisation files as above is a reasonable solution for now.

@andy840119
Copy link
Member Author

Big thanks for the testing for this issue 🙏🏼 .
I might test this issue in a few days in the osx.

@andy840119
Copy link
Member Author

andy840119 commented Apr 11, 2022

Tested, both way works in the osx.

But have some (maybe) bad news:

  • I have made traditional chinese(zh-TW) localization as well, but seems the folder(zh-TW) and resource file doesn't generated.
  • Trying to packing them as single dll, but this way seems doesn't work.(Checked that the resource is inside the dll)
    image

@smoogipoo
Copy link

but seems the folder(zh-TW) and resource file doesn't generated

This is weird. It looks like it needs to be called zh-Hant for it to be generated. I've made an issue tracking this here: ppy/osu-localisation-analyser#44.

Trying to packing them as single dll, but this way seems doesn't work

Yeah, that's why I mentioned ResourceManager doesn't search the parenting assembly. I noticed you're using IL repack 😄

@andy840119
Copy link
Member Author

andy840119 commented Apr 12, 2022

Conclusion:

  • Will working if copy the osu.Game.Rulesets.Karaoke.resources.dll into the right position.
  • zh-TW localization resource file not generated issue is fixing.

Guess it's harmless if merged.
Will open another issue if has another new progress(e.g: zh-TW issue or found a new way to deal with the localization or interact with CI).

Also, might open another issue for packing the localization resource file as zip for users who wants to use the localization with release build.

@andy840119 andy840119 marked this pull request as ready for review April 12, 2022 12:23
@andy840119 andy840119 added the still have bug This pull request still have some bug label Apr 12, 2022
@andy840119 andy840119 merged commit b26adb4 into karaoke-dev:master Apr 12, 2022
@andy840119 andy840119 deleted the localization branch April 12, 2022 12:27
@smoogipoo
Copy link

After ppy/osu#17785, you'll be able to rename it to zh-Hant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/XL still have bug This pull request still have some bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants