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.
StaticTranslation::getLanguage
, add @return
values in the comment docblocks.
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff-11-13.txt | 959 bytes | rang501 |
#13 | 2606246-13.patch | 967 bytes | rang501 |
#11 | interdiff-9-11.txt | 1002 bytes | rang501 |
#11 | 2606246-11.patch | 923 bytes | rang501 |
#9 | interdiff-5-9.txt | 1.13 KB | rang501 |
Comments
Comment #2
heykarthikwithuAdded a patch for this.
Comment #3
jhodgdonThanks... but it is not OK to add a @return without a documentation line telling what the return value is.
Comment #4
heykarthikwithuComment #5
heykarthikwithuAdded documentation for
@return
.Comment #6
heykarthikwithuComment #7
heykarthikwithuComment #8
jhodgdonThanks for the patch... but I don't think this is really correct.
Looking at StaticTranslation::getLanguage:
- The first line of the doc block is not correct. It says "Add translations for new language" but that is not what it does, and besides which first line doc blocks should start with a verb ending in S.
- The return value docs in the patch are also unclear and incorrect. You need to look at what some of the overriding methods do to get an idea. Start from
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!StringTranslation...
and then look at "2 methods override..."
Also you can look at the method getStringTranslation() that calls this method, to get more of an idea of the structure it returns.
So what it's really doing, I think, is returning all of the translations for the given language, in an array. The documentation should document the structure of this array.
Comment #9
rang501 CreditAttribution: rang501 at ADM Interactive commentedHi!
It should be more accurate now.
Comment #10
jhodgdonThanks for the patch! It's getting better, but still needs some work.
Retrieve -> Retrieves
by given -> for a given
We don't normally start @return docs with "Returns", so just leave that word out.
Also I don't understand what this is saying. Is it it a multi-dimensional array indexed first by language and second by context... what is context if so? This needs more detail still.
Comment #11
rang501 CreditAttribution: rang501 at ADM Interactive commentedHi! Thanks for the review!
The return docs should be better now.
Comment #12
jhodgdonThanks!
Better, but still not quite clear:
- Which index is first, context or string?
- Needs punctuation. It is all one long string of text without even a comma. I suggest comma after "translations".
- I also think the "or an empty array" should maybe be made into a separate sentence because it is pretty run-on as it is? At a minimum, needs some punctuation to set that part apart.
Comment #13
rang501 CreditAttribution: rang501 at ADM Interactive commentedHi!
Thanks for the fast response.
Hopefully this is better now.
Comment #14
rang501 CreditAttribution: rang501 at ADM Interactive commentedComment #15
jhodgdonThanks! That is clear enough... maybe we could come up with a slightly better wording, but it is readable and correct, so that makes it Good Documentation (TM). Thanks!
Comment #17
jhodgdonbot fail. :(
Comment #18
jhodgdonComment #20
rang501 CreditAttribution: rang501 at ADM Interactive commentedBot failed, marking it back RTBC.
Comment #21
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!