Since date formats in shipped config are going to end up on localize.drupal.org, they need to have a context to be able to identify them. Strings like "Y" or "m-d" will be confusing for translators, without a context.

@Gabor mentioned there was some discussion for adding context to schema in general, but I couldn't find an issue.

I'm not familiar with core's config translation, so I'd like to know how big (or small) of a change would it be to add context (for date_formats at least) in core? Is it even possible?

Files: 
CommentFileSizeAuthor
#6 add-date_format-context-2333987-6.patch2.67 KBherom
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,984 pass(es). View
#6 interdiff-2333987-4-6.txt1.75 KBherom

Comments

Gábor Hojtsy’s picture

Issue tags: +language-config

Yeah I *think* there is/was an issue to add context support to config schemas, so when you provide a schema you can not only specify "translatable: true" but also "translation_context: ..." or something along those lines. I cannot find that issue right now. It would need support on both built-in Drupal and localize.drupal.org though. Not sure it is feasible / possible to implement this just for date formats, they are just translated as config entities like anything else.

herom’s picture

Status: Active » Needs review
FileSize
406 bytes
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,875 pass(es), 6 fail(s), and 2 exception(s). View

One word: "Awesome". Meaning, config schema already supports context; It just wasn't used till now.

Status: Needs review » Needs work

The last submitted patch, 2: add-date_format-context-2333987.patch, failed testing.

herom’s picture

Status: Needs work » Needs review
FileSize
1.36 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,938 pass(es). View

Added a one-line test fix.

Gábor Hojtsy’s picture

Title: Add context for date_format config translations. » Add context for date_format config translations
Status: Needs review » Needs work
Issue tags: +sprint

Oh, gosh :D Little known features are interesting, eh? :) I would *love* to rename this to something where we don't say "locale" since we so successfully eradicated "locale" from everywhere. Something like "translation context" or "string context". Since this is the first use of it ever, we could likely do it here if you agree.

Otherwise the patch itself looks good.

Since this is the first use of context in relation to config translation, it would also be great to add an integration test for this, but looks like the existing test may be covering it already, since it is going to add a translation, etc. So looking at that test, it seems to prove this integration works. So only renaming to a more sensible name is left.

herom’s picture

Status: Needs work » Needs review
FileSize
1.75 KB
2.67 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,984 pass(es). View

Ok. Replaced with "translation context". That fits better with "translatable".

Gábor Hojtsy’s picture

Title: Add context for date_format config translations » Fix schema translation context terminology and add context for date_format configuration
Category: Task » Bug report
Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Looks great.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Nice!

Committed ea561c1 and pushed to 8.0.x. Thanks!

  • alexpott committed ea561c1 on 8.0.x
    Issue #2333987 by herom: Fixed schema translation context terminology...
Gábor Hojtsy’s picture

Issue tags: -sprint

Documented this at https://www.drupal.org/node/1905070/revisions/view/7470481/7614325 yay :) Boo for not having docs for this before. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.