Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
How do we translate instructions in crossword-instructions.tpl.php?
Proposed resolution
Implement https://www.drupal.org/docs/theming-drupal/twig-in-drupal/create-custom-...
Whether accepted, I will post a patch for this
Comment | File | Size | Author |
---|---|---|---|
#8 | i18t-instructions-3232280-6.patch | 2.71 KB | afagioli |
#5 | i18t-instructions-3232280-4.patch | 2.69 KB | afagioli |
Comments
Comment #2
afagioliComment #3
danflanagan8The current way to customize the instructions is to put a
crossword-instructions.html.twig
in your site's theme and then make the text whatever you want.That's clumsy though because it assumes the site has a custom theme, which isn't always the case.
One option would be to wrap all the bits of text in
crossword-instructions.html.twig
in{% trans %}
tags, which would allow translation through the UI. That might be good enough?I'm not too familiar with translation and internationalization from the site-building perspective, so your insight would be helpful here.
Comment #4
afagioliText to be translated in crossword-instructions.tpl.php is so specific. No need now to face the "context" element in translation.
Thus, the easiest
{{ 'Active Square'|t }}
seems to be enough.Patch on the way...
Comment #5
afagioliComment #6
danflanagan8Looks like you missed "Arrow Keys"
Other than that it looks good when I test it out. If you make that update I'll commit.
I have a question about a comment you made though:
I don't see any difference between using
|t
and using{% trans %}
. Could you clarify?Comment #7
danflanagan8Also, would you be able to provide an Italian translation for the instructions? I'm new to this, so I'm not sure if that goes in the module or if it goes to localize.drupal.org. But that would be really cool.
Comment #8
afagioliImproving previous patch with missing string.
Thanks for pointing that out.
Comment #9
afagioliSure thing.
Following https://www.drupal.org/docs/8/api/translation-api/overview > Translation in Twig templates,
|t comes handy most of times while I can use {% trans %} for more complex cases. Let's say we need to add the string "down" in the crossword-instructions.html.twig
As translator, the "down" word is ambiguous. With {% trans %} I can add a "crossword" context to this string. This way I will have the default "down" string ("giù" in italian) and the crossword "down" ("vertical" in italian).
Real case at https://www.drupal.org/project/crossword/issues/3232223#comment-14214443
I'm not sure this is clear. Feel free to ask for further clarification
Comment #10
afagioliComment #12
danflanagan8Committed patch from #8. Thanks for the patch and for teaching me about translation, @afagioli.
Comment #13
afagioli#7 in very useful also.
From Drupal 8, translation can be easily added from https://localize.drupal.org/translate/languages/it/translate?page=2&proj... , which is pretty cool.
From my understading we will be able to translation new internationalised strings with new the module release.
Should we maybe open a specific issue as reminder?
Comment #14
danflanagan8Thanks for the link, @afagioli. I've opened a new ticket for discussion and planning if you're interested: #3232748: Translation and Internationalization.
Comment #15
afagioliFollowing.
Thanks