GithubHelp home page GithubHelp logo

Comments (12)

hishamco avatar hishamco commented on July 2, 2024

Any plans to support fallback-functionality?

Sure, let me check why this not included, I already support this in some OSS

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 2, 2024

FYI the fallback is here https://github.com/hishamco/My.Extensions.Localization.Json/blob/master/src/My.Extensions.Localization.Json/JsonStringLocalizer.cs#L119-L140

Are you sure it doesn't work, perhaps I need to add a unit test if it is not included yet

from my.extensions.localization.json.

thomkle avatar thomkle commented on July 2, 2024

That's really strange, to provide more accurate info:
I have a test.en-US.json, test.en.json and test.json (in the same folder) with the following content:

test.en-US.json

{
  "temp":  "test-en-US"
}

test.en.json

{
  "temp": "test-en",
  "temp2": "test-en"
}

test.json

{
  "temp": "test",
  "temp2": "test",
  "temp3": "test"
}

With an empty Test-class:

public class Test
{
}

And then trying to access the values using IStringLocalizer<Test> _localizer (injected into a controller) and _localizer["temp"] == "test-en-US" (which is correct), but _localizer["temp2"] == "temp2" and _localizer["temp3"] == "temp3".

Do you have an example where the fallback-functionality is used? Maybe I'm missing something.

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 2, 2024

I know what you mean exactly, let me create a unit test for that

from my.extensions.localization.json.

thomkle avatar thomkle commented on July 2, 2024

Great, thanks for being so fast to respond!

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 2, 2024

@thomkle seems the culture fallback works fine with GetAllStrings() but not localizer indexer

from my.extensions.localization.json.

thomkle avatar thomkle commented on July 2, 2024

@hishamco Ah, I see. I'll follow the status on #26

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 2, 2024

It's already merged ;) feel free to use and try the latest bits

from my.extensions.localization.json.

thomkle avatar thomkle commented on July 2, 2024

Ah, great! I'll try out the last change. Could you push a NuGet package for it as well?

from my.extensions.localization.json.

thomkle avatar thomkle commented on July 2, 2024

@hishamco Seems to be working very well now, thanks!

from my.extensions.localization.json.

thomkle avatar thomkle commented on July 2, 2024

@hishamco Sorry to nag, but the fallback doesn't seem to work completely. E.g. say I have set the culture "es-ES", but there are no files .es-ES.json, but I have a .json. It will not fall back to values in .json. I also tested this creating unit tests after cloning the repo and it looks that the unit test fails.
Reproduction steps:

  • Add a Test.json with the content { "Hello": "Hello there" }
  • In the JsonStringLocalizerTests for the method GetTranslation add the inline data: [InlineData("es-ES", "Hello", "Hello there")]. This will fail, but this kind of fallback should work, right?

I'll be happy to try to solve this my self and create pull requests, but I understand if you're more comfortable with solving things in the project yourself :)

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 2, 2024

Could you push a NuGet package for it as well?

I'm not sure for now, but may be a pre release version will be fine

from my.extensions.localization.json.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.