AlexTeixeira / Askmethat-Aspnet-JsonLocalizer

Json Localizer library for .NetStandard and .NetCore Asp.net projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alternate File Configuration

davious opened this issue · comments

would you add support for an alternate file layout configuration?

example 1
Resources/localization.en-US.json
Resources/localization.fr-FR.json

example 2
Resources/en-US/localization.json
Resources/fr-FR/localization.json

Hi,

If you think is a quite good thing, this can be an improvement.

Today if the same key is found, the value is not considered. I can change the code to merge values instead.

Hi,

After a look it should work.
Do you want to filter the loaded files from culture ?

I came across this thread and looking for a similar way to load json files that allows sharing of translated files with frontend libraries such as ngx-translate.

They store files in i18n/{locale}.json format eg. i18n/en-US.json

Sample JSON file:

{
  "Area": {
    "TITLE": "Bonjour Angular avec ngx-translate !",
    "SELECT": "Changer la langue"
  }
}

Hi,

Yep, currently it's impossible to have this format.
You need to provide the Culture.

To add this feature, this is a huge work in the JSON file loading process.
Currently, I can't do it, I don't have enough time.

Hi @AlexTeixeira,
I'm interesting in using this alternate config, separating JSON files by language.

We are working with this format:

View1.json

{
  "text_1": {
    "Values": {
      "en": "Englisht Text 1",
      "es": "Spanish Text 1"
    }
  },
  "text_2": {
    "Values": {
      "en": "English Text 2",
      "es": "Spanish Text 2"
    }
  }
}

We need to work with this format or similar:

View1.es.json

{
  "text_1": {
    "Value": "Spanish Text 1"
  },
  "text_2": {
    "Value": "Spanish Text 2"
  },
}

View1.en.json

{
  "text_1": {
    "Value": "Englisht Text 1"
  },
  "text_2": {
    "Value": "Englisht Text 2"
  },
}

or simpler without "Value" node:

{
  "text_1": "Spanish Text 1",
  "text_2": "Spanish Text 2"
}

It would be possible?

Thanks for considering my request.

Hi,

I let this issue open. When I will have some free time to work in this feature, I will try to add this feature.

Hi,

After a look it should work.
Do you want to filter the loaded files from culture ?

Hi @AlexTeixeira,

Is this feature available? I only want to separate localization file by languages, the schema can be same.

Thanks

Hi everyone,

The version 3.0.0-preview1 will have the I18n file configuration.
Let me know if you find an issue and something that is not compliant with the needs.

I will set the release in final after your feedbacks.

Hi @AlexTeixeira

Great news!
I will test the change and I will give you feedback.

Thanks

Hi,
is it possible to configure each json file per local?
found it in the frontpage 😅
why this issue still open tho?