alphabar instructions won't translate
| Project: | Glossary |
| Version: | 5.x-2.6 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active (needs more info) |
Jump to:
Due to the way, the alphabar instructions are implemented, they will never translate in localisation mode.
Currently, line 579 in glossary.module reads
<?php
$output .= variable_get('glossary_alphabar_instruction', _alphabar_instruction_default());
?>As far as the alphabar instruction is not translated when installing the module, the gloabl variable 'glossary_alphabar_instruction' is filled with the default english value.
Translations are ment to be dynamically implemented. Pushing the translation into the global variables makes this value static.
Due to the functionality of variable_get(), a value is returned from the global variables, if it is already set. As it *is* already filled with the default value, there is no way to get the translated value ....
... except using my patch, which makes line 579 read
<?php
$output .= _alphabar_instruction_default();
?>| Attachment | Size |
|---|---|
| glossary_translation.patch | 501 bytes |

#1
You can set whatever you want on the settings page - and it can be any language. You are correct that this value will not be translated after it is entered.
I suppose this is a matter of semantics. The "t()" function will only translate a string that was defined in the translation template. I would not consider this to be dynamic.
Your patch bypasses the text as entered by the admin. I cannot apply that as this feature was requested by another user some time ago.
#2
This indeed seems to be a matter of semantics.
In my case, the Glossary module is used on a multilingual page, so I have to consider that value as dynamic.
So, maybe something like
<?php$output .= t(variable_get('glossary_alphabar_instruction', _alphabar_instruction_default()));
?>
would do both our jobs without bypassing the text entered by the admin.
#3
That would be considered an incorrect use of t(). It has to be something like
t('a !type to translate', array('!type' => $type)). And even with that whatever the value of "$type" is will not be translated.#4
Any other suggestions? Does i18n provide anything?