I found the following string and like to point out that this is not very good for translation. Sometimes you came in situation where this "!link" text must be context sensitive pronounced or something else - and then the translator will run in troubles... if you are trying to reuse content type settings in different cases the string The default priority for specific content types can be set on the !link pages. should be changed to be specific so it don't get unreadable or wrong.

Comments

hass’s picture

Status: Active » Needs review
StatusFileSize
new1.19 KB

Patch attached to solve this problem.

darren oh’s picture

Can you give an example of what could go wrong?

hass’s picture

Yep, In German i translate content type settings with Einstellungen für Inhaltstypen. If i translate the full sentence The default priority for specific content types can be set on the !link pages it would end with Die Standardpriorität für spezische Inhaltstypen kann auf der Seite !link eingestellt werden.. If i mix both together i get big sh** Die Standardpriorität für spezische Inhaltstypen kann auf der Seite "Einstellungen für Inhaltstypen" eingestellt werden.. It would better be Die Standardpriorität für spezische Inhaltstypen kann auf der Seite für "Inhaltstypen" eingestellt werden. what only means 'content types' and is the translated title of the content type page made by core translators. What you does here is not context sensitive. If someone will start reusing (or already doing) the string the content type settings it may need a different meaning or accent. Often you need to attach an S somewhere or remove it on a other situation in German... other language have much more difficulties here.

However you understand the German above or not - there was a consense with the core developers to make strings more context sensitive. I lost the case number with this discussion... but Garbor said - that such context less strings will create big difficulties in translations... thats all. It simply make translators live much easier... i know my other languages are much much more context sensitive then German <> English.

darren oh’s picture

I must be misunderstanding something. My purpose in writing the string as it is was to keep HTML out of it. Your suggested change puts the HTML back in the string. A link to the discussion would be helpful.

hass’s picture

I will try to find this discussion again... but you could also take a look into D6 core and how it is done there.

darren oh’s picture

Status: Needs review » Closed (won't fix)

I'm going to save this for the Drupal 6 branch.

hass’s picture

darren oh’s picture

Status: Closed (won't fix) » Closed (works as designed)

Sorry for the "won't fix." I'm changing this to by design for the Drupal 5 version. Hopefully the guidelines for converting modules to Drupal 6 will address this question.

avpaderno’s picture

Title: Translation may be context sensitive... » Translation may be context sensitive
Category: bug » feature
Status: Closed (works as designed) » Fixed

I am changing the status to fixed to make the report close automatically after 2 weeks.
I am changing the category as the report doesn't describe a bug of the code.

hass’s picture

Category: feature » bug
Priority: Minor » Normal
Status: Fixed » Active

This is a bug. Please read the t() docs http://api.drupal.org/api/function/t.

Here is an example of incorrect usage of t():

$output .= t('<p>Go to the @contact-page.</p>', array('@contact-page' => l(t('contact page'), 'contact')));

Have the patch been committed?

avpaderno’s picture

Status: Active » Closed (duplicate)

In this case, this is a duplicate of #345654: Correct the calls to t().
Anyway, the report topic was about Translation may be context sensitive, and not about the incorrect usage of t().

hass’s picture

Title: Translation may be context sensitive » Translatable strings review
Status: Closed (duplicate) » Needs review

Changing back, patch is above and needs review. We change the topic here. No need for a new case.

avpaderno’s picture

Category: bug » support
Status: Needs review » Fixed

The report refers to 5.x-1.2 which is an obsolete version.
The only versions which take fixes are 5.x-2.x-dev, and 6.x-1.x-dev which are changed to reflect the code I am using on the version of the module I am developing internally.

I am changing the category because the report is about the choice of strings to use; the change proposed was to make easier for who translate the module to a different language, not because the module was not working correctly.
As a matter of fact, the versions which receive the bug fixes are available only in English.

The incorrect use of t() is another issue, that is completely separated from the current one. There is already a report about that.

hass’s picture

Version: 5.x-1.2 » 5.x-2.x-dev
Category: support » bug
Status: Fixed » Needs review

Then move this to the latest version. THIS IS A BUG that was filed at 1.2 times - nothing else. Patch is here http://drupal.org/node/192939#comment-632339

avpaderno’s picture

Category: bug » feature
Status: Needs review » Fixed

There we go.
The code has been changed in 5.x-2.x-dev; therefore the patch does not apply anymore.

Repeating myself, the use of a word in a UI is not a bug. If it would be so, then all the times a module uses a word that for me is not correct, I could report a bug.

hass’s picture

Category: feature » bug
Status: Fixed » Needs review
StatusFileSize
new11.73 KB

Patch updated for D5 2.x.

If a patch no longer applies set a case to CODE NEEDS WORK, but never close it.

avpaderno’s picture

Status: Needs review » Needs work

The patch also changes Site map into XML site map which was object of a different report to which Darren Oh replied that he was not going to change it if he would not have seen a real need to change it.

The line return 'unsupported type '. $type .'for xmlsitemap_placeholder'; doesn't need to be localized because it's not shown to the end user. That function, that is a port of a function existing for Drupal 6 (db_placeholder()) should return a placeholder to be used for the data type passed to the function; when the function get an invalid argument, it returns that value that will cause the query to fail, and will be only visible in the log that reports the query which caused the error.
Being reported inside a query that use English words, it doesn't have any meaning to be translated; if that would be the case, then also the SQL queries that update.php shows in the final report would need to be translated.

For the change from Site map to XML site map I will open a task report; if that task is reported by other people to be necessary, then I will make the necessary changes.

hass’s picture

Is return 'unsupported type '. $type .'for xmlsitemap_placeholder'; used in a watchdog message?

avpaderno’s picture

No, it is not.
The string returned should be normally something like '%s', %f, used to build the query. When the function gets a value for $type that the function is not able to handle, it returns a value that makes the query fail, as it takes the assumption it gets a wrong value because something else is wrong in the code, somewhere.

Anyway, the Drupal 6 code doesn't return a translated string in the function I back ported to Drupal 5, so I don't see any reason to do it in the code I wrote, which is merely a copy of code existing in Drupal 6.

avpaderno’s picture

Category: task » bug
Status: Needs review » Needs work

Well, I could close it because the only string subject of the patch was already modified.
Patch (code needs work) would mean there are some changes to be applied; in this case, the change would have made the patch an empty file.

avpaderno’s picture

This report is partially matching #345654: Correct the calls to t().
You keep to say they are two different issues, then in your patch there would not be any corrections that change the call to l() into a call to url() As that change is already reported in that task report, it should not corrected in this issue.

hass’s picture

Updated patches attached to fix all translatable string issues in the module.

hass’s picture

Status: Needs work » Needs review
avpaderno’s picture

Category: bug » task
Status: Needs review » Needs work

The patch needs to be changed as more code has been ported from the Drupal 6 branch I am developing internally.
The back-port also includes the use of translatable strings used in the priority settings that before used values like '1.0', '0.9', '0.8' without to pass them to t().

Having corrected the use of a wrong function, the category can now be changed; bug report usually refers to code bugs.

hass’s picture

Status: Needs work » Needs review
StatusFileSize
new11.59 KB
new2.65 KB

Re-roled patches.

D6: You need to fix one bug by hand. There is one char in the string that cannot be fixed with a patch file. Search for t('This number will be multiplied by the ratio of the number of comments on a post to the highest number of comments on any post. After the word "post" you see a rectangle.

avpaderno’s picture

Category: bug » task

The description strings used in the implementation of hook_schema() are all passed to t() like is evident in the documentation; if you then see how the core modules implement that hook, you will see they all do the same (just to make an example, book_schema(), node_schema()).

This issue is referred to 5.x-2.x-dev; let us change the code in that version, and pass to 6.x-1.x-dev successively.

hass’s picture

Status: Needs work » Needs review

The hook_schema() stuff no more needs to be translated. You are not up-to-date and the docs are also not up-to-date! See #332123: Remove t() from all schema descriptions. Simply commit the patches and do not discuss any longer, please. I'm one of the most if not the most active developer about translatable string fixes. I know very well what I'm talking about and how it should looks like.

avpaderno’s picture

Your affirmation is not completely true, as the issue has not been fixed.

I would remind you that you were suggesting to to make translatable a string used by a port made by me, when even the original code passed that string to t().
Then I would make you notice that wrong patches are not accepted, whomever submit them; it could be even the Pope, but a wrong patch still is a wrong patch.

To complete, the report is for 5.x-2.x-dev which doesn't even have a schema API.

avpaderno’s picture

'@' should be used only for input got from external sources, and I am not sure that is always true when you use it.

I would suggest you to not submit any patches, as I am still porting the code I internally developed to the development snapshots.

hass’s picture

See the t() examples in the API docs together with url(). All are using @. I can also not remember the url, but we should use "@" by default and "%" for titles inside a string and "!" only if we need to pass something as is into the string (for e.g. HTML code that must not run through check_plain).

About the schema API changes - you may not aware about the persons who are listed in the tread, but if Gabor say - he will commit and support this change, be assured this will get committed very soon. I expect this will happen for Drupal 6.9. There is no more any discussion if this change should not be done or not. So don't waste translators valuable time and remove them.

Feel free to change the Version selectbox after you committed the D5 patch to D6. This is the way we work for ages if we discuss general bugs and finally if patches for multiple versions have been appended. There is NO need to have extra cases for every version with the same issue.

avpaderno’s picture

Until the referring version is 5.x-2.x-dev all the patches must focus on that version; adding a patch for a version for which the issue has not been opened creates just confusion on who follows the report.

I hope we agree on this.

avpaderno’s picture

As far as I can read, the differences between the placeholders for t() are the following:

  • !variable indicates that the text should be inserted as-is.
  • @variable indicates that the text should be run through check_plain(), to escape HTML characters.
  • %variable indicates that the string should be HTML escaped and highlighted with theme_placeholder().

That means that, if I don't need to pass the value which replaces the placeholder through drupal_validate_utf8(), or htmlspecialchars() (which is what check_plain() does) I would not use '@'.
It could even happen with the input received from the user, if the input is, i.e., converted into an integer with (integer) $input, and then it is used in a string (which normally happens if that value is output into a Drupal page). In such case both the functions (drupal_validate_utf8(), and htmlspecialchars()) are useless: a string which contains digit characters is surely valid UTF-8, and it surely doesn't contain HTML characters that must be escaped.

Therefore the assumption that '@' placeholder strings must be used by default must be reviewed.

avpaderno’s picture

Status: Needs review » Needs work

This has been fixed in CVS for 5.x-2.x-dev.
I will change the code for Drupal 6 branch as well, later.

The code still uses the !variable placeholder when the value which replaces it is a constant string or it's a value that is an integer (I also added a simple check on the value returned by a function to be sure the value is an integer).

There is still something that needs to made better. The string '!sitemap submitted to !engine' (with '!sitemap' being replaced by 'Site map index', or 'Site map') should be changed, as it maybe opens again the problem of a translatable string given without a context; I don't know if this is the case, but it could be that site map is translated in more than one way in some languages.

avpaderno’s picture

Status: Needs work » Needs review

The only solution I can find is to simply use Site map submitted to !engine. It could be confusing to read the same message repeated more than once in row in the log, but I don't think it's requested this level of detail, in this case.

avpaderno’s picture

Status: Needs review » Fixed

I also applied the change I was talking before in CVS.
I will make the necessary changes for the Drupal 6 branch later; the commit for Drupal 6 will be delayed, as I am changing the development snapshot code to the code I was testing internally.

I am setting the status to fixed until I don't change the referring version to 6.x-1.x-dev.

hass’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev
Status: Fixed » Needs review
hass’s picture

avpaderno’s picture

Status: Needs review » Fixed
avpaderno’s picture

Status: Fixed » Postponed
avpaderno’s picture

Status: Postponed » Fixed

The changes have been committed in CVS.

Status: Fixed » Closed (fixed)

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