Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There are a few methods to solve these issues, let me know your preference.
How does this work in a multilingual site? Now that the value is stored in a variable, it will appear in all languages, and becomes untranslatable.
Maybe we can use
t(variable_get('stock_save', 'Save'));
instead? It will use a localized string when available.
1. Use a theme function for the button, and people can override it with what they want.
That's right, but it's very nice to have the admin set the button text and not the themer/developer.
2. Use the strings override module.
That was my first attempt, but 'Save' is such a popular string, I was getting 'Add to portfolio' in the nodequeue pages, and many others..:)
Let me know which approach you prefer, I'll reroll the patch.
Taking another look at the code, I see that 'stock_description' has the same issues you mentioned, but for 'stock_block_title' and 'stock_overview_title', you use the t() function on the result of variable_get() - so I suggest to do the same, for consistency.
Actually, using t() on stuff that is not a constant is a mistake. The reason is that it cannot be translated using POT tools, since the constant cannot be extracted using these tools, since it is in the database.
So we need to correct the ones that use this method rather than use new ones.
Comments
Comment #1
kbahey CreditAttribution: kbahey commentedHow does this work in a multilingual site? Now that the value is stored in a variable, it will appear in all languages, and becomes untranslatable.
Other approaches:
1. Use a theme function for the button, and people can override it with what they want.
2. Use the strings override module.
Comment #2
yhager CreditAttribution: yhager commentedThere are a few methods to solve these issues, let me know your preference.
How does this work in a multilingual site? Now that the value is stored in a variable, it will appear in all languages, and becomes untranslatable.
Maybe we can use
instead? It will use a localized string when available.
1. Use a theme function for the button, and people can override it with what they want.
That's right, but it's very nice to have the admin set the button text and not the themer/developer.
2. Use the strings override module.
That was my first attempt, but 'Save' is such a popular string, I was getting 'Add to portfolio' in the nodequeue pages, and many others..:)
Let me know which approach you prefer, I'll reroll the patch.
Comment #3
yhager CreditAttribution: yhager commentedTaking another look at the code, I see that 'stock_description' has the same issues you mentioned, but for 'stock_block_title' and 'stock_overview_title', you use the t() function on the result of variable_get() - so I suggest to do the same, for consistency.
Comment #4
kbahey CreditAttribution: kbahey commentedActually, using t() on stuff that is not a constant is a mistake. The reason is that it cannot be translated using POT tools, since the constant cannot be extracted using these tools, since it is in the database.
So we need to correct the ones that use this method rather than use new ones.
Comment #5
yhager CreditAttribution: yhager commentedYes, you're right about t() usage.
Let me know if I can help making this patch acceptable, or you prefer to do the modifications yourself.
Comment #6
kbahey CreditAttribution: kbahey commentedIf you can fix these problems with wrong t() and have the time, please do so via a patch.
Comment #7
yhager CreditAttribution: yhager commentedIf you can fix these problems with wrong t()
Well, these problems are unrelated to the original patch, so let's use a different issue for those.
Let me know what else needs to be done with this patch.