Data Localization
Fixes #3607
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
@sebastienros any comments here before I will move further
/cc @jtkech @jptissot @Skrypt
@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:
I had started to review ... will go on don't worry, very important
@sebastienros you asked me from the beginning to keep you in the loop, seem I enter in infinite loop 😄
@sebastienros any change to review this before 1.0.0 or shall we delay to 1.1.0?
Conflicts to resolve.
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 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.
I just waiting for Seb at that time ;) I can implement this feature in OCC and provide a worked prototype
It definitely needs to be added to OC.
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
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.
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
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.
Thanks @jtkech for your review, seem I will keep continue on this from today :)
@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
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.
I will try to make the build pass ASAP
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 :


What it should be :

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 }}
Maybe, but I can't repro in the latest dev branch.
@Skrypt I will check from my side while I'm working on this PR
Ok makes sense to rename to OrchardCore.DataLocalization for the module.
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.
Thanks @Skrypt for your commit I suffer last month from the Internet connection :( I will try to update the PR ASAP
@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 ;)
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 ...
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 ;)
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