The module provides an alternative interface for translating lines:
- translate a line into all languages on one page without unnecessary clicks;
- page of the translation line in all languages (as in drupal 7);
- possibility of translation via google translate service;
- availability of the google translate service on the pages of translation of field names, blocks, entities, views, etc .;
- block page reloads if no data is saved;
- exporting translations;
Dependencies
Project link
https://www.drupal.org/project/gtext
Git instructions
git clone --branch '9.0.x' https://git.drupalcode.org/project/gtext.git
Pareview checklist
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | file-gtext.txt | 18.45 KB | rohitrajputsahab |
Comments
Comment #2
anatolij zajika commentedComment #3
avpadernoThank you for applying!
Remember to change status, as in this queue Active tells the reviewers not to review the code, yet.
Comment #4
anatolij zajika commentedComment #5
anatolij zajika commented@apaderno Okey, Thanks.
Comment #6
anatolij zajika commentedComment #7
avpadernoComment #8
anoopjohn commentedI couldn't access the PAReview link with https. This worked - http://pareview.net/r/371. There are still a few pending items in there. Can you please take a look at those?
Comment #9
anatolij zajika commented@anoopjohn
Thanks, let's take a look now.
Comment #10
anatolij zajika commentedUpdate PAReview: http://pareview.net/r/371
Not possible
Not possible, because gText better readable than GText ... I think.
Comment #11
avpadernoThe documentation for
TranslatableMarkup::__construct()says:It's not clear the purpose of that code, when a module would just use code similar to the following one.
It's not also clear why the class would implement
__call(), which is invoked for every not existing method, instead of implementing a normal method.As for the class name,
gTextisn't more readable thanGtextorGText, which are the class names that follow the Drupal coding standards.Comment #12
anatolij zajika commentedWe do not see any security issues in this code. The following code is used in the kernel: https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/includes/boo...
When writing a module for a specific site, there will be no problems with using the record
gtext()->personal_site('Username');, but the code is a bit shorter.Closest comparison:
Оnly for convenience when using the function "t" (with context).
Both options will give the same result:
gtext()->personal_site('Username');andt('Username', array('context' => 'personal_site'));.The module simply provides an alternative in writing code.
The function name will be used as the context of the string translation:
Comment #13
anatolij zajika commentedComment #14
anoopjohn commentedI checked the two instances of the concatenation warning
FILE: /var/www/pareviewd/pareview_temp/wshijwft/src/Form/TranslateForm.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
264 | WARNING | Do not concatenate strings to translatable strings, they
| | should be part of the t() argument and you should use
| | placeholders
--------------------------------------------------------------------------
This concatenation does not affect the whole idea of t() being able to also handle structural and word ordering implications of languages. All of what t is to handle is actually handled by t().
FILE: ...pareviewd/pareview_temp/wshijwft/src/Twig/TwigTranslateExtension.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
65 | WARNING | Only string literals should be passed to t() where
| | possible
--------------------------------------------------------------------------
This is a wrapper to allow the translation function to be called within the class. So this is a false positive as well.
I concur with @apaderno on class naming. Even when acronyms are part of class names it is recommended to follow the Drupal standard. There is a long discussion around this on drupal.org - https://www.drupal.org/project/drupal/issues/1627350. It is worth a read :)
Comment #15
anoopjohn commentedComment #16
avpadernot()is allowed to use that code because that is Drupal core, but none of the modules are allowed to callt()ornew TranslatableMarkup()using a variable as first argument.The translation context is allowed to be a string containing spaces, such as in
t('December', [], ['context' => 'Long month name'])used by Drupal to get the translated month names. In those cases, that code won't work.Comment #17
seonic commentedAnother security vulnerability is a translation form on a route "gtext.translate"
Form on this route doesn't have a html validation and allows to save translations like
"<script src="https://somescript"></script>"The core interface translation form doesn't allow to save tags like this to prevent xss.
Comment #18
anatolij zajika commentedThe gText class is renamed to TextTranslationFactory, and the gTextTranslation class is renamed to TextTranslationWrapper.
Thanks @Seonic, іt was fixed.
"The parameter could be a variable if the entire string in $text has been passed into t() or new TranslatableMarkup() elsewhere as the first argument, but that strategy is not recommended.", but allowed.
But I understand that improper use of the functionality can lead to security issues, so a message has been added to the function descriptions.
This functionality does not replace the standard translation functionality, but only simplifies access to it. Convenience and the ability to use the wrapper at the discretion of the developer.
The functionality of text translation forms works regardless of the use of the wrapper.
Comment #19
anatolij zajika commentedComment #20
avpadernoThose properties are already defined from the parent class. There is no need to re-define them.
Functions in Drupal core or Drupal core module whose names start with an underscore should not be called, since they aren't part of the Drupal public API.
Modules should not access the values in
$_POST, as that is considered a security issue. There is also no need to access that global variable, since Symfony has methods to get those values.Symfony has also a method to get the value of
$_SERVER['HTTP_HOST'], which should not be accessed directly.Since the class is used for a configuration form, it should extend
ConfigFormBase, notFormBase.That code is returning the wrong plural formula for many languages, including Tibetan, Mapudungun, Chiga, Czech, Welsh, and French.
The error message isn't translatable.
Instead of deleting a form submission button, the code should set its
#accessproperty toFALSE.Comment #21
anatolij zajika commentedThanks @apaderno. The following fixes have been made:
Those properties are already defined from the parent class.Since the class is used for a configuration form, it should extend ConfigFormBase, not FormBase.Functions in Drupal core or Drupal core module whose names start with an underscore should not be called, since they aren't part of the Drupal public API.Modules should not access the values in $_POST, as that is considered a security issue.That code is returning the wrong plural formula for many languages, including Tibetan, Mapudungun, Chiga, Czech, Welsh, and French.That code is returning the wrong plural formula for many languages, including Tibetan, Mapudungun, Chiga, Czech, Welsh, and French.The error message isn't translatable.Comment #22
anatolij zajika commentedComment #23
rohitrajputsahab commentedPlease fix the error and the warning in the attached file.
Comment #24
rohitrajputsahab commentedComment #25
avpadernoUsing the following code, the title changes from First plural form for the first text area to 2. plural form for the second text area. That is probably not the desired effect. Rather then changing the title, it would be easier to use the same title for every plural form text areas; Drupal doesn't require that each form element have a unique title and Plural form is correct for every plural form text area.
Comment #26
anatolij zajika commented@apaderno, Thank you for following your example, and @rohit-rajput-sahab fixed errors.
Comment #27
avpadernoThank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
I thank all the dedicated reviewers as well.