For some very odd reason the text found on user/%user/tokenauth ("You may use an alphanumeric token to see restricted content...") is saved in a variable in the database. I have got no clue why this would be a good idea. How many administrators would need to replace that text? The text does convey the information it needs to...

I suggest the string is properly wrapped in a t() to make it translatable to more than one language (storing a translated value in the database won't work for multilingual sites/users with different languages). This will allow all users to have it translated to their language.

I've gone through the module and removed all instances of the variable tokenauth_text and optimized the code, where it was needed.

Comments

Grayside’s picture

Issue tags: +localization

The text for that UI is set because Tokenauth serves a wide number of use cases and workflows because of it's configurability. If we were to add #990468: Setting to always add token to links we could discuss moving the UI to a separate module, and treating it more as an example than a configurable feature.

As such, using t() to fix this is unacceptable, however using the utilities provided by modules like i18n might take this forward.

lund.mikkel’s picture

I'm not sure I quite follow you. The current setup may be configurable, but it still doesn't allow for translations on multilingual sites...

Why is t() unacceptable in this case?

Grayside’s picture

Took a closer look, seems I mistook your argument for the patch.

To address the actual change: tokenauth_text_load() does have default text that can be wrapped in a t(), but there are two problems with this:

  • Only the default value would be used, not whatever the value is configured to be. Thus, inconsistencies in handling.
  • This value is also used to populate the administrative form.

My point is thus that t() is not compatible with the existing configurability, but internationalization functionality is compatible.