Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heykarthikwithu created an issue. See original summary.

heykarthikwithu’s picture

Assigned: heykarthikwithu » Unassigned
Status: Active » Needs review
FileSize
620 bytes

Added a patch for this.

jhodgdon’s picture

Status: Needs review » Needs work
Issue tags: +rc eligible
+++ b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php
@@ -59,6 +59,8 @@ public function reset() {
+   * @return array
    */

Thanks... but it is not OK to add a @return without a documentation line telling what the return value is.

heykarthikwithu’s picture

Assigned: Unassigned » heykarthikwithu
heykarthikwithu’s picture

Assigned: heykarthikwithu » Unassigned
Status: Needs work » Needs review
FileSize
664 bytes
569 bytes

Added documentation for @return.

heykarthikwithu’s picture

Priority: Normal » Minor
Issue tags: +Quick fix
heykarthikwithu’s picture

Issue tags: -rc eligible
jhodgdon’s picture

Status: Needs review » Needs work
Issue tags: -Quick fix

Thanks 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.

rang501’s picture

Status: Needs work » Needs review
FileSize
856 bytes
1.13 KB

Hi!
It should be more accurate now.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks for the patch! It's getting better, but still needs some work.

  1. +++ b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php
    @@ -55,10 +55,14 @@ public function reset() {
    +   * Retrieve translations by given language.
    

    Retrieve -> Retrieves
    by given -> for a given

  2. +++ b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php
    @@ -55,10 +55,14 @@ public function reset() {
    +   * @return array
    +   *   Returns array of translations indexed by language and context or an empty
    +   *   array when no translations are available.
    

    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.

rang501’s picture

Status: Needs work » Needs review
FileSize
923 bytes
1002 bytes

Hi! Thanks for the review!
The return docs should be better now.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks!

+++ b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php
@@ -55,10 +55,15 @@ public function reset() {
+   *   A multidimensional array of translations indexed by the context the
+   *   source string belongs to and the original string or an empty array when
+   *   no translations are available.

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.

rang501’s picture

Hi!
Thanks for the fast response.
Hopefully this is better now.

rang501’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! 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!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 2606246-13.patch, failed testing.

jhodgdon’s picture

bot fail. :(

jhodgdon’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 2606246-13.patch, failed testing.

rang501’s picture

Status: Needs work » Reviewed & tested by the community

Bot failed, marking it back RTBC.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!

  • catch committed 0b93076 on 8.1.x
    Issue #2606246 by rang501, heykarthikwithu: StaticTranslation::...

  • catch committed 8d5e4c9 on 8.0.x
    Issue #2606246 by rang501, heykarthikwithu: StaticTranslation::...

Status: Fixed » Closed (fixed)

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