OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Data Localization

Open hishamco opened this issue 6 years ago • 65 comments

Fixes #3607

hishamco avatar Oct 03 '19 07:10 hishamco

I'm successfully able to export the dynamic data localization, here's what I got:

{
  "name": "",
  "displayName": "",
  "description": "",
  "author": "",
  "website": "",
  "version": "",
  "issetuprecipe": false,
  "categories": "",
  "tags": [],
  "steps": [
    {
      "name": "DynamicDataTranslations",
      "DynamicDataTranslations": {
        "Article1": {
          "en": "Article1",
          "fr": "Article1",
          "es": "Artículo1"
        },
        "Article2": {
          "en": "Article2",
          "fr": "Article2",
          "es": ""
        },
        "Article3": {
          "en": "",
          "fr": "",
          "es": "Artículo3"
        }
      }
    }
  ]
}

It's the time to tweak it little to add the group them by the context

hishamco avatar Oct 04 '19 14:10 hishamco

@sebastienros any comments here before I will move further

/cc @jtkech @jptissot @Skrypt

hishamco avatar Oct 20 '19 10:10 hishamco

@sebastienros any comments or should @hishamco keep going? Would love to see this one keep moving but it's dropped to the second page of PRs :worried:

jrestall avatar Oct 24 '19 23:10 jrestall

I had started to review ... will go on don't worry, very important

sebastienros avatar Oct 24 '19 23:10 sebastienros

@sebastienros you asked me from the beginning to keep you in the loop, seem I enter in infinite loop 😄

hishamco avatar Nov 06 '19 23:11 hishamco

@sebastienros any change to review this before 1.0.0 or shall we delay to 1.1.0?

hishamco avatar Nov 21 '19 16:11 hishamco

Conflicts to resolve.

agriffard avatar Oct 05 '20 13:10 agriffard

Sure, I will resolve them, but still need more work here, IMHO if this feature will be after 1.0.0 I can try to finalize it and ship it in Orchard Core Contrib at least we have a preview there, unless @sebastienros has another suggestion about when this feature should be shipped. Furthermore I think DataAnnotations Localization could go in 1.0.0 to avoid any breaking changes later

Thanks

hishamco avatar Oct 05 '20 13:10 hishamco

@hishamco This PR looks like a good start but where is the UI/Views/Controllers for adding translations on a Content Type or Field names? Ok, getting back on this tomorrow. Will test it and try to add some UI.

Skrypt avatar Dec 15 '20 07:12 Skrypt

I just waiting for Seb at that time ;) I can implement this feature in OCC and provide a worked prototype

hishamco avatar Dec 15 '20 08:12 hishamco

It definitely needs to be added to OC.

Skrypt avatar Dec 15 '20 14:12 Skrypt

It definitely needs to be added to OC.

Me too ;) what I'm suggested is to make real working prototype in OCC, after that we can continue here and hear the OC team opinions

BTW this supposed to be 1.1.0 feature If I remembered

hishamco avatar Dec 15 '20 14:12 hishamco

I think everyone will agree that we should not wait on 1.0 to start working on something 😅 I don't know about OC Contrib. I think this should be part of OC right out of the box.

Skrypt avatar Dec 15 '20 19:12 Skrypt

I don't know about OC Contrib. I think this should be part of OC right out of the box.

OCC is provide non official modules, themes and features for OC, of course this will be a part of OC but it needs a time to review and merge, I will try to keep this updated until Seb have a time to revise this

hishamco avatar Dec 15 '20 19:12 hishamco

Ok, though I can tell you that I will use this for myself, because this is a requirement I have to move forward with my website translations. I will work on a separate branch based on yours this week.

Skrypt avatar Dec 15 '20 20:12 Skrypt

Thanks @jtkech for your review, seem I will keep continue on this from today :)

hishamco avatar Dec 16 '20 07:12 hishamco

@Skrypt I didn't know who commit here, seems your avatar has been changed ;) I will update this PR soon, in case you want to do customization I rather prefer to copy the branch and start your customization, coz I build this PR with Seb suggestions

Thanks

hishamco avatar Dec 20 '20 09:12 hishamco

Yeah I won't add anything else on this branch. I will work on my own branch for the remaining. I just updated the PR hoping it would build. It does, but there is a unit test failing.

Skrypt avatar Dec 20 '20 16:12 Skrypt

I will try to make the build pass ASAP

hishamco avatar Dec 20 '20 17:12 hishamco

Something breaks the current .po file localizations harvesting in this PR. You can try and add a different culture than "en" and execute TheBlog recipe on a fresh tenant installation. You will see that the datetime is not properly formatted.

"Posted by admin on décembre 22, 2020" should be "Posté par admin le 22 décembre 2020" here based on "d MMMM yyyy" datetime format and other .po file localizations :

image

image

What it should be :

image

Skrypt avatar Dec 22 '20 22:12 Skrypt

It has been splitted in two with the owner PR and I updated the pot files recently: {{ "Posted by" | t }} <a href="#">{{ Model.ContentItem.Author }}</a> {{ "on {0}" | t: dateTime | raw }}

agriffard avatar Dec 22 '20 22:12 agriffard

Maybe, but I can't repro in the latest dev branch.

Skrypt avatar Dec 22 '20 22:12 Skrypt

@Skrypt I will check from my side while I'm working on this PR

hishamco avatar Dec 23 '20 08:12 hishamco

Ok makes sense to rename to OrchardCore.DataLocalization for the module.

Skrypt avatar May 10 '21 14:05 Skrypt

I'm trying to use it but so far I did not find the proper combination or JSON values 😢

{
  "name": "",
  "displayName": "",
  "description": "",
  "author": "",
  "website": "",
  "version": "",
  "issetuprecipe": false,
  "categories": [],
  "tags": [],
  "steps": [
    {
      "name": "DynamicDataTranslations",
      "DynamicDataTranslations": {
        "Dealer": {
          "Context": "Content Types",
          "Key": "Dealer",
          "Values": {"fr": "Marchand", "en": "Dealer"}
        },
        "MagazineAd": {
          "Context": "Content Types",
          "Key": "MagazineAd",
          "Values": {"fr": "Annonce revue", "en": "Magazine Ad"}
        }
      }
    }
  ]
}

Here is what I tried in the end to see if I can get it from the CultureDictionary. Will try again tomorrow. I added a D method in the RazorPage class so that we can use D["Something"]. I did not commit here yet though. Need to test more before.

RazorPage.cs

        /// <summary>
        /// The <see cref="IDataLocalizer"/> instance for the current view.
        /// </summary>
        public IDataLocalizer D
        {
            get
            {
                if (_d == null)
                {
                    _d = Context.RequestServices.GetRequiredService<IDataLocalizer>();
                }

                return _d;
            }
        }

This will surely throw a NRE when the module is not enabled, will need to probably have a NullDataLocalizer or something like that.

Skrypt avatar May 14 '21 04:05 Skrypt

Thanks @Skrypt for your commit I suffer last month from the Internet connection :( I will try to update the PR ASAP

hishamco avatar May 14 '21 06:05 hishamco

@sebastienros @Skrypt can we revise this, we need to push a first version of the dynamic localization then we can add more features, because it's hard to review a HUGE PR ;)

hishamco avatar Aug 19 '21 19:08 hishamco

I made a mistake. I meant that this PR should be what we are working on for 1.2 instead of the Data Annotations one. But would be good having both ...

Skrypt avatar Dec 09 '21 22:12 Skrypt

I think Data Annotations Localisation should comes first, I'm agree that this PR is very important and promising hope to be a part of OC 2.0.0 if not 1.2.0 ;)

hishamco avatar Dec 10 '21 06:12 hishamco

I planned to work to much on this PR, @sebastienros @Skrypt if there's any new thoughts about this please let me know or I will continue on what it's written in the earlier comments

hishamco avatar Feb 27 '22 08:02 hishamco