Comments (12)
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.
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.
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.
I know what you mean exactly, let me create a unit test for that
from my.extensions.localization.json.
Great, thanks for being so fast to respond!
from my.extensions.localization.json.
@thomkle seems the culture fallback works fine with GetAllStrings()
but not localizer indexer
from my.extensions.localization.json.
@hishamco Ah, I see. I'll follow the status on #26
from my.extensions.localization.json.
It's already merged ;) feel free to use and try the latest bits
from my.extensions.localization.json.
Ah, great! I'll try out the last change. Could you push a NuGet package for it as well?
from my.extensions.localization.json.
@hishamco Seems to be working very well now, thanks!
from my.extensions.localization.json.
@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 methodGetTranslation
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.
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)
- Add Benchmark HOT 16
- Missing Localization Behavior
- Remove internal contructor in JsonStringLocalizer HOT 1
- Ability to override methods in JsonStringLocalizer and JsonStringLocalizerFactory HOT 9
- Registering the service one should provide absolute path, otherwise exception is thrown HOT 31
- Localization FallBack Considerations
- Support ResourceLocationAttribute HOT 1
- Support RootNamespaceAttribute
- assign culture in runtime HOT 3
- Have one resource file for project HOT 13
- Any plan to switch the project to a .NET standard class library ? HOT 10
- How to use with DataAnnotation? HOT 17
- Regression Bug HOT 1
- LocalizationSample project is not working HOT 3
- About NET5.0 Blazor WebAssembly Uses My.Extensions.Localization.Json HOT 14
- System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. HOT 11
- Class based localisation only works when the class is in the root namespace HOT 5
- Can you provide an core api example with DataAnnotations? HOT 2
- when using xunit test(SUT),there is an exception throwed! HOT 7
- JsonResourceManager does not dispose of (unix) File System Watches HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from my.extensions.localization.json.