Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

FileSize
1.39 KB

Better -- extractor tools were twice.

The last submitted patch, StringTranslationTrait.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 1: StringTranslationTrait.patch, failed testing.

cs_shadow’s picture

Status: Needs work » Needs review
FileSize
1.41 KB

Re-roll of #1.

jhodgdon’s picture

Status: Needs review » Needs work

This is great documentation -- very clear and explains why I would want to use this.

A few little things to fix:

a) Not only t() but formatPlural() is added, and using both methods is essential for making sure text is translatable.

b) translateable is misspelled (should be translatable).

c)

+ * every translateable string similarly to how procedural code must use the

How about "... every translatable string, similar to how..." ?

d) Maybe add

@see container

at the end to link to the Services and Container topic (since you talk about injecting services)?

e)

+ * @see Drupal\Core\StringTranslation\TranslationInterface

Class namespace should start with \

er.pushpinderrana’s picture

Status: Needs work » Needs review
FileSize
1.14 KB
1.42 KB

Incorporated all #5 suggested points in this patch. Please review.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks! Almost there...

 * Using this trait will add a t() and formatPlural() method to the class. This must be used for

Should say "add t() and formatPlural() methods" and "These must be used", since there are now two methods described. And then in the next sentence:

+ * every translatable string, similar to how procedural code must use the
+ * global function t(). This allows string extractor tools to find

... global functions t() and formatPlural().

Also that first line is too long. Documentation lines should not exceed 80 characters.

er.pushpinderrana’s picture

@jhodgdon, please review, did the required changes.

jhodgdon’s picture

Status: Needs review » Needs work

99% there, thanks!

+ * must use the global function t() and formatPlural(). This allows string

function -> functions

er.pushpinderrana’s picture

Status: Needs work » Needs review
FileSize
1.44 KB

Changed function to functions.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now, thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php
@@ -10,14 +10,17 @@
+ * must be used for every translatable string, similar to how procedural code
+ * must use the global functions t() and formatPlural(). This allows string

format_plural() - we're talking about the procedural function here.

chx’s picture

Status: Needs work » Needs review
FileSize
1.44 KB

Status: Needs review » Needs work

The last submitted patch, 13: drupal-fix_StringTranslationTrait_doxygen-2292197-10.patch, failed testing.

chx’s picture

Status: Needs work » Needs review
FileSize
792 bytes

@alexpott accidentally committed this in 4b91f16d48490343f0d0c5abf1b915b21788550c with the formatPlural still in place .

alexpott’s picture

I've reverted 4b91f16d48490343f0d0c5abf1b915b21788550c so that we can get the correct commit history. Patch in #13 is the correct patch to review :)

jhodgdon’s picture

Status: Needs review » Needs work

Looking at the patch in #13:

+ * Using this trait will add t() and format_plural() methods to the class.

No, I think the methods added are t() and formatPlural(), right?

and then:

+ * These must be used for every translatable string, similar to how procedural
+ * code must use the global functions t() and formatPlural(). This allows

this should say global functions t() and format_plural().

chx’s picture

bah, i got it totally backwards, didnt I? If noone else rerolls i will later today

LinL’s picture

Status: Needs work » Needs review
FileSize
1.44 KB
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks LinL! This patch looks right to me.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed aa898f8 and pushed to 8.x. Thanks!

  • alexpott committed aa898f8 on 8.x
    Issue #2292197 by er.pushpinderrana, chx, LinL, cs_shadow: Fixed The...

Status: Fixed » Closed (fixed)

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