Comments

Chi created an issue. See original summary.

lucian.gutoiu’s picture

Assigned: Unassigned » lucian.gutoiu
lucian.gutoiu’s picture

StatusFileSize
new427 bytes

It actually returns a TranslatableMarkup object.

lucian.gutoiu’s picture

Status: Active » Needs review
goz’s picture

Status: Needs review » Needs work
+++ b/core/includes/bootstrap.inc
@@ -305,7 +305,7 @@ function drupal_get_path($type, $name) {
  * @return

Add @return type \Drupal\Core\StringTranslation\TranslatableMarkup.

Also replace 'The translated string.' in @return comment from translate method in \Drupal\Core\StringTranslation\TranslationInterface.

sdstyles’s picture

Status: Needs work » Needs review
StatusFileSize
new1.16 KB
new909 bytes
goz’s picture

Status: Needs review » Reviewed & tested by the community

Good job @all

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs work

Good idea to fix up these docs! But:

+++ b/core/includes/bootstrap.inc
@@ -304,8 +304,8 @@ function drupal_get_path($type, $name) {
+ * @return \Drupal\Core\StringTranslation\TranslatableMarkup
+ *   A translated TranslatableMarkup object.

This is not accurate. The returned object is not yet translated when it is returned. The point of that return value (one of them anyway) is that translation is done later.

Same in the other hunk.

snehi’s picture

i think

A TranslatableMarkup object

will work or

The TranslatableMarkup object

jhodgdon’s picture

A is better than The here, I think.

goz’s picture

35 occurrences for "A something object" in comments based on regex @return [a-zA-Z/\\]*\n \* A [a-zA-Z]+ object

122 occurrences for "The something object" in comments based on regex @return [a-zA-Z/\\]*\n \* The [a-zA-Z]+ object

I prefer The because we ask for the translation of the string passed as param (and not a random translation from many possible translations). So we return the translatableMarkup.

jhodgdon’s picture

"The" requires an antecedent, and "A" is for introducing a new thing, grammatically. There are plenty of cases where "the" is appropriate to start a @return, like "The input $foo, transformed by bar baz.".

But in this case, the object doesn't exist before this function call. So the return docs should be something like:

A new foobar object that, when cast to a string, will result in the translated string.

snehi’s picture

Status: Needs work » Needs review
StatusFileSize
new1.13 KB
new340 bytes

Done as suggested by @jhodgdon

jhodgdon’s picture

Status: Needs review » Needs work

Not really what I suggested?

anil280988’s picture

Status: Needs work » Needs review
StatusFileSize
new1.12 KB
new1.12 KB

Hi Jhodgdon,
Made the changes.

chi’s picture

Status: Needs review » Needs work
  1. +++ b/core/includes/bootstrap.inc
    @@ -305,7 +305,8 @@ function drupal_get_path($type, $name) {
      * @return
    

    The type of the return value is missing.

  2. +++ b/core/includes/bootstrap.inc
    @@ -305,7 +305,8 @@ function drupal_get_path($type, $name) {
    + *   A new Markup object that, when cast to a string, will result in the
    
    +++ b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php
    @@ -34,7 +34,8 @@
    -   *   The translated string.
    

    Why 'Markup' but not 'TranslatableMarkup'?

goz’s picture

Assigned: lucian.gutoiu » Unassigned
anil280988’s picture

Assigned: Unassigned » anil280988
Status: Needs work » Needs review
StatusFileSize
new1.28 KB
new1.28 KB

Done as suggested by @Chi

Status: Needs review » Needs work

The last submitted patch, 18: wrong_documentation_of_t-2585781-18.patch, failed testing.

chi’s picture

+++ b/core/includes/bootstrap.inc
@@ -305,8 +305,8 @@ function drupal_get_path($type, $name) {
  * @return

The type of return value is still missing.

anil280988’s picture

Status: Needs work » Needs review
StatusFileSize
new1.42 KB

Hi Chi,
Made the changes

Status: Needs review » Needs work

The last submitted patch, 21: wrong_documentation_of_t-2585781-21.patch, failed testing.

anil280988’s picture

Status: Needs work » Needs review
StatusFileSize
new1.29 KB

Hi Chi,
Made the changes

chi’s picture

+++ b/core/includes/bootstrap.inc
@@ -304,8 +304,9 @@ function drupal_get_path($type, $name) {
+ *   in the translated string.

+++ b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php
@@ -34,7 +34,8 @@
+   *   A new TranslatableMarkup object that, when cast to a string, will result

I would remove 'new'. Nearly all Drupal functions and methods return something new. Since there is no 'old' TranslatableMarkup object in this context 'new' looks redundant for me.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

It's technically meaningful to say "new" actually... not a bad idea... I think this is fine. Thanks!

The last submitted patch, 18: wrong_documentation_of_t-2585781-18.patch, failed testing.

The last submitted patch, 21: wrong_documentation_of_t-2585781-21.patch, failed testing.

yesct’s picture

cool. it is great to find this being fixed.

+++ b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php
@@ -34,7 +34,8 @@
+   *   A new TranslatableMarkup object that, when cast to a string, will result
+   *   in the translated string.

I had a similar change in #2578377: Make translatable docs consolidated and better for developers
but used slightly different words "An object that, when cast to a string, will yield the translated string."

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

I like @YesCT's version - fixed on commit. Committed fd6f9cb and pushed to 8.0.x. Thanks!

  • alexpott committed fd6f9cb on 8.0.x
    Issue #2585781 by anil280988, Davinder.Snehi, sdstyles, lucian.gutoiu,...

Status: Fixed » Closed (fixed)

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