Problem/Motivation
The "separator" used in daterange fields is not translatable. It should be.
Proposed resolution
Make it translatable. I believe the proper way to do this is to add "translatable" and "translation context" to the schemas for the separator formatter settings (someone please correct this if it is wrong).
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #44 | interdiff-39-44.txt | 877 bytes | mpdonadio |
| #44 | 2796151-44.patch | 6.14 KB | mpdonadio |
| #39 | 2796151-39.patch | 6.09 KB | mpdonadio |
Comments
Comment #2
mylies commentedAnd here a patch
I added a translatable config to schema, so for correct usage, need to reinstall module datetime_range
Comment #3
mpdonadioThanks for working on this!
We should provide a translation context here. How about 'Date range separator' ? Happens few times in the patch.
Since this is a config translation, we don't need this. t() is just for real strings provided by core.
I don't think we need test coverage of this since we have coverage of config schema translation in general.
If we add an empty update_N hook to the module, it will do a rebuild which should pick up the schema change.
Comment #4
mpdonadioI think this is how to do this, but I can't find this anywhere in admin/config/regional/config-translation
Comment #5
vijaycs85type: label is equivalent of string + translatable.
Comment #6
mpdonadioSeeing if we have an issue about translating field formatter settings. They aren't in the UI.
Comment #7
mpdonadioLooks like the formatter settings being translatable by the UI is a known issue, #2546212: Entity view/form mode formatter/widget settings have no translation UI
Comment #8
vijaycs85Looks good...
Comment #9
mpdonadioAdding @vijaycs85 to the commit list b/c he spent a while in IRC helping me dig through the UI issue (which I had totally forgotten about).
Comment #10
xjmActually adding credit for @vijaycs85. (Only committers can actually save values in the Credits & Committing section).
Patch looks good to me, and is RC-eligible since it only touches experimental code.
However, I have a question about the related issue, #2546212: Entity view/form mode formatter/widget settings have no translation UI. Does that prevent the separator we want to add here from being translated at all? If so maybe we should postpone on that issue, because we also need test coverage for this. If there's another way to provide a translation without needing the UI, then the test could exercise that method instead. @vijaycs85, any ideas?
Comment #11
vijaycs85Reg #9: thanks @mpdonadio :)
Reg #10: I don't think we have any other option to add/update the translation without the related issue getting in. We can see the translation UI using Configuration Inspector, but no way to add/update.
Comment #12
vijaycs85Just FYI, I applied the latest patch in #2546212: Entity view/form mode formatter/widget settings have no translation UI and the patch in #6 of this issue and able to see the translation.
Comment #13
penyaskitoWe can provide the language override in a test using the API. Is that better than postponing it?
Comment #14
gábor hojtsyI agree the fix looks good. If we want to test it, we can add an override with the API, the language manager makes it possible, @penyaskito and I have a session on this: http://www.slideshare.net/gabor.hojtsy/drupal-8-multilingual-apis slide 69 ;)
We do not yet have a UI to translate these due to #2546212: Entity view/form mode formatter/widget settings have no translation UI but I would consider the two bugs independent, since we did not make the rest of the entity mode translatable settings postponed either on not having a UI for them.
Comment #15
jhedstromThis adds a test, although I haven't worked much with config translation tests, so am unsure if this is what @Gábor Hojtsy was referring to.
Comment #18
penyaskitoThanks!
Yes, this is exactly what Gábor and I were referring to.
Should be setLanguage (see uppercase L)
I guess we should delete this debug line.
Just cosmetic, but let's assert with the exclamation sign if we put that in the translation.
Comment #19
mpdonadio#18-3, since this is a kernel test, I would leave this so that you can see the output from the UI, to be similar to what would happen from a drupalGet() ?
Comment #20
jhedstromThis addresses #18.2 and #18.4. I've left the verbose output as it is similar to other kernel tests in core as mentioned in #19.
Not sure why this was passing locally with that lower case 'l'.
Comment #23
mpdonadioBecause PHP: http://www.php.net/manual/en/functions.user-defined.php :
Reattaching #20 to see if it will run. Patch seems fine locally.
Comment #25
mpdonadioLet's try adding a @group, https://www.drupal.org/node/2680713
Comment #26
vijaycs85Looks good. +1 to RTBC
Minor rewrite to avoid those 4 lines of duplicate code. Don't think worth a re-roll just for this fix, but if we find some other issue, we can add it:
Comment #27
penyaskito#25 looks RTBC to me. I actually find it more readable without the patch at #26.
Comment #28
alexpottIt's not really a semantically a label. Of the existing core types the best fit is
type: text.I'm not sure whether this should be fixed in 8.2.x or is only eligible for 8.3.x because (a) new translatable strings (b) the hook_update_N
Comment #29
alexpottThis can be an empty update because a cache flush occurs if there is an empty function.
Comment #30
alexpottLet's fix in 8.3.x first and discuss 8.2.x eligibility once we've got this in.
Comment #31
gábor hojtsyWell, our handling of text is as a multiline text widget, and this is not that, is it? :) We can introduce yet another single line translatable string type to have a semantically more correct name for it for these cases, but would that simplify the choice of the type for single line translatable strings or complicate it?
Comment #32
mpdonadioThere is some IRC conversation going on right now about this. Once it is finished, I will post a new patch.
Comment #33
alexpottAs pointed out in IRC we've (ab)used label for this already so ignore #28 - we still need to address #29 since clearing the cache twice is unnecessary.
Comment #34
mpdonadioHere is the adjustment to the update hook.
Once this is in 8.3.x, it would just need a quick change to the update hook to make it work for 8.2.x. I don't see why it wouldn't be eligible since datetime_range is still officially experimental, and even with that we are only adding a translatable string, not changing any.
Comment #35
mpdonadioComment #36
gábor hojtsyYay, thanks!
Comment #37
alexpottAh of course this is experimental... this should be an 8.2.x update - we can't change update numbers like that. So we need to do it before committing to 8.3.x. And thne we can cherry-pick for 8.2.x
Comment #38
lomasr commentedPlease correct me if I am wrong : With a date range field I am getting date like "Tue, 10/11/2016 - 12:00 - Mon, 10/31/2016 - 12:00 " . Is it expected to come 'and' instead of '-' . Please see the screen. if '-' is good to show . Then I think we don't need to translate.
Comment #39
mpdonadioOK, update hook renamed.
#38, since this is a configurable setting, a user is free to set to to anything they want. If they choose a word or phrase, this will allow it to be translated when needed. It is also helpful to allow it to be translatable in case where the default '-' may not make sense for a particular locale.
Comment #40
jhedstromI think this is back to RTBC.
Comment #41
anish.a commentedThe steps for reproducing the issue need to be updated. I couldn't reproduce the exact issue as of now.
Comment #42
catchSince this is experimental I think it's better if it goes into 8.2.x - I'm assuming @alexpott forgot to change the version in #37 but in case there was an explicit reason to leave it against 8.3.x, assigning for a chance to comment.
Comment #43
catchSorry only realised this after posting the review and stepping afk.
We shouldn't use hook_update_N() for empty updates to trigger a cache flush - it adds all the potential complexity of schema versions between minor branches, conflicts with other patches, inconsistencies if there's a revert etc. hook_post_update_NAME() achieves the same thing without most of that trouble.
Comment #44
mpdonadioOK, here we go.
Comment #45
catchThat's great, thanks!
Comment #46
alexpottCommitted and pushed a55967d to 8.3.x and da66644 to 8.2.x. Thanks!
Comment #50
gábor hojtsy