Allow customization of 'Save' and 'Quote' buttons text

yhager - July 18, 2008 - 06:27
Project:Stock
Version:5.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

This patch allows the administrator to set different text for the 'Save' and 'Quote' buttons.

AttachmentSize
yh.patch2.49 KB

#1

kbahey - July 19, 2008 - 00:51
Status:needs review» needs work

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.

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.

#2

yhager - July 19, 2008 - 05:27

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

<?php
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.

#3

yhager - July 19, 2008 - 05:32

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.

#4

kbahey - July 19, 2008 - 17:41

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.

#5

yhager - July 19, 2008 - 19:56

Yes, 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.

#6

kbahey - July 19, 2008 - 20:59

If you can fix these problems with wrong t() and have the time, please do so via a patch.

#7

yhager - July 20, 2008 - 05:10

If 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.

 
 

Drupal is a registered trademark of Dries Buytaert.