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

How to use resources in seperate project? #12492

Closed
stg609 opened this issue May 22, 2019 — with docs.microsoft.com · 9 comments
Closed

How to use resources in seperate project? #12492

stg609 opened this issue May 22, 2019 — with docs.microsoft.com · 9 comments
Labels
Pri2 Priority 2 Source - Docs.ms Docs Customer feedback via GitHub Issue
Milestone

Comments

Copy link

stg609 commented May 22, 2019

Tried different ways, but no luck. Hope there's a sample solution tell us how to make it.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added the Source - Docs.ms Docs Customer feedback via GitHub Issue label May 22, 2019
@Rick-Anderson Rick-Anderson added Pri2 Priority 2 PU labels May 22, 2019
@Rick-Anderson Rick-Anderson added this to the Backlog milestone May 22, 2019
@Rick-Anderson
Copy link
Contributor

@stg609 tried what? What didn't work? What did you expect?

@stg609
Copy link
Author

stg609 commented May 22, 2019

What did I expected?
We expect there's an official guideline to show us how to make use of the localized resource in a seperate project. Because we can't get it to work after google a lot.

What didn't work?
Following the doc, we can get the localized string as expected. But after we moved the whole resources folder to another project, than we can't get the localized string anymore.

What did we tried?
1、Ensure the project name is the same as the default assembly name
2、Create a AssemblyInfo.cs, and add [assembly: ResourceLocation("Resources")]
3、Remove the ResourcePath when calling services.AddLocalization

None of them works.

I have created a repo if anyone needed.

@Rick-Anderson

@hishamco
Copy link
Member

hishamco commented Jun 5, 2019

@stg609 please check the troublshooting section before I dig into your code?

@Rick-Anderson
Copy link
Contributor

This is not a localization issue. It's a getting resources from another project issue that should probably be opened with Visual Studio feedback.

@hishamco
Copy link
Member

hishamco commented Jun 5, 2019

This may caused by ResourceLocation, RootNamespace or miss localization configuration

@LazZiya
Copy link

LazZiya commented Jul 8, 2019

Tried different ways, but no luck. Hope there's a sample solution tell us how to make it.

I've created a sample repo with resources in external project, you may see it here.

The sample is based on the basic Asp.Net Core 2.2 template and it contains:

  • Custom (route) RequestCultureProvider
  • Custom IStringLocalizer
  • Localization of :
    • Views
    • DataAnnotations
    • IdentityErrorDescriber error messages
    • Model binding and model validation error messages
    • Client side validation error messages
  • Client side validation of localized input for different cultures (e.g. 12,34 and 12.34)
  • All using shared resources

Notice: In the releases after v0.0.3 I moved the resources to the main project folder just to simplify the sample for beginners.

@hishamco
Copy link
Member

hishamco commented Aug 2, 2019

@Rick-Anderson can we closed this while the issues has been answered and there's no respond from the author

Copy link

okofahi commented Dec 20, 2019

i still cannot resolve this issue.
The main project cannot display the localized strings from the Models class library.

@hishamco
Copy link
Member

@okofahi do you a repo that reproduce the bug, but before that please check the troubleshooting guidance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pri2 Priority 2 Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

6 participants