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

Support for NuGet Packages with Language Packages #632

Open
hackerzhuli opened this issue Mar 25, 2024 · 6 comments
Open

Support for NuGet Packages with Language Packages #632

hackerzhuli opened this issue Mar 25, 2024 · 6 comments

Comments

@hackerzhuli
Copy link

hackerzhuli commented Mar 25, 2024

Description

I tried to install the Humanzier package. The core package worked but the language packages are not working. I inspected the files that are downloaded by NuGetForUnity and found that the actual assemblies that contains the localized strings are not downloaded, even though the folders for language packages are there. Is it a limitation of Unity that .NET language packages does not work, or is it a limitation of NuGetForUnity?

  • NuGet Package: Humanizer 2.14.1
  • NuGetForUnity Version: 4.0.2
  • Unity Version: 2022.3.15f1
  • Operating System: Windows 10

Why this is important

If the limitation is not caused by Unity, then I think this improvement is very useful for anyone who need to use a NuGet package with language packages.

If the limitation is caused by Unity, then I think it will be great if you can put this information in the documentation of NuGetForUnity and explain why language packages are not supported, it will be very helpful for others who encountered the same issue.

@JoC0de
Copy link
Collaborator

JoC0de commented Mar 25, 2024

Hi @hackerzhuli
thanks for creating the issue.
Currently we skip / delete the localization resource files.
See e.g. the content of Humanizer.Core.de https://nuget.info/packages/Humanizer.Core.de/2.14.1
image
It contains a file with the name: Humanizer.resources.dll, the file name is the same for all languages Unity doesn't support multiple assemblies (.dll) with the same name in one project.
I never testet if it would be possible to get the resources to work if the files are renamed. I don't know how the system behind the localized resources work in normal dotnet. Unity uses a different build / runtime than normal .net so not everything works directly.

@hackerzhuli
Copy link
Author

hackerzhuli commented Mar 26, 2024

@JoC0de Thank you for your prompt response. I guess I'll have to modify the source code of Humanizer to enable localization in Unity.

@JoC0de
Copy link
Collaborator

JoC0de commented Mar 26, 2024

Did you try copy pasting the dlls to unity manually?

@hackerzhuli
Copy link
Author

What I found about language packages of Humanizer in Unity.

Summary

I tried to copy dlls manually and here is what I find:

  1. Unity does not have compile errors when the language package dll's names are the same when multiple of them are in the project
  2. Only one of the language package dll (of Humanizer language packages) would work if multiple of them are in the project
  3. Any one of the language package dll (of Humanizer language packages) would work if it is the only one in the project

Detailed Result

Here is my detailed test result.

When only fr language package (dll) is in the project. Console logs:

culture is en
2024/3/26 12:38:37 is humanized to yesterday
2024/3/25 12:38:37 is humanized to 2 days ago
2024/3/24 12:38:37 is humanized to 3 days ago
2024/3/23 12:38:37 is humanized to 4 days ago
2024/3/22 12:38:37 is humanized to 5 days ago
2024/3/21 12:38:37 is humanized to 6 days ago
2024/3/20 12:38:37 is humanized to 7 days ago
2024/3/19 12:38:37 is humanized to 8 days ago
2024/3/18 12:38:37 is humanized to 9 days ago
2024/3/17 12:38:37 is humanized to 10 days ago

culture is fr-FR
2024/3/26 12:38:37 is humanized to hier
2024/3/25 12:38:37 is humanized to avant-hier
2024/3/24 12:38:37 is humanized to il y a 3 jours
2024/3/23 12:38:37 is humanized to il y a 4 jours
2024/3/22 12:38:37 is humanized to il y a 5 jours
2024/3/21 12:38:37 is humanized to il y a 6 jours
2024/3/20 12:38:37 is humanized to il y a 7 jours
2024/3/19 12:38:37 is humanized to il y a 8 jours
2024/3/18 12:38:37 is humanized to il y a 9 jours
2024/3/17 12:38:37 is humanized to il y a 10 jours

culture is de-DE
2024/3/26 12:38:37 is humanized to yesterday
2024/3/25 12:38:37 is humanized to 2 days ago
2024/3/24 12:38:37 is humanized to 3 days ago
2024/3/23 12:38:37 is humanized to 4 days ago
2024/3/22 12:38:37 is humanized to 5 days ago
2024/3/21 12:38:37 is humanized to 6 days ago
2024/3/20 12:38:37 is humanized to 7 days ago
2024/3/19 12:38:37 is humanized to 8 days ago
2024/3/18 12:38:37 is humanized to 9 days ago
2024/3/17 12:38:37 is humanized to 10 days ago

When only de language package (dll) is in the project. Console logs:

culture is en
2024/3/26 12:43:55 is humanized to yesterday
2024/3/25 12:43:55 is humanized to 2 days ago
2024/3/24 12:43:55 is humanized to 3 days ago
2024/3/23 12:43:55 is humanized to 4 days ago
2024/3/22 12:43:55 is humanized to 5 days ago
2024/3/21 12:43:55 is humanized to 6 days ago
2024/3/20 12:43:55 is humanized to 7 days ago
2024/3/19 12:43:55 is humanized to 8 days ago
2024/3/18 12:43:55 is humanized to 9 days ago
2024/3/17 12:43:55 is humanized to 10 days ago

culture is fr-FR
2024/3/26 12:43:55 is humanized to yesterday
2024/3/25 12:43:55 is humanized to 2 days ago
2024/3/24 12:43:55 is humanized to 3 days ago
2024/3/23 12:43:55 is humanized to 4 days ago
2024/3/22 12:43:55 is humanized to 5 days ago
2024/3/21 12:43:55 is humanized to 6 days ago
2024/3/20 12:43:55 is humanized to 7 days ago
2024/3/19 12:43:55 is humanized to 8 days ago
2024/3/18 12:43:55 is humanized to 9 days ago
2024/3/17 12:43:55 is humanized to 10 days ago

culture is de-DE
2024/3/26 12:43:55 is humanized to gestern
2024/3/25 12:43:55 is humanized to vor 2 Tagen
2024/3/24 12:43:55 is humanized to vor 3 Tagen
2024/3/23 12:43:55 is humanized to vor 4 Tagen
2024/3/22 12:43:55 is humanized to vor 5 Tagen
2024/3/21 12:43:55 is humanized to vor 6 Tagen
2024/3/20 12:43:55 is humanized to vor 7 Tagen
2024/3/19 12:43:55 is humanized to vor 8 Tagen
2024/3/18 12:43:55 is humanized to vor 9 Tagen
2024/3/17 12:43:55 is humanized to vor 10 Tagen

When both fr and de language packages (dll) are in the project. No compile errors are found. Console logs:

culture is en
2024/3/26 12:47:23 is humanized to yesterday
2024/3/25 12:47:23 is humanized to 2 days ago
2024/3/24 12:47:23 is humanized to 3 days ago
2024/3/23 12:47:23 is humanized to 4 days ago
2024/3/22 12:47:23 is humanized to 5 days ago
2024/3/21 12:47:23 is humanized to 6 days ago
2024/3/20 12:47:23 is humanized to 7 days ago
2024/3/19 12:47:23 is humanized to 8 days ago
2024/3/18 12:47:23 is humanized to 9 days ago
2024/3/17 12:47:23 is humanized to 10 days ago

culture is fr-FR
2024/3/26 12:47:23 is humanized to yesterday
2024/3/25 12:47:23 is humanized to 2 days ago
2024/3/24 12:47:23 is humanized to 3 days ago
2024/3/23 12:47:23 is humanized to 4 days ago
2024/3/22 12:47:23 is humanized to 5 days ago
2024/3/21 12:47:23 is humanized to 6 days ago
2024/3/20 12:47:23 is humanized to 7 days ago
2024/3/19 12:47:23 is humanized to 8 days ago
2024/3/18 12:47:23 is humanized to 9 days ago
2024/3/17 12:47:23 is humanized to 10 days ago

culture is de-DE
2024/3/26 12:47:23 is humanized to gestern
2024/3/25 12:47:23 is humanized to vor 2 Tagen
2024/3/24 12:47:23 is humanized to vor 3 Tagen
2024/3/23 12:47:23 is humanized to vor 4 Tagen
2024/3/22 12:47:23 is humanized to vor 5 Tagen
2024/3/21 12:47:23 is humanized to vor 6 Tagen
2024/3/20 12:47:23 is humanized to vor 7 Tagen
2024/3/19 12:47:23 is humanized to vor 8 Tagen
2024/3/18 12:47:23 is humanized to vor 9 Tagen
2024/3/17 12:47:23 is humanized to vor 10 Tagen

Conclusion

The reason only one of language packages would work in Unity is probably because they have the same assembly name (Humanizer.resources).

@JoC0de
Copy link
Collaborator

JoC0de commented Mar 27, 2024

Interesting.
What happens if you rename them to Humanizer.de.resources.dll and Humanizer.fr.resources.dll. As far as I found out they are not dynamically loaded by Humanizer so only unity needs to be tricked to include the file.

@hackerzhuli
Copy link
Author

I tried to change the names of language packages' dll files, but it makes no difference. I guess Unity just doesn't support localization in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants